Show More
@@ -156,10 +156,10 b' def diffline(revs, a, b, opts):' | |||||
156 | return ' '.join(parts) + '\n' |
|
156 | return ' '.join(parts) + '\n' | |
157 |
|
157 | |||
158 | def unidiff(a, ad, b, bd, fn1, fn2, r=None, opts=defaultopts): |
|
158 | def unidiff(a, ad, b, bd, fn1, fn2, r=None, opts=defaultopts): | |
159 |
def datetag(date, |
|
159 | def datetag(date, fn=None): | |
160 | if not opts.git and not opts.nodates: |
|
160 | if not opts.git and not opts.nodates: | |
161 | return '\t%s\n' % date |
|
161 | return '\t%s\n' % date | |
162 |
if |
|
162 | if fn and ' ' in fn: | |
163 | return '\t\n' |
|
163 | return '\t\n' | |
164 | return '\n' |
|
164 | return '\n' | |
165 |
|
165 | |||
@@ -177,19 +177,19 b' def unidiff(a, ad, b, bd, fn1, fn2, r=No' | |||||
177 | elif not a: |
|
177 | elif not a: | |
178 | b = splitnewlines(b) |
|
178 | b = splitnewlines(b) | |
179 | if a is None: |
|
179 | if a is None: | |
180 |
l1 = '--- /dev/null%s' % datetag(epoch |
|
180 | l1 = '--- /dev/null%s' % datetag(epoch) | |
181 | else: |
|
181 | else: | |
182 | l1 = "--- %s%s" % ("a/" + fn1, datetag(ad)) |
|
182 | l1 = "--- %s%s" % ("a/" + fn1, datetag(ad, fn1)) | |
183 | l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd)) |
|
183 | l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd, fn2)) | |
184 | l3 = "@@ -0,0 +1,%d @@\n" % len(b) |
|
184 | l3 = "@@ -0,0 +1,%d @@\n" % len(b) | |
185 | l = [l1, l2, l3] + ["+" + e for e in b] |
|
185 | l = [l1, l2, l3] + ["+" + e for e in b] | |
186 | elif not b: |
|
186 | elif not b: | |
187 | a = splitnewlines(a) |
|
187 | a = splitnewlines(a) | |
188 | l1 = "--- %s%s" % ("a/" + fn1, datetag(ad)) |
|
188 | l1 = "--- %s%s" % ("a/" + fn1, datetag(ad, fn1)) | |
189 | if b is None: |
|
189 | if b is None: | |
190 |
l2 = '+++ /dev/null%s' % datetag(epoch |
|
190 | l2 = '+++ /dev/null%s' % datetag(epoch) | |
191 | else: |
|
191 | else: | |
192 | l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd)) |
|
192 | l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd, fn2)) | |
193 | l3 = "@@ -1,%d +0,0 @@\n" % len(a) |
|
193 | l3 = "@@ -1,%d +0,0 @@\n" % len(a) | |
194 | l = [l1, l2, l3] + ["-" + e for e in a] |
|
194 | l = [l1, l2, l3] + ["-" + e for e in a] | |
195 | else: |
|
195 | else: | |
@@ -199,8 +199,8 b' def unidiff(a, ad, b, bd, fn1, fn2, r=No' | |||||
199 | if not l: |
|
199 | if not l: | |
200 | return "" |
|
200 | return "" | |
201 |
|
201 | |||
202 | l.insert(0, "--- a/%s%s" % (fn1, datetag(ad))) |
|
202 | l.insert(0, "--- a/%s%s" % (fn1, datetag(ad, fn1))) | |
203 | l.insert(1, "+++ b/%s%s" % (fn2, datetag(bd))) |
|
203 | l.insert(1, "+++ b/%s%s" % (fn2, datetag(bd, fn2))) | |
204 |
|
204 | |||
205 | for ln in xrange(len(l)): |
|
205 | for ln in xrange(len(l)): | |
206 | if l[ln][-1] != '\n': |
|
206 | if l[ln][-1] != '\n': |
@@ -140,3 +140,54 b' 0 lines of context hunk header matches g' | |||||
140 | +c3 |
|
140 | +c3 | |
141 | @@ -3,1 +4,0 @@ c4 |
|
141 | @@ -3,1 +4,0 @@ c4 | |
142 | -c5 |
|
142 | -c5 | |
|
143 | ||||
|
144 | $ echo a > f1 | |||
|
145 | $ hg ci -m movef2 | |||
|
146 | ||||
|
147 | Test diff headers terminating with TAB when necessary (issue3357) | |||
|
148 | Regular diff --nodates, file creation | |||
|
149 | ||||
|
150 | $ hg mv f1 'f 1' | |||
|
151 | $ echo b > 'f 1' | |||
|
152 | $ hg diff --nodates 'f 1' | |||
|
153 | diff -r 7574207d0d15 f 1 | |||
|
154 | --- /dev/null | |||
|
155 | +++ b/f 1 | |||
|
156 | @@ -0,0 +1,1 @@ | |||
|
157 | +b | |||
|
158 | ||||
|
159 | Git diff, adding space | |||
|
160 | ||||
|
161 | $ hg diff --git | |||
|
162 | diff --git a/f1 b/f 1 | |||
|
163 | rename from f1 | |||
|
164 | rename to f 1 | |||
|
165 | --- a/f1 | |||
|
166 | +++ b/f 1 | |||
|
167 | @@ -1,1 +1,1 @@ | |||
|
168 | -a | |||
|
169 | +b | |||
|
170 | ||||
|
171 | Regular diff --nodates, file deletion | |||
|
172 | ||||
|
173 | $ hg ci -m addspace | |||
|
174 | $ hg mv 'f 1' f1 | |||
|
175 | $ echo a > f1 | |||
|
176 | $ hg diff --nodates 'f 1' | |||
|
177 | diff -r ca50fe67c9c7 f 1 | |||
|
178 | --- a/f 1 | |||
|
179 | +++ /dev/null | |||
|
180 | @@ -1,1 +0,0 @@ | |||
|
181 | -b | |||
|
182 | ||||
|
183 | Git diff, removing space | |||
|
184 | ||||
|
185 | $ hg diff --git | |||
|
186 | diff --git a/f 1 b/f1 | |||
|
187 | rename from f 1 | |||
|
188 | rename to f1 | |||
|
189 | --- a/f 1 | |||
|
190 | +++ b/f1 | |||
|
191 | @@ -1,1 +1,1 @@ | |||
|
192 | -b | |||
|
193 | +a |
General Comments 0
You need to be logged in to leave comments.
Login now