comparison mercurial/mdiff.py @ 1379:8ee7ce877be2

Clean up mdiff imports
author Matt Mackall <mpm@selenic.com>
date Tue, 04 Oct 2005 11:25:48 -0700
parents a0fcfbbf52bb
children f1755621cb7d
comparison
equal deleted inserted replaced
1378:a0fcfbbf52bb 1379:8ee7ce877be2
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)
115 t.append(bin[pos:pos + l]) 113 t.append(bin[pos:pos + l])
116 pos += l 114 pos += l
117 return "".join(t) 115 return "".join(t)
118 116
119 def patch(a, bin): 117 def patch(a, bin):
120 return patches(a, [bin]) 118 return mpatch.patches(a, [bin])
121 119
120 patches = mpatch.patches
122 textdiff = bdiff.bdiff 121 textdiff = bdiff.bdiff
123 122
124 123