~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

fixme note for bzr status

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
1
2
# -*- coding: UTF-8 -*-
2
3
 
3
4
# This program is free software; you can redistribute it and/or modify
44
45
    ud = difflib.unified_diff(oldlines, newlines,
45
46
                              fromfile=old_label, tofile=new_label)
46
47
 
47
 
    ud = list(ud)
48
48
    # work-around for difflib being too smart for its own good
49
49
    # if /dev/null is "1,0", patch won't recognize it as /dev/null
50
50
    if not oldlines:
 
51
        ud = list(ud)
51
52
        ud[2] = ud[2].replace('-1,0', '-0,0')
52
53
    elif not newlines:
 
54
        ud = list(ud)
53
55
        ud[2] = ud[2].replace('+1,0', '+0,0')
54
 
    # work around for difflib emitting random spaces after the label
55
 
    ud[0] = ud[0][:-2] + '\n'
56
 
    ud[1] = ud[1][:-2] + '\n'
57
56
 
58
57
    for line in ud:
59
58
        to_file.write(line)
212
211
                          specific_files=specific_files)
213
212
 
214
213
    for path, file_id, kind in delta.removed:
215
 
        print >>to_file, '=== removed %s %r' % (kind, path)
 
214
        print >>to_file, '*** removed %s %r' % (kind, path)
216
215
        if kind == 'file':
217
216
            diff_file(old_label + path,
218
217
                      old_tree.get_file(file_id).readlines(),
221
220
                      to_file)
222
221
 
223
222
    for path, file_id, kind in delta.added:
224
 
        print >>to_file, '=== added %s %r' % (kind, path)
 
223
        print >>to_file, '*** added %s %r' % (kind, path)
225
224
        if kind == 'file':
226
225
            diff_file(DEVNULL,
227
226
                      [],
230
229
                      to_file)
231
230
 
232
231
    for old_path, new_path, file_id, kind, text_modified in delta.renamed:
233
 
        print >>to_file, '=== renamed %s %r => %r' % (kind, old_path, new_path)
 
232
        print >>to_file, '*** renamed %s %r => %r' % (kind, old_path, new_path)
234
233
        if text_modified:
235
234
            diff_file(old_label + old_path,
236
235
                      old_tree.get_file(file_id).readlines(),
239
238
                      to_file)
240
239
 
241
240
    for path, file_id, kind in delta.modified:
242
 
        print >>to_file, '=== modified %s %r' % (kind, path)
 
241
        print >>to_file, '*** modified %s %r' % (kind, path)
243
242
        if kind == 'file':
244
243
            diff_file(old_label + path,
245
244
                      old_tree.get_file(file_id).readlines(),