~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-04-19 08:42:39 UTC
  • mfrom: (1558.15.11 bzr.binaries)
  • Revision ID: pqm@pqm.ubuntu.com-20060419084239-730ca2dccc3bea14
diff and merge handle binaries safely

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from bzrlib.errors import BzrError
19
19
import bzrlib.errors as errors
20
20
from bzrlib.symbol_versioning import *
 
21
from bzrlib.textfile import check_text_lines
21
22
from bzrlib.trace import mutter
22
23
 
23
24
# TODO: Rather than building a changeset object, we should probably
24
25
# invoke callbacks on an object.  That object can either accumulate a
25
26
# list, write them out directly, etc etc.
26
27
 
27
 
def internal_diff(old_filename, oldlines, new_filename, newlines, to_file):
 
28
def internal_diff(old_filename, oldlines, new_filename, newlines, to_file,
 
29
                  allow_binary=False):
28
30
    import difflib
29
31
    
30
32
    # FIXME: difflib is wrong if there is no trailing newline.
42
44
    # both sequences are empty.
43
45
    if not oldlines and not newlines:
44
46
        return
 
47
    
 
48
    if allow_binary is False:
 
49
        check_text_lines(oldlines)
 
50
        check_text_lines(newlines)
45
51
 
46
52
    ud = difflib.unified_diff(oldlines, newlines,
47
53
                              fromfile=old_filename+'\t',