##// END OF EJS Templates
copies: sort old names by depth
Matt Mackall -
r6424:d8f44384 default
parent child Browse files
Show More
@@ -0,0 +1,31 b''
1 #!/bin/bash
2
3 for i in aaa zzz; do
4 hg init t
5 cd t
6
7 echo "-- With $i"
8
9 touch file
10 hg add file
11 hg ci -m "Add"
12
13 hg cp file $i
14 hg ci -m "a -> $i"
15
16 hg cp $i other-file
17 echo "different" >> $i
18 hg ci -m "$i -> other-file"
19
20 hg cp other-file somename
21
22 echo "Status":
23 hg st -C
24 echo
25 echo "Diff:"
26 hg diff -g
27 echo
28
29 cd ..
30 rm -rf t
31 done
@@ -0,0 +1,20 b''
1 -- With aaa
2 Status:
3 A somename
4 other-file
5
6 Diff:
7 diff --git a/other-file b/somename
8 copy from other-file
9 copy to somename
10
11 -- With zzz
12 Status:
13 A somename
14 other-file
15
16 Diff:
17 diff --git a/other-file b/somename
18 copy from other-file
19 copy to somename
20
@@ -35,22 +35,23 b' def _findoldnames(fctx, limit):'
35 old = {}
35 old = {}
36 seen = {}
36 seen = {}
37 orig = fctx.path()
37 orig = fctx.path()
38 visit = [fctx]
38 visit = [(fctx, 0)]
39 while visit:
39 while visit:
40 fc = visit.pop()
40 fc, depth = visit.pop()
41 s = str(fc)
41 s = str(fc)
42 if s in seen:
42 if s in seen:
43 continue
43 continue
44 seen[s] = 1
44 seen[s] = 1
45 if fc.path() != orig and fc.path() not in old:
45 if fc.path() != orig and fc.path() not in old:
46 old[fc.path()] = 1
46 old[fc.path()] = (depth, fc.path()) # remember depth
47 if fc.rev() < limit and fc.rev() is not None:
47 if fc.rev() < limit and fc.rev() is not None:
48 continue
48 continue
49 visit += fc.parents()
49 visit += [(p, depth - 1) for p in fc.parents()]
50
50
51 old = old.keys()
51 # return old names sorted by depth
52 old = old.values()
52 old.sort()
53 old.sort()
53 return old
54 return [o[1] for o in old]
54
55
55 def copies(repo, c1, c2, ca):
56 def copies(repo, c1, c2, ca):
56 """
57 """
General Comments 0
You need to be logged in to leave comments. Login now