Show More
@@ -1161,9 +1161,10 b' def diff(repo, node1=None, node2=None, f' | |||
|
1161 | 1161 | # returns False if there was no rename between ctx1 and ctx2 |
|
1162 | 1162 | # returns None if the file was created between ctx1 and ctx2 |
|
1163 | 1163 | # returns the (file, node) present in ctx1 that was renamed to f in ctx2 |
|
1164 | def renamed(f): | |
|
1165 | startrev = ctx1.rev() | |
|
1166 | c = ctx2 | |
|
1164 | # This will only really work if c1 is the Nth 1st parent of c2. | |
|
1165 | def renamed(c1, c2, man, f): | |
|
1166 | startrev = c1.rev() | |
|
1167 | c = c2 | |
|
1167 | 1168 | crev = c.rev() |
|
1168 | 1169 | if crev is None: |
|
1169 | 1170 | crev = repo.changelog.count() |
@@ -1179,7 +1180,7 b' def diff(repo, node1=None, node2=None, f' | |||
|
1179 | 1180 | crev = c.parents()[0].rev() |
|
1180 | 1181 | # try to reuse |
|
1181 | 1182 | c = getctx(crev) |
|
1182 |
if f not in man |
|
|
1183 | if f not in man: | |
|
1183 | 1184 | return None |
|
1184 | 1185 | if f == orig: |
|
1185 | 1186 | return False |
@@ -1193,11 +1194,27 b' def diff(repo, node1=None, node2=None, f' | |||
|
1193 | 1194 | |
|
1194 | 1195 | if opts.git: |
|
1195 | 1196 | copied = {} |
|
1196 | for f in added: | |
|
1197 |
|
|
|
1197 | c1, c2 = ctx1, ctx2 | |
|
1198 | files = added | |
|
1199 | man = man1 | |
|
1200 | if node2 and ctx1.rev() >= ctx2.rev(): | |
|
1201 | # renamed() starts at c2 and walks back in history until c1. | |
|
1202 | # Since ctx1.rev() >= ctx2.rev(), invert ctx2 and ctx1 to | |
|
1203 | # detect (inverted) copies. | |
|
1204 | c1, c2 = ctx2, ctx1 | |
|
1205 | files = removed | |
|
1206 | man = ctx2.manifest() | |
|
1207 | for f in files: | |
|
1208 | src = renamed(c1, c2, man, f) | |
|
1198 | 1209 | if src: |
|
1199 | 1210 | copied[f] = src |
|
1200 | srcs = [x[1] for x in copied.items()] | |
|
1211 | if ctx1 == c2: | |
|
1212 | # invert the copied dict | |
|
1213 | copied = dict([(v, k) for (k, v) in copied.iteritems()]) | |
|
1214 | # If we've renamed file foo to bar (copied['bar'] = 'foo'), | |
|
1215 | # avoid showing a diff for foo if we're going to show | |
|
1216 | # the rename to bar. | |
|
1217 | srcs = [x[1] for x in copied.iteritems() if x[0] in added] | |
|
1201 | 1218 | |
|
1202 | 1219 | all = modified + added + removed |
|
1203 | 1220 | all.sort() |
@@ -78,6 +78,8 b' hg mv dst2 dst3' | |||
|
78 | 78 | hg ci -m 'mv dst2 dst3; revert start' -d '0 0' |
|
79 | 79 | |
|
80 | 80 | hg diff --git -r 9:11 |
|
81 | echo '% reversed' | |
|
82 | hg diff --git -r 11:9 | |
|
81 | 83 | |
|
82 | 84 | echo a >> foo |
|
83 | 85 | hg add foo |
@@ -92,12 +94,18 b" hg ci -m 'change bar'" | |||
|
92 | 94 | echo |
|
93 | 95 | echo '% file created before r1 and renamed before r2' |
|
94 | 96 | hg diff --git -r -3:-1 |
|
97 | echo '% reversed' | |
|
98 | hg diff --git -r -1:-3 | |
|
95 | 99 | echo |
|
96 | 100 | echo '% file created in r1 and renamed before r2' |
|
97 | 101 | hg diff --git -r -4:-1 |
|
102 | echo '% reversed' | |
|
103 | hg diff --git -r -1:-4 | |
|
98 | 104 | echo |
|
99 | 105 | echo '% file created after r1 and renamed before r2' |
|
100 | 106 | hg diff --git -r -5:-1 |
|
107 | echo '% reversed' | |
|
108 | hg diff --git -r -1:-5 | |
|
101 | 109 | |
|
102 | 110 | echo |
|
103 | 111 | echo '% comparing with the working dir' |
@@ -139,6 +147,8 b' hg cp brand-new2 brand-new3' | |||
|
139 | 147 | hg mv brand-new2 brand-new3-2 |
|
140 | 148 | hg ci -m 'multiple renames/copies' |
|
141 | 149 | hg diff --git -r -2 -r -1 |
|
150 | echo '% reversed' | |
|
151 | hg diff --git -r -1 -r -2 | |
|
142 | 152 | |
|
143 | 153 | echo '% there should be a trailing TAB if there are spaces in the file name' |
|
144 | 154 | echo foo > 'with spaces' |
@@ -75,6 +75,10 b' rename to renamed.bin' | |||
|
75 | 75 | diff --git a/dst2 b/dst3 |
|
76 | 76 | rename from dst2 |
|
77 | 77 | rename to dst3 |
|
78 | % reversed | |
|
79 | diff --git a/dst3 b/dst2 | |
|
80 | rename from dst3 | |
|
81 | rename to dst2 | |
|
78 | 82 | |
|
79 | 83 | % file created before r1 and renamed before r2 |
|
80 | 84 | diff --git a/foo b/bar |
@@ -86,6 +90,16 b' rename to bar' | |||
|
86 | 90 | a |
|
87 | 91 | b |
|
88 | 92 | +c |
|
93 | % reversed | |
|
94 | diff --git a/bar b/foo | |
|
95 | rename from bar | |
|
96 | rename to foo | |
|
97 | --- a/foo | |
|
98 | +++ b/foo | |
|
99 | @@ -1,3 +1,2 @@ a | |
|
100 | a | |
|
101 | b | |
|
102 | -c | |
|
89 | 103 | |
|
90 | 104 | % file created in r1 and renamed before r2 |
|
91 | 105 | diff --git a/foo b/bar |
@@ -97,6 +111,16 b' rename to bar' | |||
|
97 | 111 | a |
|
98 | 112 | +b |
|
99 | 113 | +c |
|
114 | % reversed | |
|
115 | diff --git a/bar b/foo | |
|
116 | rename from bar | |
|
117 | rename to foo | |
|
118 | --- a/foo | |
|
119 | +++ b/foo | |
|
120 | @@ -1,3 +1,1 @@ a | |
|
121 | a | |
|
122 | -b | |
|
123 | -c | |
|
100 | 124 | |
|
101 | 125 | % file created after r1 and renamed before r2 |
|
102 | 126 | diff --git a/bar b/bar |
@@ -107,6 +131,15 b' new file mode 100644' | |||
|
107 | 131 | +a |
|
108 | 132 | +b |
|
109 | 133 | +c |
|
134 | % reversed | |
|
135 | diff --git a/bar b/bar | |
|
136 | deleted file mode 100644 | |
|
137 | --- a/bar | |
|
138 | +++ /dev/null | |
|
139 | @@ -1,3 +0,0 @@ | |
|
140 | -a | |
|
141 | -b | |
|
142 | -c | |
|
110 | 143 | |
|
111 | 144 | % comparing with the working dir |
|
112 | 145 | % there's a copy in the working dir... |
@@ -145,6 +178,16 b' rename to brand-new3' | |||
|
145 | 178 | diff --git a/brand-new2 b/brand-new3-2 |
|
146 | 179 | copy from brand-new2 |
|
147 | 180 | copy to brand-new3-2 |
|
181 | % reversed | |
|
182 | diff --git a/brand-new3 b/brand-new2 | |
|
183 | rename from brand-new3 | |
|
184 | rename to brand-new2 | |
|
185 | diff --git a/brand-new3-2 b/brand-new3-2 | |
|
186 | deleted file mode 100644 | |
|
187 | --- a/brand-new3-2 | |
|
188 | +++ /dev/null | |
|
189 | @@ -1,1 +0,0 @@ | |
|
190 | - | |
|
148 | 191 | % there should be a trailing TAB if there are spaces in the file name |
|
149 | 192 | diff --git a/with spaces b/with spaces |
|
150 | 193 | new file mode 100644 |
General Comments 0
You need to be logged in to leave comments.
Login now