~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Aaron Bentley
  • Date: 2005-08-10 21:43:27 UTC
  • mto: (1092.1.41) (1185.3.4) (974.1.47)
  • mto: This revision was merged to the branch mainline in revision 1110.
  • Revision ID: abentley@panoramicfeedback.com-20050810214327-4e8c22e4cba24527
Eliminated ThreeWayInventory

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
 
389
380
 
390
381
    for file_id in old_tree:
391
382
        if file_id in new_tree:
392
 
            kind = old_inv.get_file_kind(file_id)
393
 
            assert kind == new_inv.get_file_kind(file_id)
 
383
            old_ie = old_inv[file_id]
 
384
            new_ie = new_inv[file_id]
 
385
 
 
386
            kind = old_ie.kind
 
387
            assert kind == new_ie.kind
394
388
            
395
389
            assert kind in ('file', 'directory', 'symlink', 'root_directory'), \
396
390
                   'invalid file kind %r' % kind
398
392
            if kind == 'root_directory':
399
393
                continue
400
394
            
401
 
            old_path = old_inv.id2path(file_id)
402
 
            new_path = new_inv.id2path(file_id)
403
 
 
404
 
            old_ie = old_inv[file_id]
405
 
            new_ie = new_inv[file_id]
406
 
 
407
395
            if specific_files:
408
 
                if (not is_inside_any(specific_files, old_path) 
409
 
                    and not is_inside_any(specific_files, new_path)):
 
396
                if (not is_inside_any(specific_files, old_inv.id2path(file_id)) 
 
397
                    and not is_inside_any(specific_files, new_inv.id2path(file_id))):
410
398
                    continue
411
399
 
412
400
            if kind == 'file':
424
412
            
425
413
            if (old_ie.name != new_ie.name
426
414
                or old_ie.parent_id != new_ie.parent_id):
427
 
                delta.renamed.append((old_path, new_path, file_id, kind,
 
415
                delta.renamed.append((old_inv.id2path(file_id),
 
416
                                      new_inv.id2path(file_id),
 
417
                                      file_id, kind,
428
418
                                      text_modified))
429
419
            elif text_modified:
430
 
                delta.modified.append((new_path, file_id, kind))
 
420
                delta.modified.append((new_inv.id2path(file_id), file_id, kind))
431
421
            elif want_unchanged:
432
 
                delta.unchanged.append((new_path, file_id, kind))
 
422
                delta.unchanged.append((new_inv.id2path(file_id), file_id, kind))
433
423
        else:
434
424
            kind = old_inv.get_file_kind(file_id)
435
425
            old_path = old_inv.id2path(file_id)