##// END OF EJS Templates
Attempt to make diff deal with null sources properly...
mpm@selenic.com -
r264:4c1d7072 default
parent child Browse files
Show More
@@ -61,12 +61,12 b' def dodiff(repo, files = None, node1 = N'
61 tn = read(f)
61 tn = read(f)
62 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f))
62 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f))
63 for f in a:
63 for f in a:
64 to = ""
64 to = None
65 tn = read(f)
65 tn = read(f)
66 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f))
66 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f))
67 for f in d:
67 for f in d:
68 to = repo.file(f).read(mmap[f])
68 to = repo.file(f).read(mmap[f])
69 tn = ""
69 tn = None
70 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f))
70 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f))
71
71
72 def help(ui, cmd=None):
72 def help(ui, cmd=None):
@@ -10,9 +10,23 b' from mercurial.mpatch import *'
10
10
11 def unidiff(a, ad, b, bd, fn):
11 def unidiff(a, ad, b, bd, fn):
12 if not a and not b: return ""
12 if not a and not b: return ""
13 a = a.splitlines(1)
13
14 b = b.splitlines(1)
14 if a == None:
15 l = list(difflib.unified_diff(a, b, "a/" + fn, "b/" + fn, ad, bd))
15 b = b.splitlines(1)
16 l1 = "--- %s\t%s\n" % ("/dev/null", ad)
17 l2 = "+++ %s\t%s\n" % ("b/" + fn, bd)
18 l3 = "@@ -0,0 +1,%d @@\n" % len(b)
19 l = [l1, l2, l3] + ["+" + e for e in b]
20 elif b == None:
21 a = a.splitlines(1)
22 l1 = "--- %s\t%s\n" % ("a/" + fn, ad)
23 l2 = "+++ %s\t%s\n" % ("/dev/null", bd)
24 l3 = "@@ -1,%d +0,0 @@\n" % len(a)
25 l = [l1, l2, l3] + ["-" + e for e in a]
26 else:
27 a = a.splitlines(1)
28 b = b.splitlines(1)
29 l = list(difflib.unified_diff(a, b, "a/" + fn, "b/" + fn, ad, bd))
16
30
17 for ln in xrange(len(l)):
31 for ln in xrange(len(l)):
18 if l[ln][-1] != '\n':
32 if l[ln][-1] != '\n':
General Comments 0
You need to be logged in to leave comments. Login now