Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/mdiff.py @ 264:4c1d7072d5cd
Attempt to make diff deal with null sources properly
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Attempt to make diff deal with null sources properly
manifest hash: 7766ed2b885640157b93474b6e42573ec061fcfb
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCpJsdywK+sNU5EO8RAr5gAJ9sIik+3FDyI8UvIvrWlku4QgMZWQCcDFvh
MvtqY8pFYTFLp7tM2zzTlu4=
=a0oy
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Mon, 06 Jun 2005 10:51:09 -0800 |
parents | 619e775aa7f9 |
children | 467cea2bf2d8 |
comparison
equal
deleted
inserted
replaced
263:e8eb427c6d71 | 264:4c1d7072d5cd |
---|---|
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): |
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': |
19 l[ln] += "\n\ No newline at end of file\n" | 33 l[ln] += "\n\ No newline at end of file\n" |
20 | 34 |