~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: 2007-08-21 04:19:12 UTC
  • mfrom: (2711.2.7 remove-bzrdir-statics)
  • Revision ID: pqm@pqm.ubuntu.com-20070821041912-ph1kv921fvotcgdd
remove static BzrDir.create_repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
347
347
def show_diff_trees(old_tree, new_tree, to_file, specific_files=None,
348
348
                    external_diff_options=None,
349
349
                    old_label='a/', new_label='b/',
350
 
                    extra_trees=None,
351
 
                    path_encoding='utf8'):
 
350
                    extra_trees=None):
352
351
    """Show in text form the changes from one tree to another.
353
352
 
354
353
    to_files
359
358
 
360
359
    extra_trees
361
360
        If set, more Trees to use for looking up file ids
362
 
 
363
 
    path_encoding
364
 
        If set, the path will be encoded as specified, otherwise is supposed
365
 
        to be utf8
366
361
    """
367
362
    old_tree.lock_read()
368
363
    try:
374
369
            return _show_diff_trees(old_tree, new_tree, to_file,
375
370
                                    specific_files, external_diff_options,
376
371
                                    old_label=old_label, new_label=new_label,
377
 
                                    extra_trees=extra_trees,
378
 
                                    path_encoding=path_encoding)
 
372
                                    extra_trees=extra_trees)
379
373
        finally:
380
374
            new_tree.unlock()
381
375
            if extra_trees is not None:
386
380
 
387
381
 
388
382
def _show_diff_trees(old_tree, new_tree, to_file,
389
 
                     specific_files, external_diff_options, path_encoding,
 
383
                     specific_files, external_diff_options, 
390
384
                     old_label='a/', new_label='b/', extra_trees=None):
391
385
 
392
386
    # GNU Patch uses the epoch date to detect files that are being added
411
405
    has_changes = 0
412
406
    for path, file_id, kind in delta.removed:
413
407
        has_changes = 1
414
 
        path_encoded = path.encode(path_encoding, "replace")
415
 
        print >>to_file, "=== removed %s '%s'" % (kind, path_encoded)
 
408
        print >>to_file, "=== removed %s '%s'" % (kind, path.encode('utf8'))
416
409
        old_name = '%s%s\t%s' % (old_label, path,
417
410
                                 _patch_header_date(old_tree, file_id, path))
418
411
        new_name = '%s%s\t%s' % (new_label, path, EPOCH_DATE)
420
413
                                         new_name, None, None, to_file)
421
414
    for path, file_id, kind in delta.added:
422
415
        has_changes = 1
423
 
        path_encoded = path.encode(path_encoding, "replace")
424
 
        print >>to_file, "=== added %s '%s'" % (kind, path_encoded)
 
416
        print >>to_file, "=== added %s '%s'" % (kind, path.encode('utf8'))
425
417
        old_name = '%s%s\t%s' % (old_label, path, EPOCH_DATE)
426
418
        new_name = '%s%s\t%s' % (new_label, path,
427
419
                                 _patch_header_date(new_tree, file_id, path))
432
424
         text_modified, meta_modified) in delta.renamed:
433
425
        has_changes = 1
434
426
        prop_str = get_prop_change(meta_modified)
435
 
        oldpath_encoded = old_path.encode(path_encoding, "replace")
436
 
        newpath_encoded = new_path.encode(path_encoding, "replace")
437
 
        print >>to_file, "=== renamed %s '%s' => '%s'%s" % (kind,
438
 
                            oldpath_encoded, newpath_encoded, prop_str)
 
427
        print >>to_file, "=== renamed %s '%s' => %r%s" % (
 
428
                    kind, old_path.encode('utf8'),
 
429
                    new_path.encode('utf8'), prop_str)
439
430
        old_name = '%s%s\t%s' % (old_label, old_path,
440
431
                                 _patch_header_date(old_tree, file_id,
441
432
                                                    old_path))
448
439
    for path, file_id, kind, text_modified, meta_modified in delta.modified:
449
440
        has_changes = 1
450
441
        prop_str = get_prop_change(meta_modified)
451
 
        path_encoded = path.encode(path_encoding, "replace")
452
 
        print >>to_file, "=== modified %s '%s'%s" % (kind,
453
 
                            path_encoded, prop_str)
 
442
        print >>to_file, "=== modified %s '%s'%s" % (kind, path.encode('utf8'),
 
443
                                                     prop_str)
454
444
        # The file may be in a different location in the old tree (because
455
445
        # the containing dir was renamed, but the file itself was not)
456
446
        old_path = old_tree.id2path(file_id)