# HG changeset patch # User Matt Mackall # Date 1206812387 18000 # Node ID d8f44384c3ee2e5d72249b657e24ad1cd1deace6 # Parent fb374b1b3911ce5d5861592142271bb230635ea0 copies: sort old names by depth diff -r fb374b1b3911 -r d8f44384c3ee mercurial/copies.py --- a/mercurial/copies.py Sat Mar 29 12:39:47 2008 -0500 +++ b/mercurial/copies.py Sat Mar 29 12:39:47 2008 -0500 @@ -35,22 +35,23 @@ 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 -r fb374b1b3911 -r d8f44384c3ee tests/test-diff-copy-depth --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-diff-copy-depth Sat Mar 29 12:39:47 2008 -0500 @@ -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 -r fb374b1b3911 -r d8f44384c3ee tests/test-diff-copy-depth.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-diff-copy-depth.out Sat Mar 29 12:39:47 2008 -0500 @@ -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 +