[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

useful extra check in FS fold_change function

From: David Glasser <glasser_at_davidglasser.net>
Date: Thu, 18 Mar 2010 14:39:36 -0700

When dealing with some nasty cases in the almost-retired old Google
Code subversion backend, I found a kind of data corruption that the FS
code wasn't catching even though it caught relatively similar issues.
Specifically, find the fold_change function in both of the FS
implementations. There's a check:

      /* Sanity check: an add, replacement, or reset must be the first
         thing to follow a deletion. */
      if ((old_change->change_kind == svn_fs_path_change_delete)
          && (! ((change->kind == svn_fs_path_change_replace)
                 || (change->kind == svn_fs_path_change_reset)
                 || (change->kind == svn_fs_path_change_add))))
        return svn_error_create
           _("Invalid change ordering: non-add change on deleted path"));

It might also be nice to check the opposite condition: if change->kind
is add or replace, and old_change is not delete (or reset, I guess),
throw an error. (We had accidentally recorded the sequence "add,
prop-mod, text-mod" out of order as "prop-mod, add, text-mod", which
was interpreted as an "R" below instead of an "A"; this suggested
check would have caught it earlier.)

(Sorry, but I haven't managed to get a proper Subversion build
environment working in a while or I'd send a real patch.)


glasser_at_davidglasser.net | langtonlabs.org | flickr.com/photos/glasser/
Received on 2010-03-18 22:40:22 CET

This is an archived mail posted to the Subversion Dev mailing list.