# HG changeset patch # User Martin von Zweigbergk # Date 2014-11-25 00:42:36 # Node ID c7c95838be9adc11a2697d71ea011347adc0212e # Parent 6a254a2dd37ca786e5074c2940bff7d71c0f164f merge: break out "both renamed a -> b" case We can further limit the scope of the 2-way merge case by breaking out the case where the file was not created from scratch on both sides but rather renamed in the same way (and is therefore a 3-way merge). This involves copying some code, but it makes it clearer which case the "Note:" in the code refers to. diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -416,11 +416,15 @@ def manifestmerge(repo, wctx, p2, pa, br continue if n1 and n2: if f not in ma: - # Note: f as ancestor is wrong - we can't really make a 3-way - # merge without an ancestor file. - fa = copy.get(f, f) - actions['m'].append((f, (f, f, fa, False, pa.node()), - "both created")) + fa = copy.get(f, None) + if fa is not None: + actions['m'].append((f, (f, f, fa, False, pa.node()), + "both renamed from " + fa)) + else: + # Note: f as ancestor is wrong - we can't really make a + # 3-way merge without an ancestor file. + actions['m'].append((f, (f, f, f, False, pa.node()), + "both created")) else: a = ma[f] fla = ma.flags(f) diff --git a/tests/test-rename-merge2.t b/tests/test-rename-merge2.t --- a/tests/test-rename-merge2.t +++ b/tests/test-rename-merge2.t @@ -343,7 +343,7 @@ args: ancestor: 924404dff337, local: 62e7bf090eba+, remote: 49b6d8032493 preserving b for resolve of b preserving rev for resolve of rev - b: both created -> m + b: both renamed from a -> m updating: b 1/2 files (50.00%) picked tool 'python ../merge' for b (binary False symlink False) merging b