Mercurial > public > mercurial-scm > hg
diff mercurial/mdiff.py @ 7200:ca5ac40949dc
patch/diff: use a separate function to write the first line of a file diff
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Wed, 22 Oct 2008 13:14:52 +0200 |
parents | 13fe85fe396b |
children | ad28279053ef |
line wrap: on
line diff
--- 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)