diff --git a/mercurial/copies.py b/mercurial/copies.py --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -35,22 +35,23 @@ def _findoldnames(fctx, limit): old = {} seen = {} orig = fctx.path() - visit = [fctx] + visit = [(fctx, 0)] while visit: - fc = visit.pop() + fc, depth = visit.pop() s = str(fc) if s in seen: continue seen[s] = 1 if fc.path() != orig and fc.path() not in old: - old[fc.path()] = 1 + old[fc.path()] = (depth, fc.path()) # remember depth if fc.rev() < limit and fc.rev() is not None: continue - visit += fc.parents() + visit += [(p, depth - 1) for p in fc.parents()] - old = old.keys() + # return old names sorted by depth + old = old.values() old.sort() - return old + return [o[1] for o in old] def copies(repo, c1, c2, ca): """ diff --git a/tests/test-diff-copy-depth b/tests/test-diff-copy-depth new file mode 100644 --- /dev/null +++ b/tests/test-diff-copy-depth @@ -0,0 +1,31 @@ +#!/bin/bash + +for i in aaa zzz; do + hg init t + cd t + + echo "-- With $i" + + touch file + hg add file + hg ci -m "Add" + + hg cp file $i + hg ci -m "a -> $i" + + hg cp $i other-file + echo "different" >> $i + hg ci -m "$i -> other-file" + + hg cp other-file somename + + echo "Status": + hg st -C + echo + echo "Diff:" + hg diff -g + echo + + cd .. + rm -rf t +done diff --git a/tests/test-diff-copy-depth.out b/tests/test-diff-copy-depth.out new file mode 100644 --- /dev/null +++ b/tests/test-diff-copy-depth.out @@ -0,0 +1,20 @@ +-- With aaa +Status: +A somename + other-file + +Diff: +diff --git a/other-file b/somename +copy from other-file +copy to somename + +-- With zzz +Status: +A somename + other-file + +Diff: +diff --git a/other-file b/somename +copy from other-file +copy to somename +