Mercurial > hg-stable
changeset 408:3695fbd2c33b
[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 <Michael.Fetterman@cl.cam.ac.uk>
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-----
author | mpm@selenic.com |
---|---|
date | Tue, 21 Jun 2005 18:48:28 -0800 |
parents | 0e0d0670b2bc |
children | feadc9697b43 |
files | mercurial/hg.py |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hg.py Tue Jun 21 18:41:57 2005 -0800 +++ b/mercurial/hg.py Tue Jun 21 18:48:28 2005 -0800 @@ -1011,6 +1011,10 @@ (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 @@ 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 @@ 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