Show More
@@ -50,7 +50,9 b' def _findoldnames(fctx, limit):' | |||||
50 | return [o[1] for o in sorted(old.values())] |
|
50 | return [o[1] for o in sorted(old.values())] | |
51 |
|
51 | |||
52 | def _findlimit(repo, a, b): |
|
52 | def _findlimit(repo, a, b): | |
53 |
" |
|
53 | """Find the earliest revision that's an ancestor of a or b but not both, | |
|
54 | None if no such revision exists. | |||
|
55 | """ | |||
54 | # basic idea: |
|
56 | # basic idea: | |
55 | # - mark a and b with different sides |
|
57 | # - mark a and b with different sides | |
56 | # - if a parent's children are all on the same side, the parent is |
|
58 | # - if a parent's children are all on the same side, the parent is | |
@@ -73,6 +75,7 b' def _findlimit(repo, a, b):' | |||||
73 | visit = [-a, -b] |
|
75 | visit = [-a, -b] | |
74 | heapq.heapify(visit) |
|
76 | heapq.heapify(visit) | |
75 | interesting = len(visit) |
|
77 | interesting = len(visit) | |
|
78 | hascommonancestor = False | |||
76 | limit = working |
|
79 | limit = working | |
77 |
|
80 | |||
78 | while interesting: |
|
81 | while interesting: | |
@@ -82,6 +85,8 b' def _findlimit(repo, a, b):' | |||||
82 | else: |
|
85 | else: | |
83 | parents = cl.parentrevs(r) |
|
86 | parents = cl.parentrevs(r) | |
84 | for p in parents: |
|
87 | for p in parents: | |
|
88 | if p < 0: | |||
|
89 | continue | |||
85 | if p not in side: |
|
90 | if p not in side: | |
86 | # first time we see p; add it to visit |
|
91 | # first time we see p; add it to visit | |
87 | side[p] = side[r] |
|
92 | side[p] = side[r] | |
@@ -92,9 +97,13 b' def _findlimit(repo, a, b):' | |||||
92 | # p was interesting but now we know better |
|
97 | # p was interesting but now we know better | |
93 | side[p] = 0 |
|
98 | side[p] = 0 | |
94 | interesting -= 1 |
|
99 | interesting -= 1 | |
|
100 | hascommonancestor = True | |||
95 | if side[r]: |
|
101 | if side[r]: | |
96 | limit = r # lowest rev visited |
|
102 | limit = r # lowest rev visited | |
97 | interesting -= 1 |
|
103 | interesting -= 1 | |
|
104 | ||||
|
105 | if not hascommonancestor: | |||
|
106 | return None | |||
98 | return limit |
|
107 | return limit | |
99 |
|
108 | |||
100 | def copies(repo, c1, c2, ca, checkdirs=False): |
|
109 | def copies(repo, c1, c2, ca, checkdirs=False): | |
@@ -110,6 +119,9 b' def copies(repo, c1, c2, ca, checkdirs=F' | |||||
110 | return repo.dirstate.copies(), {} |
|
119 | return repo.dirstate.copies(), {} | |
111 |
|
120 | |||
112 | limit = _findlimit(repo, c1.rev(), c2.rev()) |
|
121 | limit = _findlimit(repo, c1.rev(), c2.rev()) | |
|
122 | if limit is None: | |||
|
123 | # no common ancestor, no copies | |||
|
124 | return {}, {} | |||
113 | m1 = c1.manifest() |
|
125 | m1 = c1.manifest() | |
114 | m2 = c2.manifest() |
|
126 | m2 = c2.manifest() | |
115 | ma = ca.manifest() |
|
127 | ma = ca.manifest() |
@@ -78,3 +78,18 b' tb "hg cp a b" "hg cp b c" "hg cp c d" "' | |||||
78 | tb "add a a1" "hg mv a b" "hg mv b a" "circular rename" |
|
78 | tb "add a a1" "hg mv a b" "hg mv b a" "circular rename" | |
79 |
|
79 | |||
80 | tb "hg mv x y" "add y/x x1" "add y/x x2" "directory move" |
|
80 | tb "hg mv x y" "add y/x x1" "add y/x x2" "directory move" | |
|
81 | ||||
|
82 | # Cannot implement unrelated branch with tb | |||
|
83 | echo '% testing copies with unrelated branch' | |||
|
84 | hg init unrelated | |||
|
85 | cd unrelated | |||
|
86 | add a a | |||
|
87 | hg ci -Am adda | |||
|
88 | hg mv a b | |||
|
89 | hg ci -m movea | |||
|
90 | hg up -C null | |||
|
91 | add a a | |||
|
92 | hg ci -Am addunrelateda | |||
|
93 | echo '% unrelated branch diff' | |||
|
94 | hg diff --git -r 2 -r 1 | |||
|
95 | cd .. |
@@ -1234,3 +1234,21 b' new file mode 100644' | |||||
1234 | +y1 |
|
1234 | +y1 | |
1235 |
|
1235 | |||
1236 |
|
1236 | |||
|
1237 | % testing copies with unrelated branch | |||
|
1238 | adding a | |||
|
1239 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
1240 | adding a | |||
|
1241 | created new head | |||
|
1242 | % unrelated branch diff | |||
|
1243 | diff --git a/a b/a | |||
|
1244 | deleted file mode 100644 | |||
|
1245 | --- a/a | |||
|
1246 | +++ /dev/null | |||
|
1247 | @@ -1,1 +0,0 @@ | |||
|
1248 | -a | |||
|
1249 | diff --git a/b b/b | |||
|
1250 | new file mode 100644 | |||
|
1251 | --- /dev/null | |||
|
1252 | +++ b/b | |||
|
1253 | @@ -0,0 +1,1 @@ | |||
|
1254 | +a |
General Comments 0
You need to be logged in to leave comments.
Login now