~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Martin Pool
  • Date: 2005-05-05 09:26:27 UTC
  • Revision ID: mbp@sourcefrog.net-20050505092627-cfd25ed501e08001
- Simpler compare_inventories() to possibly replace diff_trees
- New TreeDelta class
- Use this in show_log()

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
    """
95
95
    from osutils import format_date
96
96
    from errors import BzrCheckError
97
 
    from diff import diff_trees
 
97
    from diff import compare_inventories
98
98
    from textui import show_status
 
99
    from inventory import Inventory
99
100
 
100
101
    if to_file == None:
101
102
        import sys
113
114
        
114
115
    branch._need_readlock()
115
116
    precursor = None
 
117
    if verbose:
 
118
        prev_inv = Inventory()
116
119
    for revno, revision_id in which_revs():
117
120
        print >>to_file,  '-' * 60
118
121
        print >>to_file,  'revno:', revno
137
140
        # Don't show a list of changed files if we were asked about
138
141
        # one specific file.
139
142
 
140
 
        if verbose and precursor and not filename:
141
 
            # TODO: Group as added/deleted/renamed instead
142
 
            # TODO: Show file ids
143
 
            print >>to_file, 'changed files:'
144
 
            tree = branch.revision_tree(revision_id)
145
 
            prevtree = branch.revision_tree(precursor)
146
 
 
147
 
            for file_state, fid, old_name, new_name, kind in \
148
 
                                    diff_trees(prevtree, tree, ):
149
 
                if file_state == 'A' or file_state == 'M':
150
 
                    show_status(file_state, kind, new_name)
151
 
                elif file_state == 'D':
152
 
                    show_status(file_state, kind, old_name)
153
 
                elif file_state == 'R':
154
 
                    show_status(file_state, kind,
155
 
                        old_name + ' => ' + new_name)
 
143
        if verbose and not filename:
 
144
            this_inv = branch.get_inventory(rev.inventory_id)
 
145
            delta = compare_inventories(prev_inv, this_inv)
 
146
 
 
147
            if delta.removed:
 
148
                print >>to_file, 'removed files:'
 
149
                for path, fid in delta.removed:
 
150
                    print >>to_file, '  ' + path
 
151
            if delta.added:
 
152
                print >>to_file, 'added files:'
 
153
                for path, fid in delta.added:
 
154
                    print >>to_file, '  ' + path
 
155
            if delta.renamed:
 
156
                print >>to_file, 'renamed files:'
 
157
                for oldpath, newpath, fid in delta.renamed:
 
158
                    print >>to_file, '  %s => %s' % (oldpath, newpath)
 
159
            if delta.modified:
 
160
                print >>to_file, 'modified files:'
 
161
                for path, fid in delta.modified:
 
162
                    print >>to_file, '  ' + path
 
163
 
 
164
            prev_inv = this_inv
156
165
 
157
166
        precursor = revision_id
158
167