~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Martin Pool
  • Date: 2005-06-29 04:11:40 UTC
  • Revision ID: mbp@sourcefrog.net-20050629041140-6b17e65a23ffdf47
Merge John's log patch:

implements bzr log --forward --verbose
optimizes so that only logs to be printed are read (rather than reading
all and filtering out unwanted).

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
        mutter('get log for file_id %r' % specific_fileid)
126
126
 
127
127
    which_revs = branch.enum_history(direction)
 
128
    which_revs = [x for x in which_revs if (
 
129
            (start_revision is None or x[0] >= start_revision)
 
130
            and (end_revision is None or x[0] <= end_revision))]
128
131
 
129
132
    if not (verbose or specific_fileid):
130
133
        # no need to know what changed between revisions
132
135
    elif direction == 'reverse':
133
136
        with_deltas = deltas_for_log_reverse(branch, which_revs)
134
137
    else:        
135
 
        raise NotImplementedError("sorry, verbose forward logs not done yet")
 
138
        with_deltas = deltas_for_log_forward(branch, which_revs)
136
139
 
137
140
    for revno, rev, delta in with_deltas:
138
141
        if specific_fileid:
139
142
            if not delta.touches_file_id(specific_fileid):
140
143
                continue
141
144
 
142
 
        if start_revision is not None and revno < start_revision:
143
 
            continue
144
 
 
145
 
        if end_revision is not None and revno > end_revision:
146
 
            continue
147
 
        
148
145
        if not verbose:
149
146
            # although we calculated it, throw it away without display
150
147
            delta = None
184
181
        last_tree = this_tree
185
182
 
186
183
    if last_revno:
187
 
        this_tree = EmptyTree()
 
184
        if last_revno == 1:
 
185
            this_tree = EmptyTree()
 
186
        else:
 
187
            this_revno = last_revno - 1
 
188
            this_revision_id = branch.revision_history()[this_revno]
 
189
            this_tree = branch.revision_tree(this_revision_id)
188
190
        yield last_revno, last_revision, compare_trees(this_tree, last_tree, False)
189
191
 
190
192
 
 
193
def deltas_for_log_forward(branch, which_revs):
 
194
    """Compute deltas for display in forward log.
 
195
 
 
196
    Given a sequence of (revno, revision_id) pairs, return
 
197
    (revno, rev, delta).
 
198
 
 
199
    The delta is from the given revision to the next one in the
 
200
    sequence, which makes sense if the log is being displayed from
 
201
    newest to oldest.
 
202
    """
 
203
    from tree import EmptyTree
 
204
    from diff import compare_trees
 
205
 
 
206
    last_revno = last_revision_id = last_tree = None
 
207
    for revno, revision_id in which_revs:
 
208
        this_tree = branch.revision_tree(revision_id)
 
209
        this_revision = branch.get_revision(revision_id)
 
210
 
 
211
        if not last_revno:
 
212
            if revno == 1:
 
213
                last_tree = EmptyTree()
 
214
            else:
 
215
                last_revno = revno - 1
 
216
                last_revision_id = branch.revision_history()[last_revno]
 
217
                last_tree = branch.revision_tree(last_revision_id)
 
218
 
 
219
        yield revno, this_revision, compare_trees(last_tree, this_tree, False)
 
220
 
 
221
        last_revno = revno
 
222
        last_revision = this_revision
 
223
        last_tree = this_tree
191
224
 
192
225
 
193
226
class LogFormatter(object):