Mercurial > public > mercurial-scm > hg
comparison mercurial/hg.py @ 616:d45d1c90032e
Fix zombie files in merge
# HG changeset patch
# User maf46@burn.cl.cam.ac.uk
# Node ID 57667c9b93a5a743e4629d15a0e6bd76699130c3
# Parent d2994b5298fb20f87dc1d4747635b280db3c0526
Fix zombie files in merge
Keir Fraser observed the following:
> I made a small test case that illustrates the bug in merging changesets
> with 'hg remove's in them:
>
> 1. Create a repository A containing files foo & bar.
> 2. Create clone called B.
> 3. A removes file bar, and commits this removal.
> 4. B edits file foo, and commits this edit.
>
> Now, if B:
> # hg pull ../A; hg update -m; hg commit
> Then bar remains deleted.
>
> If A:
> # hg pull ../B; hg update -m; hg commit
> Then bar is resurrected!
>
> It looks as though, when you merge across a branch, any deletions in
> your own branch are forgotten.
> ...
> Fixing this is a must, as zombie files are a real pain. :-)
Keir later patched our local copy of hg as shown below, which fixes
the problem. I've also enclosed a test which captures the test Keir
outlined...
Files deleted on a branch should not automatically reappear in a merge
Patch notes:
1. The first chunk does not change behaviour, but cleans up the code
to more closely match check of 'force' in the second chunk. I
think it makes the code clearer.
2. The second chunk fixes two bugs --
i. If we choose to keep a remotely-changed locally-deleted file,
then we need to 'get' that file. If we choose to delete it
then no action need be taken (it is already deleted in the
working manifest). Without this fix, choosing to delete would
get a Python traceback.
ii. The test for whether the file was remotely-created is
insufficient. It is only true if f is not in the common
ancestor. Otherwise the file was deleted locally, and should
remain deleted. (this is the most important fix!)
Index: hg/tests/test-merge6
===================================================================
author | maf46@burn.cl.cam.ac.uk |
---|---|
date | Mon, 04 Jul 2005 12:38:34 -0800 |
parents | 48c3eb2bf844 |
children | 004e811f7706 |
comparison
equal
deleted
inserted
replaced
615:ad2999fad721 | 616:d45d1c90032e |
---|---|
1177 self.ui.debug(" updating permissions for %s\n" % f) | 1177 self.ui.debug(" updating permissions for %s\n" % f) |
1178 util.set_exec(self.wjoin(f), mode) | 1178 util.set_exec(self.wjoin(f), mode) |
1179 mark[f] = 1 | 1179 mark[f] = 1 |
1180 del m2[f] | 1180 del m2[f] |
1181 elif f in ma: | 1181 elif f in ma: |
1182 if not force and n != ma[f]: | 1182 if n != ma[f]: |
1183 r = "" | 1183 r = "d" |
1184 if linear_path or allow: | 1184 if not force and (linear_path or allow): |
1185 r = self.ui.prompt( | 1185 r = self.ui.prompt( |
1186 (" local changed %s which remote deleted\n" % f) + | 1186 (" local changed %s which remote deleted\n" % f) + |
1187 "(k)eep or (d)elete?", "[kd]", "k") | 1187 "(k)eep or (d)elete?", "[kd]", "k") |
1188 if r == "d": | 1188 if r == "d": |
1189 remove.append(f) | 1189 remove.append(f) |
1201 self.ui.debug("working dir created %s, keeping\n" % f) | 1201 self.ui.debug("working dir created %s, keeping\n" % f) |
1202 | 1202 |
1203 for f, n in m2.iteritems(): | 1203 for f, n in m2.iteritems(): |
1204 if choose and not choose(f): continue | 1204 if choose and not choose(f): continue |
1205 if f[0] == "/": continue | 1205 if f[0] == "/": continue |
1206 if not force and f in ma and n != ma[f]: | 1206 if f in ma and n != ma[f]: |
1207 r = "" | 1207 r = "k" |
1208 if linear_path or allow: | 1208 if not force and (linear_path or allow): |
1209 r = self.ui.prompt( | 1209 r = self.ui.prompt( |
1210 ("remote changed %s which local deleted\n" % f) + | 1210 ("remote changed %s which local deleted\n" % f) + |
1211 "(k)eep or (d)elete?", "[kd]", "k") | 1211 "(k)eep or (d)elete?", "[kd]", "k") |
1212 if r == "d": remove.append(f) | 1212 if r == "k": get[f] = n |
1213 else: | 1213 elif f not in ma: |
1214 self.ui.debug("remote created %s\n" % f) | 1214 self.ui.debug("remote created %s\n" % f) |
1215 get[f] = n | 1215 get[f] = n |
1216 else: | |
1217 self.ui.debug("local deleted %s\n" % f) | |
1216 | 1218 |
1217 del mw, m1, m2, ma | 1219 del mw, m1, m2, ma |
1218 | 1220 |
1219 if force: | 1221 if force: |
1220 for f in merge: | 1222 for f in merge: |