3 # Copyright 2005 Matt Mackall <mpm@selenic.com> |
3 # Copyright 2005 Matt Mackall <mpm@selenic.com> |
4 # |
4 # |
5 # This software may be used and distributed according to the terms |
5 # This software may be used and distributed according to the terms |
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, bdiff |
8 import difflib, struct, bdiff, util, mpatch |
9 from mpatch import * |
|
10 from util import * |
|
11 |
9 |
12 def unidiff(a, ad, b, bd, fn, r=None, text=False): |
10 def unidiff(a, ad, b, bd, fn, r=None, text=False): |
13 |
11 |
14 if not a and not b: return "" |
12 if not a and not b: return "" |
15 epoch = datestr((0,0)) |
13 epoch = util.datestr((0, 0)) |
16 |
14 |
17 if not text and (binary(a) or binary(b)): |
15 if not text and (util.binary(a) or util.binary(b)): |
18 l = ['Binary file %s has changed\n' % fn] |
16 l = ['Binary file %s has changed\n' % fn] |
19 elif a == None: |
17 elif a == None: |
20 b = b.splitlines(1) |
18 b = b.splitlines(1) |
21 l1 = "--- %s\t%s\n" % ("/dev/null", epoch) |
19 l1 = "--- %s\t%s\n" % ("/dev/null", epoch) |
22 l2 = "+++ %s\t%s\n" % ("b/" + fn, bd) |
20 l2 = "+++ %s\t%s\n" % ("b/" + fn, bd) |