~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Aaron Bentley
  • Date: 2005-07-27 16:42:41 UTC
  • mto: (1092.1.41) (1185.3.4) (974.1.47)
  • mto: This revision was merged to the branch mainline in revision 1020.
  • Revision ID: abentley@panoramicfeedback.com-20050727164241-c6248889b6c83fa4
Fixed handling of missing newlines in udiffs

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