[PATCH 0 of 1] revert: fix missing removes when parent was changed in dirstate

Peer Stritzinger peerst at gmail.com
Wed Oct 26 11:49:55 CDT 2011


revert: fix missing removes when parent was changed in dirstate

When dirstate parent is changed with dirstate.setparent before a
revert so it no longer points to where the dirstate refered to, revert
does not remove all files it should:

Revert to a different revision needs also to remove files that are not
found through disptables and not in the context or parent manifest.

Example consider this repo:

       add:  a 	 b   c
    	     3---4---5   <- dirstate has x,a,b,c
    	    /
  add: x   /
      1---2
       \   \
       	\   \
       	 \   6---7 <-- has files x,y
       	  \  add: y
	   \
	    8---9---10
	    add: y   z


We just have commited rev 5.

Then we dirstate.setparent to 7

And revert all to rev 10

What would be expected is: a,b,c are removed, x stays, y and z are added.

What happens without this patch: depending on how fast all this happens
is that only some of a,b,c get removed (only those that have undefined
timestamp since they are in the modified table)

This sequence of setparent, revert and commit is used in a loop in the
hg collapse extension which works most of the time since it is fast
enough that almost always in such situations all files still have
undefined timestamp in dirstate.

This can be reproduced with this version of hgcollapse:

https://bitbucket.org/peerst/hgcollapse/src/17cf5b882746/

The testcase 

https://bitbucket.org/peerst/hgcollapse/src/17cf5b882746/test/test-hashchange.t

Fails with Mercurial 1.9.1 and the current stable.
After this patch is applied it passes.

The mercurial tests pass also with the patch applied.


More information about the Mercurial-devel mailing list