##// END OF EJS Templates
patch/diff: use a separate function to write the first line of a file diff
Dirkjan Ochtman -
r7200:ca5ac409 default
parent child Browse files
Show More
@@ -66,6 +66,19 b' def wsclean(opts, text):'
66 text = re.sub('\n+', '', text)
66 text = re.sub('\n+', '', text)
67 return text
67 return text
68
68
69 def diffline(revs, a, b, opts):
70 parts = ['diff']
71 if opts.git:
72 parts.append('--git')
73 if revs and not opts.git:
74 parts.append(' '.join(["-r %s" % rev for rev in revs]))
75 if opts.git:
76 parts.append('a/%s' % a)
77 parts.append('b/%s' % b)
78 else:
79 parts.append(a)
80 return ' '.join(parts) + '\n'
81
69 def unidiff(a, ad, b, bd, fn1, fn2, r=None, opts=defaultopts):
82 def unidiff(a, ad, b, bd, fn1, fn2, r=None, opts=defaultopts):
70 def datetag(date, addtab=True):
83 def datetag(date, addtab=True):
71 if not opts.git and not opts.nodates:
84 if not opts.git and not opts.nodates:
@@ -113,8 +126,7 b' def unidiff(a, ad, b, bd, fn1, fn2, r=No'
113 l[ln] += "\n\ No newline at end of file\n"
126 l[ln] += "\n\ No newline at end of file\n"
114
127
115 if r:
128 if r:
116 l.insert(0, "diff %s %s\n" %
129 l.insert(0, diffline(r, fn1, fn2, opts))
117 (' '.join(["-r %s" % rev for rev in r]), fn1))
118
130
119 return "".join(l)
131 return "".join(l)
120
132
@@ -1266,7 +1266,7 b' def diff(repo, node1=None, node2=None, m'
1266 if util.binary(to) or util.binary(tn):
1266 if util.binary(to) or util.binary(tn):
1267 dodiff = 'binary'
1267 dodiff = 'binary'
1268 r = None
1268 r = None
1269 header.insert(0, 'diff --git a/%s b/%s\n' % (a, b))
1269 header.insert(0, mdiff.diffline(r, a, b, opts))
1270 if dodiff:
1270 if dodiff:
1271 if dodiff == 'binary':
1271 if dodiff == 'binary':
1272 text = b85diff(to, tn)
1272 text = b85diff(to, tn)
General Comments 0
You need to be logged in to leave comments. Login now