diff --git a/mercurial/copies.py b/mercurial/copies.py --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -564,9 +564,8 @@ def _checkcopies(ctx, f, m1, m2, base, t # traversed backwards. # # In the case there is both backward and forward renames (before and after - # the base) this is more complicated as we must detect a divergence. This - # is currently broken and hopefully some later code update will make that - # work (we use 'backwards = False' in that case) + # the base) this is more complicated as we must detect a divergence. + # We use 'backwards = False' in that case. backwards = base != tca and f in mb getfctx = _makegetfctx(ctx) @@ -600,6 +599,12 @@ def _checkcopies(ctx, f, m1, m2, base, t data['copy'][of] = f elif of in mb: data['copy'][f] = of + else: # divergence w.r.t. graft CA on one side of topological CA + for sf in seen: + if sf in mb: + assert sf not in data['diverge'] + data['diverge'][sf] = [f, of] + break return if of in mb: diff --git a/tests/test-graft.t b/tests/test-graft.t --- a/tests/test-graft.t +++ b/tests/test-graft.t @@ -982,6 +982,9 @@ Test the cases A.0 (f4x) and A.6 (f3x) $ HGEDITOR="echo D1 >" hg graft -r 'desc("D0")' --edit grafting 3:b69f5839d2d9 "D0" + note: possible conflict - f3b was renamed multiple times to: + f3d + f3a warning: can't find ancestor for 'f3d' copied from 'f3b'! Set up the repository for some further tests