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

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


# HG changeset patch
# User Peer Stritzinger <peer at stritzinger.com>
# Date 1319647632 -7200
# Branch stable
# Node ID 38b64b146e62047a7d94d4da36de65ed7808f4f5
# Parent  c1930992e1112f2bc0a6a38a84d43a34de72e180
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.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4756,15 +4756,14 @@ def revert(ui, repo, *pats, **opts):
                     # only need parent manifest in this unlikely case,
                     # so do not read by default
                     pmf = repo[parent].manifest()
-                if abs in pmf:
-                    if mfentry:
-                        # if version of file is same in parent and target
-                        # manifests, do nothing
-                        if (pmf[abs] != mfentry or
-                            pmf.flags(abs) != mf.flags(abs)):
-                            handle(revert, False)
-                    else:
-                        handle(remove, False)
+                if abs in pmf and mfentry:
+                    # if version of file is same in parent and target
+                    # manifests, do nothing
+                    if (pmf[abs] != mfentry or
+                        pmf.flags(abs) != mf.flags(abs)):
+                        handle(revert, False)
+                else:
+                    handle(remove, False)
 
         if not opts.get('dry_run'):
             def checkout(f):


More information about the Mercurial-devel mailing list