/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Robert Collins
  • Date: 2005-10-09 23:42:12 UTC
  • Revision ID: robertc@robertcollins.net-20051009234212-7973344d900afb0b
merge in niemeyers prefixed-store patch

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
57
56
 
58
57
 
59
58
def find_touching_revisions(branch, file_id):
110
109
    return rh
111
110
 
112
111
 
 
112
def _get_revision_delta(branch, revno):
 
113
    """Return the delta for a mainline revision.
 
114
    
 
115
    This is used to show summaries in verbose logs, and also for finding 
 
116
    revisions which touch a given file."""
 
117
    # XXX: What are we supposed to do when showing a summary for something 
 
118
    # other than a mainline revision.  The delta to it's first parent, or
 
119
    # (more useful) the delta to a nominated other revision.
 
120
    return branch.get_revision_delta(revno)
 
121
 
 
122
 
113
123
def show_log(branch,
114
124
             lf,
115
125
             specific_fileid=None,
140
150
    end_revision
141
151
        If not None, only show revisions <= end_revision
142
152
    """
 
153
    branch.lock_read()
 
154
    try:
 
155
        _show_log(branch, lf, specific_fileid, verbose, direction,
 
156
                  start_revision, end_revision, search)
 
157
    finally:
 
158
        branch.unlock()
 
159
    
 
160
def _show_log(branch,
 
161
             lf,
 
162
             specific_fileid=None,
 
163
             verbose=False,
 
164
             direction='reverse',
 
165
             start_revision=None,
 
166
             end_revision=None,
 
167
             search=None):
 
168
    """Worker function for show_log - see show_log."""
143
169
    from bzrlib.osutils import format_date
144
170
    from bzrlib.errors import BzrCheckError
145
171
    from bzrlib.textui import show_status
162
188
    
163
189
    if start_revision is None:
164
190
        start_revision = 1
165
 
    elif start_revision < 1 or start_revision >= len(which_revs):
166
 
        raise InvalidRevisionNumber(start_revision)
 
191
    else:
 
192
        branch.check_real_revno(start_revision)
167
193
    
168
194
    if end_revision is None:
169
195
        end_revision = len(which_revs)
170
 
    elif end_revision < 1 or end_revision >= len(which_revs):
171
 
        raise InvalidRevisionNumber(end_revision)
 
196
    else:
 
197
        branch.check_real_revno(end_revision)
172
198
 
173
199
    # list indexes are 0-based; revisions are 1-based
174
200
    cut_revs = which_revs[(start_revision-1):(end_revision)]
182
208
 
183
209
    for revno, rev_id in cut_revs:
184
210
        if verbose or specific_fileid:
185
 
            delta = branch.get_revision_delta(revno)
 
211
            delta = _get_revision_delta(branch, revno)
186
212
            
187
213
        if specific_fileid:
188
214
            if not delta.touches_file_id(specific_fileid):
294
320
 
295
321
    def show(self, revno, rev, delta):
296
322
        raise NotImplementedError('not implemented in abstract base')
297
 
        
298
 
 
299
 
 
300
 
 
301
 
 
302
 
 
 
323
 
 
324
    
303
325
class LongLogFormatter(LogFormatter):
304
326
    def show(self, revno, rev, delta):
305
327
        from osutils import format_date
310
332
        print >>to_file,  'revno:', revno
311
333
        if self.show_ids:
312
334
            print >>to_file,  'revision-id:', rev.revision_id
 
335
 
 
336
            for parent_id in rev.parent_ids:
 
337
                print >>to_file, 'parent:', parent_id
 
338
            
313
339
        print >>to_file,  'committer:', rev.committer
314
340
 
315
341
        date_str = format_date(rev.timestamp,
360
386
 
361
387
 
362
388
def log_formatter(name, *args, **kwargs):
 
389
    """Construct a formatter from arguments.
 
390
 
 
391
    name -- Name of the formatter to construct; currently 'long' and
 
392
        'short' are supported.
 
393
    """
363
394
    from bzrlib.errors import BzrCommandError
364
 
    
365
395
    try:
366
396
        return FORMATTERS[name](*args, **kwargs)
367
397
    except IndexError: