Show More
@@ -156,6 +156,13 b' def unidiff(a, ad, b, bd, fn1, fn2, opts' | |||||
156 |
|
156 | |||
157 | if not a and not b: |
|
157 | if not a and not b: | |
158 | return "" |
|
158 | return "" | |
|
159 | ||||
|
160 | if opts.noprefix: | |||
|
161 | aprefix = bprefix = '' | |||
|
162 | else: | |||
|
163 | aprefix = 'a/' | |||
|
164 | bprefix = 'b/' | |||
|
165 | ||||
159 | epoch = util.datestr((0, 0)) |
|
166 | epoch = util.datestr((0, 0)) | |
160 |
|
167 | |||
161 | fn1 = util.pconvert(fn1) |
|
168 | fn1 = util.pconvert(fn1) | |
@@ -170,17 +177,17 b' def unidiff(a, ad, b, bd, fn1, fn2, opts' | |||||
170 | if a is None: |
|
177 | if a is None: | |
171 | l1 = '--- /dev/null%s' % datetag(epoch) |
|
178 | l1 = '--- /dev/null%s' % datetag(epoch) | |
172 | else: |
|
179 | else: | |
173 |
l1 = "--- %s%s" % ( |
|
180 | l1 = "--- %s%s%s" % (aprefix, fn1, datetag(ad, fn1)) | |
174 |
l2 = "+++ %s%s" % ( |
|
181 | l2 = "+++ %s%s" % (bprefix + fn2, datetag(bd, fn2)) | |
175 | l3 = "@@ -0,0 +1,%d @@\n" % len(b) |
|
182 | l3 = "@@ -0,0 +1,%d @@\n" % len(b) | |
176 | l = [l1, l2, l3] + ["+" + e for e in b] |
|
183 | l = [l1, l2, l3] + ["+" + e for e in b] | |
177 | elif not b: |
|
184 | elif not b: | |
178 | a = splitnewlines(a) |
|
185 | a = splitnewlines(a) | |
179 |
l1 = "--- %s%s" % ( |
|
186 | l1 = "--- %s%s%s" % (aprefix, fn1, datetag(ad, fn1)) | |
180 | if b is None: |
|
187 | if b is None: | |
181 | l2 = '+++ /dev/null%s' % datetag(epoch) |
|
188 | l2 = '+++ /dev/null%s' % datetag(epoch) | |
182 | else: |
|
189 | else: | |
183 |
l2 = "+++ %s%s" % ( |
|
190 | l2 = "+++ %s%s%s" % (bprefix, fn2, datetag(bd, fn2)) | |
184 | l3 = "@@ -1,%d +0,0 @@\n" % len(a) |
|
191 | l3 = "@@ -1,%d +0,0 @@\n" % len(a) | |
185 | l = [l1, l2, l3] + ["-" + e for e in a] |
|
192 | l = [l1, l2, l3] + ["-" + e for e in a] | |
186 | else: |
|
193 | else: | |
@@ -190,8 +197,8 b' def unidiff(a, ad, b, bd, fn1, fn2, opts' | |||||
190 | if not l: |
|
197 | if not l: | |
191 | return "" |
|
198 | return "" | |
192 |
|
199 | |||
193 |
l.insert(0, "--- |
|
200 | l.insert(0, "--- %s%s%s" % (aprefix, fn1, datetag(ad, fn1))) | |
194 |
l.insert(1, "+++ |
|
201 | l.insert(1, "+++ %s%s%s" % (bprefix, fn2, datetag(bd, fn2))) | |
195 |
|
202 | |||
196 | for ln in xrange(len(l)): |
|
203 | for ln in xrange(len(l)): | |
197 | if l[ln][-1] != '\n': |
|
204 | if l[ln][-1] != '\n': |
@@ -93,8 +93,8 b' noprefix config and option' | |||||
93 |
|
93 | |||
94 | $ hg --config diff.noprefix=True diff --nodates |
|
94 | $ hg --config diff.noprefix=True diff --nodates | |
95 | diff -r cf9f4ba66af2 a |
|
95 | diff -r cf9f4ba66af2 a | |
96 |
--- a |
|
96 | --- a | |
97 |
+++ |
|
97 | +++ a | |
98 | @@ -2,7 +2,7 @@ |
|
98 | @@ -2,7 +2,7 @@ | |
99 | c |
|
99 | c | |
100 | a |
|
100 | a | |
@@ -106,8 +106,8 b' noprefix config and option' | |||||
106 | c |
|
106 | c | |
107 | $ hg diff --noprefix --nodates |
|
107 | $ hg diff --noprefix --nodates | |
108 | diff -r cf9f4ba66af2 a |
|
108 | diff -r cf9f4ba66af2 a | |
109 |
--- a |
|
109 | --- a | |
110 |
+++ |
|
110 | +++ a | |
111 | @@ -2,7 +2,7 @@ |
|
111 | @@ -2,7 +2,7 @@ | |
112 | c |
|
112 | c | |
113 | a |
|
113 | a | |
@@ -135,8 +135,8 b' noprefix config disabled in plain mode, ' | |||||
135 | c |
|
135 | c | |
136 | $ HGPLAIN=1 hg diff --noprefix --nodates |
|
136 | $ HGPLAIN=1 hg diff --noprefix --nodates | |
137 | diff -r cf9f4ba66af2 a |
|
137 | diff -r cf9f4ba66af2 a | |
138 |
--- a |
|
138 | --- a | |
139 |
+++ |
|
139 | +++ a | |
140 | @@ -2,7 +2,7 @@ |
|
140 | @@ -2,7 +2,7 @@ | |
141 | c |
|
141 | c | |
142 | a |
|
142 | a | |
@@ -235,8 +235,8 b' Git diff with noprefix' | |||||
235 | diff --git a/f1 b/f 1 |
|
235 | diff --git a/f1 b/f 1 | |
236 | rename from f1 |
|
236 | rename from f1 | |
237 | rename to f 1 |
|
237 | rename to f 1 | |
238 |
--- |
|
238 | --- f1 | |
239 |
+++ |
|
239 | +++ f 1 | |
240 | @@ -1,1 +1,1 @@ |
|
240 | @@ -1,1 +1,1 @@ | |
241 | -a |
|
241 | -a | |
242 | +b |
|
242 | +b | |
@@ -256,8 +256,8 b' noprefix config disabled in plain mode, ' | |||||
256 | diff --git a/f1 b/f 1 |
|
256 | diff --git a/f1 b/f 1 | |
257 | rename from f1 |
|
257 | rename from f1 | |
258 | rename to f 1 |
|
258 | rename to f 1 | |
259 |
--- |
|
259 | --- f1 | |
260 |
+++ |
|
260 | +++ f 1 | |
261 | @@ -1,1 +1,1 @@ |
|
261 | @@ -1,1 +1,1 @@ | |
262 | -a |
|
262 | -a | |
263 | +b |
|
263 | +b |
General Comments 0
You need to be logged in to leave comments.
Login now