~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Martin Pool
  • Date: 2005-08-01 23:14:12 UTC
  • mfrom: (974.1.11)
  • Revision ID: mbp@sourcefrog.net-20050801231412-6a6278d24a7cbb0a
- merge aaron's revert and merge improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
    if not oldlines and not newlines:
43
43
        return
44
44
 
45
 
    nonl = False
46
 
 
47
 
    if oldlines and (oldlines[-1][-1] != '\n'):
48
 
        oldlines[-1] += '\n'
49
 
        nonl = True
50
 
    if newlines and (newlines[-1][-1] != '\n'):
51
 
        newlines[-1] += '\n'
52
 
        nonl = True
53
 
 
54
45
    ud = difflib.unified_diff(oldlines, newlines,
55
46
                              fromfile=old_label, tofile=new_label)
56
47
 
65
56
 
66
57
    for line in ud:
67
58
        to_file.write(line)
68
 
    if nonl:
69
 
        print >>to_file, "\\ No newline at end of file"
 
59
        if not line.endswith('\n'):
 
60
            to_file.write("\n\\ No newline at end of file\n")
70
61
    print >>to_file
71
62
 
72
63