Show More
@@ -43,7 +43,7 b' def __gather(ui, repo, node1, node2):' | |||
|
43 | 43 | to = mmap1 and repo.file(f).read(mmap1[f]) or None |
|
44 | 44 | tn = mmap2 and repo.file(f).read(mmap2[f]) or None |
|
45 | 45 | |
|
46 | diff = mdiff.unidiff(to, "", tn, "", f).split("\n") | |
|
46 | diff = mdiff.unidiff(to, "", tn, "", f, f).split("\n") | |
|
47 | 47 | |
|
48 | 48 | for line in diff: |
|
49 | 49 | if not line: |
@@ -873,7 +873,8 b' def debuginstall(ui):' | |||
|
873 | 873 | a = "1\n2\n3\n4\n" |
|
874 | 874 | b = "1\n2\n3\ninsert\n4\n" |
|
875 | 875 | fa = writetemp(a) |
|
876 |
d = mdiff.unidiff(a, None, b, None, os.path.basename(fa) |
|
|
876 | d = mdiff.unidiff(a, None, b, None, os.path.basename(fa), | |
|
877 | os.path.basename(fa)) | |
|
877 | 878 | fd = writetemp(d) |
|
878 | 879 | |
|
879 | 880 | files = {} |
@@ -59,11 +59,11 b' def wsclean(opts, text):' | |||
|
59 | 59 | text = re.sub('\n+', '', text) |
|
60 | 60 | return text |
|
61 | 61 | |
|
62 | def unidiff(a, ad, b, bd, fn, r=None, opts=defaultopts): | |
|
62 | def unidiff(a, ad, b, bd, fn1, fn2, r=None, opts=defaultopts): | |
|
63 | 63 | def datetag(date, addtab=True): |
|
64 | 64 | if not opts.git and not opts.nodates: |
|
65 | 65 | return '\t%s\n' % date |
|
66 | if addtab and ' ' in fn: | |
|
66 | if addtab and ' ' in fn1: | |
|
67 | 67 | return '\t\n' |
|
68 | 68 | return '\n' |
|
69 | 69 | |
@@ -76,29 +76,29 b' def unidiff(a, ad, b, bd, fn, r=None, op' | |||
|
76 | 76 | return md5.new(v).digest() |
|
77 | 77 | if a and b and len(a) == len(b) and h(a) == h(b): |
|
78 | 78 | return "" |
|
79 | l = ['Binary file %s has changed\n' % fn] | |
|
79 | l = ['Binary file %s has changed\n' % fn1] | |
|
80 | 80 | elif not a: |
|
81 | 81 | b = splitnewlines(b) |
|
82 | 82 | if a is None: |
|
83 | 83 | l1 = '--- /dev/null%s' % datetag(epoch, False) |
|
84 | 84 | else: |
|
85 | l1 = "--- %s%s" % ("a/" + fn, datetag(ad)) | |
|
86 | l2 = "+++ %s%s" % ("b/" + fn, datetag(bd)) | |
|
85 | l1 = "--- %s%s" % ("a/" + fn1, datetag(ad)) | |
|
86 | l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd)) | |
|
87 | 87 | l3 = "@@ -0,0 +1,%d @@\n" % len(b) |
|
88 | 88 | l = [l1, l2, l3] + ["+" + e for e in b] |
|
89 | 89 | elif not b: |
|
90 | 90 | a = splitnewlines(a) |
|
91 | l1 = "--- %s%s" % ("a/" + fn, datetag(ad)) | |
|
91 | l1 = "--- %s%s" % ("a/" + fn1, datetag(ad)) | |
|
92 | 92 | if b is None: |
|
93 | 93 | l2 = '+++ /dev/null%s' % datetag(epoch, False) |
|
94 | 94 | else: |
|
95 | l2 = "+++ %s%s" % ("b/" + fn, datetag(bd)) | |
|
95 | l2 = "+++ %s%s" % ("b/" + fn2, datetag(bd)) | |
|
96 | 96 | l3 = "@@ -1,%d +0,0 @@\n" % len(a) |
|
97 | 97 | l = [l1, l2, l3] + ["-" + e for e in a] |
|
98 | 98 | else: |
|
99 | 99 | al = splitnewlines(a) |
|
100 | 100 | bl = splitnewlines(b) |
|
101 | l = list(bunidiff(a, b, al, bl, "a/" + fn, "b/" + fn, opts=opts)) | |
|
101 | l = list(bunidiff(a, b, al, bl, "a/" + fn1, "b/" + fn2, opts=opts)) | |
|
102 | 102 | if not l: return "" |
|
103 | 103 | # difflib uses a space, rather than a tab |
|
104 | 104 | l[0] = "%s%s" % (l[0][:-2], datetag(ad)) |
@@ -110,7 +110,7 b' def unidiff(a, ad, b, bd, fn, r=None, op' | |||
|
110 | 110 | |
|
111 | 111 | if r: |
|
112 | 112 | l.insert(0, "diff %s %s\n" % |
|
113 | (' '.join(["-r %s" % rev for rev in r]), fn)) | |
|
113 | (' '.join(["-r %s" % rev for rev in r]), fn1)) | |
|
114 | 114 | |
|
115 | 115 | return "".join(l) |
|
116 | 116 |
@@ -1230,6 +1230,7 b' def diff(repo, node1=None, node2=None, f' | |||
|
1230 | 1230 | to = getfilectx(f, ctx1).data() |
|
1231 | 1231 | if f not in removed: |
|
1232 | 1232 | tn = getfilectx(f, ctx2).data() |
|
1233 | a, b = f, f | |
|
1233 | 1234 | if opts.git: |
|
1234 | 1235 | def gitmode(x, l): |
|
1235 | 1236 | return l and '120000' or (x and '100755' or '100644') |
@@ -1238,7 +1239,6 b' def diff(repo, node1=None, node2=None, f' | |||
|
1238 | 1239 | header.append('old mode %s\n' % omode) |
|
1239 | 1240 | header.append('new mode %s\n' % nmode) |
|
1240 | 1241 | |
|
1241 | a, b = f, f | |
|
1242 | 1242 | if f in added: |
|
1243 | 1243 | mode = gitmode(execf2(f), linkf2(f)) |
|
1244 | 1244 | if f in copied: |
@@ -1278,7 +1278,7 b' def diff(repo, node1=None, node2=None, f' | |||
|
1278 | 1278 | text = mdiff.unidiff(to, date1, |
|
1279 | 1279 | # ctx2 date may be dynamic |
|
1280 | 1280 | tn, util.datestr(ctx2.date()), |
|
1281 |
|
|
|
1281 | a, b, r, opts=opts) | |
|
1282 | 1282 | if text or len(header) > 1: |
|
1283 | 1283 | fp.write(''.join(header)) |
|
1284 | 1284 | fp.write(text) |
@@ -33,7 +33,7 b' old mode 100755' | |||
|
33 | 33 | new mode 100644 |
|
34 | 34 | rename from src |
|
35 | 35 | rename to dst |
|
36 |
--- a/ |
|
|
36 | --- a/src | |
|
37 | 37 | +++ b/dst |
|
38 | 38 | @@ -3,3 +3,4 @@ 3 |
|
39 | 39 | 3 |
@@ -84,7 +84,7 b' rename to dst2' | |||
|
84 | 84 | diff --git a/foo b/bar |
|
85 | 85 | rename from foo |
|
86 | 86 | rename to bar |
|
87 |
--- a/ |
|
|
87 | --- a/foo | |
|
88 | 88 | +++ b/bar |
|
89 | 89 | @@ -1,2 +1,3 @@ a |
|
90 | 90 | a |
@@ -94,7 +94,7 b' rename to bar' | |||
|
94 | 94 | diff --git a/bar b/foo |
|
95 | 95 | rename from bar |
|
96 | 96 | rename to foo |
|
97 |
--- a/ |
|
|
97 | --- a/bar | |
|
98 | 98 | +++ b/foo |
|
99 | 99 | @@ -1,3 +1,2 @@ a |
|
100 | 100 | a |
@@ -105,7 +105,7 b' rename to foo' | |||
|
105 | 105 | diff --git a/foo b/bar |
|
106 | 106 | rename from foo |
|
107 | 107 | rename to bar |
|
108 |
--- a/ |
|
|
108 | --- a/foo | |
|
109 | 109 | +++ b/bar |
|
110 | 110 | @@ -1,1 +1,3 @@ a |
|
111 | 111 | a |
@@ -115,7 +115,7 b' rename to bar' | |||
|
115 | 115 | diff --git a/bar b/foo |
|
116 | 116 | rename from bar |
|
117 | 117 | rename to foo |
|
118 |
--- a/ |
|
|
118 | --- a/bar | |
|
119 | 119 | +++ b/foo |
|
120 | 120 | @@ -1,3 +1,1 @@ a |
|
121 | 121 | a |
General Comments 0
You need to be logged in to leave comments.
Login now