equal
deleted
inserted
replaced
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)) |