--- a/mercurial/mdiff.py Wed Oct 22 12:56:28 2008 +0200
+++ b/mercurial/mdiff.py Wed Oct 22 13:14:52 2008 +0200
@@ -66,6 +66,19 @@
text = re.sub('\n+', '', text)
return text
+def diffline(revs, a, b, opts):
+ parts = ['diff']
+ if opts.git:
+ parts.append('--git')
+ if revs and not opts.git:
+ parts.append(' '.join(["-r %s" % rev for rev in revs]))
+ if opts.git:
+ parts.append('a/%s' % a)
+ parts.append('b/%s' % b)
+ else:
+ parts.append(a)
+ return ' '.join(parts) + '\n'
+
def unidiff(a, ad, b, bd, fn1, fn2, r=None, opts=defaultopts):
def datetag(date, addtab=True):
if not opts.git and not opts.nodates:
@@ -113,8 +126,7 @@
l[ln] += "\n\ No newline at end of file\n"
if r:
- l.insert(0, "diff %s %s\n" %
- (' '.join(["-r %s" % rev for rev in r]), fn1))
+ l.insert(0, diffline(r, fn1, fn2, opts))
return "".join(l)
--- a/mercurial/patch.py Wed Oct 22 12:56:28 2008 +0200
+++ b/mercurial/patch.py Wed Oct 22 13:14:52 2008 +0200
@@ -1266,7 +1266,7 @@
if util.binary(to) or util.binary(tn):
dodiff = 'binary'
r = None
- header.insert(0, 'diff --git a/%s b/%s\n' % (a, b))
+ header.insert(0, mdiff.diffline(r, a, b, opts))
if dodiff:
if dodiff == 'binary':
text = b85diff(to, tn)