# HG changeset patch # User Henrik Stuart # Date 2010-04-07 19:31:47 # Node ID 4f11978ae45d3725a809b3df3ff72cf6fd5a7efe # Parent 9606edb8777e2621311f37c9457eb2c717948b0d copies: properly visit file context ancestors on working file contexts diff --git a/mercurial/copies.py b/mercurial/copies.py --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -117,8 +117,23 @@ def copies(repo, c1, c2, ca, checkdirs=F diverge = {} def related(f1, f2, limit): + # Walk back to common ancestor to see if the two files originate + # from the same file. Since workingfilectx's rev() is None it messes + # up the integer comparison logic, hence the pre-step check for + # None (f1 and f2 can only be workingfilectx's initially). + + if f1 == f2: + return f1 # a match + g1, g2 = f1.ancestors(), f2.ancestors() try: + f1r, f2r = f1.rev(), f2.rev() + + if f1r is None: + f1 = g1.next() + if f2r is None: + f2 = g2.next() + while 1: f1r, f2r = f1.rev(), f2.rev() if f1r > f2r: diff --git a/tests/test-update-renames b/tests/test-update-renames new file mode 100755 --- /dev/null +++ b/tests/test-update-renames @@ -0,0 +1,19 @@ +#!/bin/sh + +# test update logic when there are renames + + +# update with local changes across a file rename +hg init a +cd a +echo a > a +hg add a +hg ci -m a +hg mv a b +hg ci -m rename +echo b > b +hg ci -m change +hg up -q 0 +echo c > a +hg up +cd .. diff --git a/tests/test-update-renames.out b/tests/test-update-renames.out new file mode 100644 --- /dev/null +++ b/tests/test-update-renames.out @@ -0,0 +1,5 @@ +merging a and b to b +warning: conflicts during merge. +merging b failed! +0 files updated, 0 files merged, 0 files removed, 1 files unresolved +use 'hg resolve' to retry unresolved file merges