~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Martin Pool
  • Date: 2005-09-19 11:18:29 UTC
  • Revision ID: mbp@sourcefrog.net-20050919111828-e57e9ff78ea2b2e8
- add diff command to weave utility

Show diffs side-by-side

added added

removed removed

Lines of Context:
835
835
        Display composite of all selected versions.
836
836
    weave merge WEAVEFILE VERSION1 VERSION2 > OUT
837
837
        Auto-merge two versions and display conflicts.
 
838
    weave diff WEAVEFILE VERSION1 VERSION2 
 
839
        Show differences between two versions.
838
840
 
839
841
example:
840
842
 
908
910
        w = readit()
909
911
        sys.stdout.writelines(w.mash_iter(map(int, argv[3:])))
910
912
 
 
913
    elif cmd == 'diff':
 
914
        from difflib import unified_diff
 
915
        w = readit()
 
916
        fn = argv[2]
 
917
        v1, v2 = map(int, argv[3:5])
 
918
        lines1 = w.get(v1)
 
919
        lines2 = w.get(v2)
 
920
        diff_gen = unified_diff(lines1, lines2,
 
921
                                '%s version %d' % (fn, v1),
 
922
                                '%s version %d' % (fn, v2))
 
923
        sys.stdout.writelines(diff_gen)
 
924
            
911
925
    elif cmd == 'annotate':
912
926
        w = readit()
913
927
        # newline is added to all lines regardless; too hard to get