# HG changeset patch # User mpm@selenic.com # Date 1119408508 28800 # Node ID 3695fbd2c33bf81574b03840667a9c2670d749af # Parent 0e0d0670b2bc09ee721d4432a28a9123b98b91b8 [PATCH] Merging files that are deleted in both branches -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [PATCH] Merging files that are deleted in both branches From: Michael A Fetterman OK, attached is an improved version of this patch... When I went back through it, I discovered that the prior version was wrong when doing real merges (as opposed to jumping between revisions that have a simple linear relationship). So that's been addressed here, too. > Here's an hg changeset patch that deals with simultaneous deletion of a file > in both the working directory and in a merged branch. > > Test case included in the patch. manifest hash: c8078733c252403314d8046efa6ecefc49c83050 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCuNF8ywK+sNU5EO8RArtdAJ9syw/JXRZzP1sxnEYXzZywkJLAPACeKpqL 5osA3AggrCbbSLTNcYVXJ8U= =T5Ik -----END PGP SIGNATURE----- diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -1011,6 +1011,10 @@ class localrepository: (c, a, d, u) = self.diffdir(self.root) + # is this a jump, or a merge? i.e. is there a linear path + # from p1 to p2? + linear_path = (pa == p1 or pa == p2) + # resolve the manifest to determine which files # we care about merging self.ui.note("resolving manifests\n") @@ -1031,6 +1035,14 @@ class localrepository: for f in d: if f in mw: del mw[f] + # If we're jumping between revisions (as opposed to merging), + # and if neither the working directory nor the target rev has + # the file, then we need to remove it from the dirstate, to + # prevent the dirstate from listing the file when it is no + # longer in the manifest. + if linear_path and f not in m2: + self.dirstate.forget((f,)) + for f, n in mw.iteritems(): if f in m2: s = 0 @@ -1117,7 +1129,7 @@ class localrepository: get[f] = merge[f][1] merge = {} - if pa == p1 or pa == p2: + if linear_path: # we don't need to do any magic, just jump to the new rev mode = 'n' p1, p2 = p2, nullid