~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Martin Pool
  • Date: 2005-06-28 05:33:40 UTC
  • Revision ID: mbp@sourcefrog.net-20050628053340-ea73b03fbcde9c46
- Remove XMLMixin class in favour of simple pack_xml, unpack_xml functions
  called as needed.  

- Avoid importing xml and ElementTree library unless needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
             verbose=False,
90
90
             direction='reverse',
91
91
             start_revision=None,
92
 
             end_revision=None,
93
 
             search=None):
 
92
             end_revision=None):
94
93
    """Write out human-readable log of commits to this branch.
95
94
 
96
95
    lf
125
124
    if specific_fileid:
126
125
        mutter('get log for file_id %r' % specific_fileid)
127
126
 
128
 
    if search is not None:
129
 
        import re
130
 
        searchRE = re.compile(search, re.IGNORECASE)
131
 
    else:
132
 
        searchRE = None
133
 
 
134
127
    which_revs = branch.enum_history(direction)
135
 
    which_revs = [x for x in which_revs if (
136
 
            (start_revision is None or x[0] >= start_revision)
137
 
            and (end_revision is None or x[0] <= end_revision))]
138
128
 
139
129
    if not (verbose or specific_fileid):
140
130
        # no need to know what changed between revisions
142
132
    elif direction == 'reverse':
143
133
        with_deltas = deltas_for_log_reverse(branch, which_revs)
144
134
    else:        
145
 
        with_deltas = deltas_for_log_forward(branch, which_revs)
 
135
        raise NotImplementedError("sorry, verbose forward logs not done yet")
146
136
 
147
137
    for revno, rev, delta in with_deltas:
148
138
        if specific_fileid:
149
139
            if not delta.touches_file_id(specific_fileid):
150
140
                continue
151
141
 
 
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
        
152
148
        if not verbose:
153
149
            # although we calculated it, throw it away without display
154
150
            delta = None
155
151
 
156
 
        if searchRE is None or searchRE.search(rev.message):
157
 
            lf.show(revno, rev, delta)
 
152
        lf.show(revno, rev, delta)
158
153
 
159
154
 
160
155
 
184
179
        if last_revno:
185
180
            yield last_revno, last_revision, compare_trees(this_tree, last_tree, False)
186
181
 
187
 
        this_tree = EmptyTree(branch.get_root_id())
188
 
 
189
182
        last_revno = revno
190
183
        last_revision = this_revision
191
184
        last_tree = this_tree
192
185
 
193
186
    if last_revno:
194
 
        if last_revno == 1:
195
 
            this_tree = EmptyTree(branch.get_root_id())
196
 
        else:
197
 
            this_revno = last_revno - 1
198
 
            this_revision_id = branch.revision_history()[this_revno]
199
 
            this_tree = branch.revision_tree(this_revision_id)
 
187
        this_tree = EmptyTree()
200
188
        yield last_revno, last_revision, compare_trees(this_tree, last_tree, False)
201
189
 
202
190
 
203
 
def deltas_for_log_forward(branch, which_revs):
204
 
    """Compute deltas for display in forward log.
205
 
 
206
 
    Given a sequence of (revno, revision_id) pairs, return
207
 
    (revno, rev, delta).
208
 
 
209
 
    The delta is from the given revision to the next one in the
210
 
    sequence, which makes sense if the log is being displayed from
211
 
    newest to oldest.
212
 
    """
213
 
    from tree import EmptyTree
214
 
    from diff import compare_trees
215
 
 
216
 
    last_revno = last_revision_id = last_tree = None
217
 
    prev_tree = EmptyTree(branch.get_root_id())
218
 
 
219
 
    for revno, revision_id in which_revs:
220
 
        this_tree = branch.revision_tree(revision_id)
221
 
        this_revision = branch.get_revision(revision_id)
222
 
 
223
 
        if not last_revno:
224
 
            if revno == 1:
225
 
                last_tree = EmptyTree(branch.get_root_id())
226
 
            else:
227
 
                last_revno = revno - 1
228
 
                last_revision_id = branch.revision_history()[last_revno]
229
 
                last_tree = branch.revision_tree(last_revision_id)
230
 
 
231
 
        yield revno, this_revision, compare_trees(last_tree, this_tree, False)
232
 
 
233
 
        last_revno = revno
234
 
        last_revision = this_revision
235
 
        last_tree = this_tree
236
191
 
237
192
 
238
193
class LogFormatter(object):