~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Martin Pool
  • Date: 2005-08-01 20:10:24 UTC
  • Revision ID: mbp@sourcefrog.net-20050801201024-51c865a893c759fa
- some cleanup of log code to have less special cases

- still some trouble caused by need for EmptyTree to have a root id

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
from bzrlib.tree import EmptyTree
54
54
from bzrlib.delta import compare_trees
55
55
from bzrlib.trace import mutter
 
56
from bzrlib.errors import InvalidRevisionNumber
56
57
 
57
58
 
58
59
def find_touching_revisions(branch, file_id):
100
101
 
101
102
 
102
103
 
 
104
def _enumerate_history(branch):
 
105
    rh = []
 
106
    revno = 1
 
107
    for rev_id in branch.revision_history():
 
108
        rh.append((revno, rev_id))
 
109
        revno += 1
 
110
    return rh
 
111
 
 
112
 
103
113
def show_log(branch,
104
114
             lf,
105
115
             specific_fileid=None,
148
158
    else:
149
159
        searchRE = None
150
160
 
151
 
    which_revs = branch.enum_history(direction)
152
 
    which_revs = [x for x in which_revs if (
153
 
            (start_revision is None or x[0] >= start_revision)
154
 
            and (end_revision is None or x[0] <= end_revision))]
155
 
 
156
 
    if not (verbose or specific_fileid):
157
 
        # no need to know what changed between revisions
158
 
        with_deltas = deltas_for_log_dummy(branch, which_revs)
159
 
    elif direction == 'reverse':
160
 
        with_deltas = deltas_for_log_reverse(branch, which_revs)
161
 
    else:        
162
 
        with_deltas = deltas_for_log_forward(branch, which_revs)
163
 
 
164
 
    for revno, rev, delta in with_deltas:
 
161
    which_revs = _enumerate_history(branch)
 
162
    
 
163
    if start_revision is None:
 
164
        start_revision = 1
 
165
    elif start_revision < 1 or start_revision >= len(which_revs):
 
166
        raise InvalidRevisionNumber(start_revision)
 
167
    
 
168
    if end_revision is None:
 
169
        end_revision = len(which_revs)
 
170
    elif end_revision < 1 or end_revision >= len(which_revs):
 
171
        raise InvalidRevisionNumber(end_revision)
 
172
 
 
173
    # list indexes are 0-based; revisions are 1-based
 
174
    cut_revs = which_revs[(start_revision-1):(end_revision)]
 
175
 
 
176
    if direction == 'reverse':
 
177
        cut_revs.reverse()
 
178
    elif direction == 'forward':
 
179
        pass
 
180
    else:
 
181
        raise ValueError('invalid direction %r' % direction)
 
182
 
 
183
    for revno, rev_id in cut_revs:
 
184
        if verbose or specific_fileid:
 
185
            delta = branch.get_revision_delta(revno)
 
186
            
165
187
        if specific_fileid:
166
188
            if not delta.touches_file_id(specific_fileid):
167
189
                continue
170
192
            # although we calculated it, throw it away without display
171
193
            delta = None
172
194
 
173
 
        if searchRE is None or searchRE.search(rev.message):
174
 
            lf.show(revno, rev, delta)
 
195
        rev = branch.get_revision(rev_id)
 
196
 
 
197
        if searchRE:
 
198
            if not searchRE.search(rev.message):
 
199
                continue
 
200
 
 
201
        lf.show(revno, rev, delta)
175
202
 
176
203
 
177
204