comparison mercurial/mdiff.py @ 396:8f8bb77d560e

Show revisions in diffs like CVS, based on a patch from Goffredo Baroncelli. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Show revisions in diffs like CVS, based on a patch from Goffredo Baroncelli. Changes from the original patch: - - Use 'diff -r ...' instead of 'hg diff -r ...' to support filetype detection by at least file(1) and vim. - - Adjusted tests for this change. - - Some cleanups. manifest hash: 5f37d1ef75ea7f4e48b53f02371053ba54fb70f8 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCsyZzW7P1GVgWeRoRAqczAJ479lR9Z289sP+VH5L+N7pQRU14SACfUueq 88ABloIR3VyRIa4qbujnZio= =Vva9 -----END PGP SIGNATURE-----
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 17 Jun 2005 20:37:23 +0100
parents 88268aa2b8d2
children 3b9e3d3d2810
comparison
equal deleted inserted replaced
395:fbe8834923c5 396:8f8bb77d560e
6 # of the GNU General Public License, incorporated herein by reference. 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 import difflib, struct 8 import difflib, struct
9 from mercurial.mpatch import * 9 from mercurial.mpatch import *
10 10
11 def unidiff(a, ad, b, bd, fn): 11 def unidiff(a, ad, b, bd, fn, r=None):
12
12 if not a and not b: return "" 13 if not a and not b: return ""
13 14
14 if a == None: 15 if a == None:
15 b = b.splitlines(1) 16 b = b.splitlines(1)
16 l1 = "--- %s\t%s\n" % ("/dev/null", ad) 17 l1 = "--- %s\t%s\n" % ("/dev/null", ad)
33 l[1] = l[1][:-2] + "\t" + bd + "\n" 34 l[1] = l[1][:-2] + "\t" + bd + "\n"
34 35
35 for ln in xrange(len(l)): 36 for ln in xrange(len(l)):
36 if l[ln][-1] != '\n': 37 if l[ln][-1] != '\n':
37 l[ln] += "\n\ No newline at end of file\n" 38 l[ln] += "\n\ No newline at end of file\n"
39
40 if r:
41 l.insert(0, "diff %s %s\n" %
42 (' '.join(["-r %s" % rev for rev in r]), fn))
38 43
39 return "".join(l) 44 return "".join(l)
40 45
41 def textdiff(a, b): 46 def textdiff(a, b):
42 return diff(a.splitlines(1), b.splitlines(1)) 47 return diff(a.splitlines(1), b.splitlines(1))