~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: Martin Pool
  • Date: 2005-07-06 04:40:52 UTC
  • Revision ID: mbp@sourcefrog.net-20050706044052-afa8a07b9a132888
- Start splitting bzr-independent parts of the test framework into
  testsweet.py

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
 
45
54
    ud = difflib.unified_diff(oldlines, newlines,
46
55
                              fromfile=old_label, tofile=new_label)
47
56
 
56
65
 
57
66
    for line in ud:
58
67
        to_file.write(line)
59
 
        if not line.endswith('\n'):
60
 
            to_file.write("\n\\ No newline at end of file\n")
 
68
    if nonl:
 
69
        print >>to_file, "\\ No newline at end of file"
61
70
    print >>to_file
62
71
 
63
72
 
380
389
 
381
390
    for file_id in old_tree:
382
391
        if file_id in new_tree:
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
 
392
            kind = old_inv.get_file_kind(file_id)
 
393
            assert kind == new_inv.get_file_kind(file_id)
388
394
            
389
395
            assert kind in ('file', 'directory', 'symlink', 'root_directory'), \
390
396
                   'invalid file kind %r' % kind
392
398
            if kind == 'root_directory':
393
399
                continue
394
400
            
 
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
 
395
407
            if specific_files:
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))):
 
408
                if (not is_inside_any(specific_files, old_path) 
 
409
                    and not is_inside_any(specific_files, new_path)):
398
410
                    continue
399
411
 
400
412
            if kind == 'file':
412
424
            
413
425
            if (old_ie.name != new_ie.name
414
426
                or old_ie.parent_id != new_ie.parent_id):
415
 
                delta.renamed.append((old_inv.id2path(file_id),
416
 
                                      new_inv.id2path(file_id),
417
 
                                      file_id, kind,
 
427
                delta.renamed.append((old_path, new_path, file_id, kind,
418
428
                                      text_modified))
419
429
            elif text_modified:
420
 
                delta.modified.append((new_inv.id2path(file_id), file_id, kind))
 
430
                delta.modified.append((new_path, file_id, kind))
421
431
            elif want_unchanged:
422
 
                delta.unchanged.append((new_inv.id2path(file_id), file_id, kind))
 
432
                delta.unchanged.append((new_path, file_id, kind))
423
433
        else:
424
434
            kind = old_inv.get_file_kind(file_id)
425
435
            old_path = old_inv.id2path(file_id)