~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Robert Collins
  • Date: 2005-09-07 10:47:36 UTC
  • mto: (1092.3.1)
  • mto: This revision was merged to the branch mainline in revision 1397.
  • Revision ID: robertc@robertcollins.net-20050907104736-8e592b72108c577d
symlink support updated to work

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
    print >>to_file
62
62
 
63
63
 
64
 
 
65
 
 
66
64
def external_diff(old_label, oldlines, new_label, newlines, to_file,
67
65
                  diff_opts):
68
66
    """Display a diff by calling out to the external diff program."""
140
138
    finally:
141
139
        oldtmpf.close()                 # and delete
142
140
        newtmpf.close()
143
 
    
144
 
 
145
141
 
146
142
def show_diff(b, revision, specific_files, external_diff_options=None,
147
143
              revision2=None, output=None):
230
226
 
231
227
    for old_path, new_path, file_id, kind, text_modified in delta.renamed:
232
228
        print >>to_file, '*** renamed %s %r => %r' % (kind, old_path, new_path)
233
 
        if text_modified:
 
229
        _maybe_diff_file_or_symlink(old_label, old_path, old_tree, file_id,
 
230
                                    new_label, new_path, new_tree,
 
231
                                    text_modified, kind, to_file)
 
232
 
 
233
    for path, file_id, kind in delta.modified:
 
234
        print >>to_file, '*** modified %s %r' % (kind, path)
 
235
        _maybe_diff_file_or_symlink(old_label, path, old_tree, file_id,
 
236
                                    new_label, path, new_tree,
 
237
                                    True, kind, to_file)
 
238
 
 
239
def _maybe_diff_file_or_symlink(old_label, old_path, old_tree, file_id,
 
240
                                new_label, new_path, new_tree, text_modified,
 
241
                                kind, to_file):
 
242
    if text_modified:
 
243
        if kind == 'file':
234
244
            diff_file(old_label + old_path,
235
245
                      old_tree.get_file(file_id).readlines(),
236
246
                      new_label + new_path,
237
247
                      new_tree.get_file(file_id).readlines(),
238
248
                      to_file)
239
 
 
240
 
    for path, file_id, kind in delta.modified:
241
 
        print >>to_file, '*** modified %s %r' % (kind, path)
242
 
        if kind == 'file':
243
 
            diff_file(old_label + path,
244
 
                      old_tree.get_file(file_id).readlines(),
245
 
                      new_label + path,
246
 
                      new_tree.get_file(file_id).readlines(),
247
 
                      to_file)
248
 
 
249
 
 
250
 
 
251
 
 
252
 
 
 
249
        elif kind == 'symlink':
 
250
            _diff_symlink(old_tree, new_tree, file_id, to_file)
 
251
            
 
252
def _diff_symlink(old_tree, new_tree, file_id, to_file):
 
253
    t1 = old_tree.get_symlink_target(file_id)
 
254
    t2 = new_tree.get_symlink_target(file_id)
 
255
    print >>to_file, '*** *** target changed %r => %r' % (t1, t2)
 
256