/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: John Arbash Meinel
  • Date: 2007-04-18 22:37:59 UTC
  • mto: This revision was merged to the branch mainline in revision 2456.
  • Revision ID: john@arbash-meinel.com-20070418223759-kek0qqqdv3wddcae
Create a direct test for _get_revisions_touching_file_id

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
 
 
18
 
 
19
"""Code to show logs of changes.
 
20
 
 
21
Various flavors of log can be produced:
 
22
 
 
23
* for one file, or the whole tree, and (not done yet) for
 
24
  files in a given directory
 
25
 
 
26
* in "verbose" mode with a description of what changed from one
 
27
  version to the next
 
28
 
 
29
* with file-ids and revision-ids shown
 
30
 
 
31
Logs are actually written out through an abstract LogFormatter
 
32
interface, which allows for different preferred formats.  Plugins can
 
33
register formats too.
 
34
 
 
35
Logs can be produced in either forward (oldest->newest) or reverse
 
36
(newest->oldest) order.
 
37
 
 
38
Logs can be filtered to show only revisions matching a particular
 
39
search string, or within a particular range of revisions.  The range
 
40
can be given as date/times, which are reduced to revisions before
 
41
calling in here.
 
42
 
 
43
In verbose mode we show a summary of what changed in each particular
 
44
revision.  Note that this is the delta for changes in that revision
 
45
relative to its mainline parent, not the delta relative to the last
 
46
logged revision.  So for example if you ask for a verbose log of
 
47
changes touching hello.c you will get a list of those revisions also
 
48
listing other things that were changed in the same revision, but not
 
49
all the changes since the previous revision that touched hello.c.
 
50
"""
 
51
 
 
52
# TODO: option to show delta summaries for merged-in revisions
 
53
 
 
54
from itertools import izip
 
55
import re
 
56
 
 
57
from bzrlib import(
 
58
    registry,
 
59
    symbol_versioning,
 
60
    )
 
61
import bzrlib.errors as errors
 
62
from bzrlib.symbol_versioning import deprecated_method, zero_eleven
 
63
from bzrlib.trace import mutter
 
64
from bzrlib.tsort import(
 
65
    merge_sort,
 
66
    topo_sort,
 
67
    )
 
68
 
 
69
 
 
70
def find_touching_revisions(branch, file_id):
 
71
    """Yield a description of revisions which affect the file_id.
 
72
 
 
73
    Each returned element is (revno, revision_id, description)
 
74
 
 
75
    This is the list of revisions where the file is either added,
 
76
    modified, renamed or deleted.
 
77
 
 
78
    TODO: Perhaps some way to limit this to only particular revisions,
 
79
    or to traverse a non-mainline set of revisions?
 
80
    """
 
81
    last_ie = None
 
82
    last_path = None
 
83
    revno = 1
 
84
    for revision_id in branch.revision_history():
 
85
        this_inv = branch.repository.get_revision_inventory(revision_id)
 
86
        if file_id in this_inv:
 
87
            this_ie = this_inv[file_id]
 
88
            this_path = this_inv.id2path(file_id)
 
89
        else:
 
90
            this_ie = this_path = None
 
91
 
 
92
        # now we know how it was last time, and how it is in this revision.
 
93
        # are those two states effectively the same or not?
 
94
 
 
95
        if not this_ie and not last_ie:
 
96
            # not present in either
 
97
            pass
 
98
        elif this_ie and not last_ie:
 
99
            yield revno, revision_id, "added " + this_path
 
100
        elif not this_ie and last_ie:
 
101
            # deleted here
 
102
            yield revno, revision_id, "deleted " + last_path
 
103
        elif this_path != last_path:
 
104
            yield revno, revision_id, ("renamed %s => %s" % (last_path, this_path))
 
105
        elif (this_ie.text_size != last_ie.text_size
 
106
              or this_ie.text_sha1 != last_ie.text_sha1):
 
107
            yield revno, revision_id, "modified " + this_path
 
108
 
 
109
        last_ie = this_ie
 
110
        last_path = this_path
 
111
        revno += 1
 
112
 
 
113
 
 
114
 
 
115
def _enumerate_history(branch):
 
116
    rh = []
 
117
    revno = 1
 
118
    for rev_id in branch.revision_history():
 
119
        rh.append((revno, rev_id))
 
120
        revno += 1
 
121
    return rh
 
122
 
 
123
 
 
124
def show_log(branch,
 
125
             lf,
 
126
             specific_fileid=None,
 
127
             verbose=False,
 
128
             direction='reverse',
 
129
             start_revision=None,
 
130
             end_revision=None,
 
131
             search=None):
 
132
    """Write out human-readable log of commits to this branch.
 
133
 
 
134
    lf
 
135
        LogFormatter object to show the output.
 
136
 
 
137
    specific_fileid
 
138
        If true, list only the commits affecting the specified
 
139
        file, rather than all commits.
 
140
 
 
141
    verbose
 
142
        If true show added/changed/deleted/renamed files.
 
143
 
 
144
    direction
 
145
        'reverse' (default) is latest to earliest;
 
146
        'forward' is earliest to latest.
 
147
 
 
148
    start_revision
 
149
        If not None, only show revisions >= start_revision
 
150
 
 
151
    end_revision
 
152
        If not None, only show revisions <= end_revision
 
153
    """
 
154
    branch.lock_read()
 
155
    try:
 
156
        _show_log(branch, lf, specific_fileid, verbose, direction,
 
157
                  start_revision, end_revision, search)
 
158
    finally:
 
159
        branch.unlock()
 
160
    
 
161
def _show_log(branch,
 
162
             lf,
 
163
             specific_fileid=None,
 
164
             verbose=False,
 
165
             direction='reverse',
 
166
             start_revision=None,
 
167
             end_revision=None,
 
168
             search=None):
 
169
    """Worker function for show_log - see show_log."""
 
170
    from bzrlib.osutils import format_date
 
171
    from bzrlib.errors import BzrCheckError
 
172
    
 
173
    from warnings import warn
 
174
 
 
175
    if not isinstance(lf, LogFormatter):
 
176
        warn("not a LogFormatter instance: %r" % lf)
 
177
 
 
178
    if specific_fileid:
 
179
        mutter('get log for file_id %r', specific_fileid)
 
180
 
 
181
    if search is not None:
 
182
        import re
 
183
        searchRE = re.compile(search, re.IGNORECASE)
 
184
    else:
 
185
        searchRE = None
 
186
 
 
187
    which_revs = _enumerate_history(branch)
 
188
    
 
189
    if start_revision is None:
 
190
        start_revision = 1
 
191
    else:
 
192
        branch.check_real_revno(start_revision)
 
193
    
 
194
    if end_revision is None:
 
195
        end_revision = len(which_revs)
 
196
    else:
 
197
        branch.check_real_revno(end_revision)
 
198
 
 
199
    # list indexes are 0-based; revisions are 1-based
 
200
    cut_revs = which_revs[(start_revision-1):(end_revision)]
 
201
    if not cut_revs:
 
202
        return
 
203
 
 
204
    # convert the revision history to a dictionary:
 
205
    rev_nos = dict((k, v) for v, k in cut_revs)
 
206
 
 
207
    # override the mainline to look like the revision history.
 
208
    mainline_revs = [revision_id for index, revision_id in cut_revs]
 
209
    if cut_revs[0][0] == 1:
 
210
        mainline_revs.insert(0, None)
 
211
    else:
 
212
        mainline_revs.insert(0, which_revs[start_revision-2][1])
 
213
    # how should we show merged revisions ?
 
214
    # old api: show_merge. New api: show_merge_revno
 
215
    show_merge_revno = getattr(lf, 'show_merge_revno', None)
 
216
    show_merge = getattr(lf, 'show_merge', None)
 
217
    if show_merge is None and show_merge_revno is None:
 
218
        # no merged-revno support
 
219
        include_merges = False
 
220
    else:
 
221
        include_merges = True
 
222
    if show_merge is not None and show_merge_revno is None:
 
223
        # tell developers to update their code
 
224
        symbol_versioning.warn('LogFormatters should provide show_merge_revno '
 
225
            'instead of show_merge since bzr 0.11.',
 
226
            DeprecationWarning, stacklevel=3)
 
227
    view_revs_iter = get_view_revisions(mainline_revs, rev_nos, branch,
 
228
                          direction, include_merges=include_merges)
 
229
    if specific_fileid:
 
230
        view_revisions = _get_revisions_touching_file_id(branch,
 
231
                                                         specific_fileid,
 
232
                                                         mainline_revs,
 
233
                                                         view_revs_iter)
 
234
    else:
 
235
        view_revisions = list(view_revs_iter)
 
236
 
 
237
    def iter_revisions():
 
238
        # r = revision, n = revno, d = merge depth
 
239
        revision_ids = [r for r, n, d in view_revisions]
 
240
        zeros = set(r for r, n, d in view_revisions if d == 0)
 
241
        num = 9
 
242
        repository = branch.repository
 
243
        while revision_ids:
 
244
            cur_deltas = {}
 
245
            revisions = repository.get_revisions(revision_ids[:num])
 
246
            if verbose:
 
247
                delta_revisions = [r for r in revisions if
 
248
                                   r.revision_id in zeros]
 
249
                deltas = repository.get_deltas_for_revisions(delta_revisions)
 
250
                cur_deltas = dict(izip((r.revision_id for r in 
 
251
                                        delta_revisions), deltas))
 
252
            for revision in revisions:
 
253
                # The delta value will be None unless
 
254
                # 1. verbose is specified, and
 
255
                # 2. the revision is a mainline revision
 
256
                yield revision, cur_deltas.get(revision.revision_id)
 
257
            revision_ids  = revision_ids[num:]
 
258
            num = min(int(num * 1.5), 200)
 
259
            
 
260
    # now we just print all the revisions
 
261
    for ((rev_id, revno, merge_depth), (rev, delta)) in \
 
262
         izip(view_revisions, iter_revisions()):
 
263
 
 
264
        if searchRE:
 
265
            if not searchRE.search(rev.message):
 
266
                continue
 
267
 
 
268
        if merge_depth == 0:
 
269
            # a mainline revision.
 
270
            lf.show(revno, rev, delta)
 
271
        else:
 
272
            if show_merge_revno is None:
 
273
                lf.show_merge(rev, merge_depth)
 
274
            else:
 
275
                lf.show_merge_revno(rev, merge_depth, revno)
 
276
 
 
277
 
 
278
def _get_revisions_touching_file_id(branch, file_id, mainline_revisions,
 
279
                                    view_revs_iter):
 
280
    """Return the list of revision ids which touch a given file id.
 
281
 
 
282
    This includes the revisions which directly change the file id,
 
283
    and the revisions which merge these changes. So if the
 
284
    revision graph is::
 
285
        A
 
286
        |\
 
287
        B C
 
288
        |/
 
289
        D
 
290
 
 
291
    And 'C' changes a file, then both C and D will be returned.
 
292
 
 
293
    This will also can be restricted based on a subset of the mainline.
 
294
    """
 
295
    # find all the revisions that change the specific file
 
296
    file_weave = branch.repository.weave_store.get_weave(file_id,
 
297
                branch.repository.get_transaction())
 
298
    weave_modifed_revisions = set(file_weave.versions())
 
299
    # build the ancestry of each revision in the graph
 
300
    # - only listing the ancestors that change the specific file.
 
301
    rev_graph = branch.repository.get_revision_graph(mainline_revisions[-1])
 
302
    sorted_rev_list = topo_sort(rev_graph)
 
303
    ancestry = {}
 
304
    for rev in sorted_rev_list:
 
305
        rev_ancestry = set()
 
306
        if rev in weave_modifed_revisions:
 
307
            rev_ancestry.add(rev)
 
308
        for parent in rev_graph[rev]:
 
309
            rev_ancestry = rev_ancestry.union(ancestry[parent])
 
310
        ancestry[rev] = rev_ancestry
 
311
 
 
312
    def is_merging_rev(r):
 
313
        parents = rev_graph[r]
 
314
        if len(parents) > 1:
 
315
            leftparent = parents[0]
 
316
            for rightparent in parents[1:]:
 
317
                if not ancestry[leftparent].issuperset(
 
318
                        ancestry[rightparent]):
 
319
                    return True
 
320
        return False
 
321
 
 
322
    # filter from the view the revisions that did not change or merge 
 
323
    # the specific file
 
324
    return [(r, n, d) for r, n, d in view_revs_iter
 
325
            if r in weave_modifed_revisions or is_merging_rev(r)]
 
326
 
 
327
 
 
328
def get_view_revisions(mainline_revs, rev_nos, branch, direction,
 
329
                       include_merges=True):
 
330
    """Produce an iterator of revisions to show
 
331
    :return: an iterator of (revision_id, revno, merge_depth)
 
332
    (if there is no revno for a revision, None is supplied)
 
333
    """
 
334
    if include_merges is False:
 
335
        revision_ids = mainline_revs[1:]
 
336
        if direction == 'reverse':
 
337
            revision_ids.reverse()
 
338
        for revision_id in revision_ids:
 
339
            yield revision_id, str(rev_nos[revision_id]), 0
 
340
        return
 
341
    merge_sorted_revisions = merge_sort(
 
342
        branch.repository.get_revision_graph(mainline_revs[-1]),
 
343
        mainline_revs[-1],
 
344
        mainline_revs,
 
345
        generate_revno=True)
 
346
 
 
347
    if direction == 'forward':
 
348
        # forward means oldest first.
 
349
        merge_sorted_revisions = reverse_by_depth(merge_sorted_revisions)
 
350
    elif direction != 'reverse':
 
351
        raise ValueError('invalid direction %r' % direction)
 
352
 
 
353
    for sequence, rev_id, merge_depth, revno, end_of_merge in merge_sorted_revisions:
 
354
        yield rev_id, '.'.join(map(str, revno)), merge_depth
 
355
 
 
356
 
 
357
def reverse_by_depth(merge_sorted_revisions, _depth=0):
 
358
    """Reverse revisions by depth.
 
359
 
 
360
    Revisions with a different depth are sorted as a group with the previous
 
361
    revision of that depth.  There may be no topological justification for this,
 
362
    but it looks much nicer.
 
363
    """
 
364
    zd_revisions = []
 
365
    for val in merge_sorted_revisions:
 
366
        if val[2] == _depth:
 
367
            zd_revisions.append([val])
 
368
        else:
 
369
            assert val[2] > _depth
 
370
            zd_revisions[-1].append(val)
 
371
    for revisions in zd_revisions:
 
372
        if len(revisions) > 1:
 
373
            revisions[1:] = reverse_by_depth(revisions[1:], _depth + 1)
 
374
    zd_revisions.reverse()
 
375
    result = []
 
376
    for chunk in zd_revisions:
 
377
        result.extend(chunk)
 
378
    return result
 
379
 
 
380
 
 
381
class LogFormatter(object):
 
382
    """Abstract class to display log messages."""
 
383
 
 
384
    def __init__(self, to_file, show_ids=False, show_timezone='original'):
 
385
        self.to_file = to_file
 
386
        self.show_ids = show_ids
 
387
        self.show_timezone = show_timezone
 
388
 
 
389
    def show(self, revno, rev, delta):
 
390
        raise NotImplementedError('not implemented in abstract base')
 
391
 
 
392
    def short_committer(self, rev):
 
393
        return re.sub('<.*@.*>', '', rev.committer).strip(' ')
 
394
    
 
395
    
 
396
class LongLogFormatter(LogFormatter):
 
397
    def show(self, revno, rev, delta):
 
398
        return self._show_helper(revno=revno, rev=rev, delta=delta)
 
399
 
 
400
    @deprecated_method(zero_eleven)
 
401
    def show_merge(self, rev, merge_depth):
 
402
        return self._show_helper(rev=rev, indent='    '*merge_depth, merged=True, delta=None)
 
403
 
 
404
    def show_merge_revno(self, rev, merge_depth, revno):
 
405
        """Show a merged revision rev, with merge_depth and a revno."""
 
406
        return self._show_helper(rev=rev, revno=revno,
 
407
            indent='    '*merge_depth, merged=True, delta=None)
 
408
 
 
409
    def _show_helper(self, rev=None, revno=None, indent='', merged=False, delta=None):
 
410
        """Show a revision, either merged or not."""
 
411
        from bzrlib.osutils import format_date
 
412
        to_file = self.to_file
 
413
        print >>to_file,  indent+'-' * 60
 
414
        if revno is not None:
 
415
            print >>to_file,  indent+'revno:', revno
 
416
        if merged:
 
417
            print >>to_file,  indent+'merged:', rev.revision_id
 
418
        elif self.show_ids:
 
419
            print >>to_file,  indent+'revision-id:', rev.revision_id
 
420
        if self.show_ids:
 
421
            for parent_id in rev.parent_ids:
 
422
                print >>to_file, indent+'parent:', parent_id
 
423
        print >>to_file,  indent+'committer:', rev.committer
 
424
        try:
 
425
            print >>to_file, indent+'branch nick: %s' % \
 
426
                rev.properties['branch-nick']
 
427
        except KeyError:
 
428
            pass
 
429
        date_str = format_date(rev.timestamp,
 
430
                               rev.timezone or 0,
 
431
                               self.show_timezone)
 
432
        print >>to_file,  indent+'timestamp: %s' % date_str
 
433
 
 
434
        print >>to_file,  indent+'message:'
 
435
        if not rev.message:
 
436
            print >>to_file,  indent+'  (no message)'
 
437
        else:
 
438
            message = rev.message.rstrip('\r\n')
 
439
            for l in message.split('\n'):
 
440
                print >>to_file,  indent+'  ' + l
 
441
        if delta is not None:
 
442
            delta.show(to_file, self.show_ids)
 
443
 
 
444
 
 
445
class ShortLogFormatter(LogFormatter):
 
446
    def show(self, revno, rev, delta):
 
447
        from bzrlib.osutils import format_date
 
448
 
 
449
        to_file = self.to_file
 
450
        date_str = format_date(rev.timestamp, rev.timezone or 0,
 
451
                            self.show_timezone)
 
452
        print >>to_file, "%5s %s\t%s" % (revno, self.short_committer(rev),
 
453
                format_date(rev.timestamp, rev.timezone or 0,
 
454
                            self.show_timezone, date_fmt="%Y-%m-%d",
 
455
                           show_offset=False))
 
456
        if self.show_ids:
 
457
            print >>to_file,  '      revision-id:', rev.revision_id
 
458
        if not rev.message:
 
459
            print >>to_file,  '      (no message)'
 
460
        else:
 
461
            message = rev.message.rstrip('\r\n')
 
462
            for l in message.split('\n'):
 
463
                print >>to_file,  '      ' + l
 
464
 
 
465
        # TODO: Why not show the modified files in a shorter form as
 
466
        # well? rewrap them single lines of appropriate length
 
467
        if delta is not None:
 
468
            delta.show(to_file, self.show_ids)
 
469
        print >>to_file, ''
 
470
 
 
471
 
 
472
class LineLogFormatter(LogFormatter):
 
473
    def truncate(self, str, max_len):
 
474
        if len(str) <= max_len:
 
475
            return str
 
476
        return str[:max_len-3]+'...'
 
477
 
 
478
    def date_string(self, rev):
 
479
        from bzrlib.osutils import format_date
 
480
        return format_date(rev.timestamp, rev.timezone or 0, 
 
481
                           self.show_timezone, date_fmt="%Y-%m-%d",
 
482
                           show_offset=False)
 
483
 
 
484
    def message(self, rev):
 
485
        if not rev.message:
 
486
            return '(no message)'
 
487
        else:
 
488
            return rev.message
 
489
 
 
490
    def show(self, revno, rev, delta):
 
491
        from bzrlib.osutils import terminal_width
 
492
        print >> self.to_file, self.log_string(revno, rev, terminal_width()-1)
 
493
 
 
494
    def log_string(self, revno, rev, max_chars):
 
495
        """Format log info into one string. Truncate tail of string
 
496
        :param  revno:      revision number (int) or None.
 
497
                            Revision numbers counts from 1.
 
498
        :param  rev:        revision info object
 
499
        :param  max_chars:  maximum length of resulting string
 
500
        :return:            formatted truncated string
 
501
        """
 
502
        out = []
 
503
        if revno:
 
504
            # show revno only when is not None
 
505
            out.append("%s:" % revno)
 
506
        out.append(self.truncate(self.short_committer(rev), 20))
 
507
        out.append(self.date_string(rev))
 
508
        out.append(rev.get_summary())
 
509
        return self.truncate(" ".join(out).rstrip('\n'), max_chars)
 
510
 
 
511
 
 
512
def line_log(rev, max_chars):
 
513
    lf = LineLogFormatter(None)
 
514
    return lf.log_string(None, rev, max_chars)
 
515
 
 
516
 
 
517
class LogFormatterRegistry(registry.Registry):
 
518
    """Registry for log formatters"""
 
519
 
 
520
    def make_formatter(self, name, *args, **kwargs):
 
521
        """Construct a formatter from arguments.
 
522
 
 
523
        :param name: Name of the formatter to construct.  'short', 'long' and
 
524
            'line' are built-in.
 
525
        """
 
526
        return self.get(name)(*args, **kwargs)
 
527
 
 
528
    def get_default(self, branch):
 
529
        return self.get(branch.get_config().log_format())
 
530
 
 
531
 
 
532
log_formatter_registry = LogFormatterRegistry()
 
533
 
 
534
 
 
535
log_formatter_registry.register('short', ShortLogFormatter,
 
536
                                'Moderately short log format')
 
537
log_formatter_registry.register('long', LongLogFormatter,
 
538
                                'Detailed log format')
 
539
log_formatter_registry.register('line', LineLogFormatter,
 
540
                                'Log format with one line per revision')
 
541
 
 
542
 
 
543
def register_formatter(name, formatter):
 
544
    log_formatter_registry.register(name, formatter)
 
545
 
 
546
 
 
547
def log_formatter(name, *args, **kwargs):
 
548
    """Construct a formatter from arguments.
 
549
 
 
550
    name -- Name of the formatter to construct; currently 'long', 'short' and
 
551
        'line' are supported.
 
552
    """
 
553
    from bzrlib.errors import BzrCommandError
 
554
    try:
 
555
        return log_formatter_registry.make_formatter(name, *args, **kwargs)
 
556
    except KeyError:
 
557
        raise BzrCommandError("unknown log formatter: %r" % name)
 
558
 
 
559
 
 
560
def show_one_log(revno, rev, delta, verbose, to_file, show_timezone):
 
561
    # deprecated; for compatibility
 
562
    lf = LongLogFormatter(to_file=to_file, show_timezone=show_timezone)
 
563
    lf.show(revno, rev, delta)
 
564
 
 
565
def show_changed_revisions(branch, old_rh, new_rh, to_file=None, log_format='long'):
 
566
    """Show the change in revision history comparing the old revision history to the new one.
 
567
 
 
568
    :param branch: The branch where the revisions exist
 
569
    :param old_rh: The old revision history
 
570
    :param new_rh: The new revision history
 
571
    :param to_file: A file to write the results to. If None, stdout will be used
 
572
    """
 
573
    if to_file is None:
 
574
        import sys
 
575
        import codecs
 
576
        import bzrlib
 
577
        to_file = codecs.getwriter(bzrlib.user_encoding)(sys.stdout, errors='replace')
 
578
    lf = log_formatter(log_format,
 
579
                       show_ids=False,
 
580
                       to_file=to_file,
 
581
                       show_timezone='original')
 
582
 
 
583
    # This is the first index which is different between
 
584
    # old and new
 
585
    base_idx = None
 
586
    for i in xrange(max(len(new_rh),
 
587
                        len(old_rh))):
 
588
        if (len(new_rh) <= i
 
589
            or len(old_rh) <= i
 
590
            or new_rh[i] != old_rh[i]):
 
591
            base_idx = i
 
592
            break
 
593
 
 
594
    if base_idx is None:
 
595
        to_file.write('Nothing seems to have changed\n')
 
596
        return
 
597
    ## TODO: It might be nice to do something like show_log
 
598
    ##       and show the merged entries. But since this is the
 
599
    ##       removed revisions, it shouldn't be as important
 
600
    if base_idx < len(old_rh):
 
601
        to_file.write('*'*60)
 
602
        to_file.write('\nRemoved Revisions:\n')
 
603
        for i in range(base_idx, len(old_rh)):
 
604
            rev = branch.repository.get_revision(old_rh[i])
 
605
            lf.show(i+1, rev, None)
 
606
        to_file.write('*'*60)
 
607
        to_file.write('\n\n')
 
608
    if base_idx < len(new_rh):
 
609
        to_file.write('Added Revisions:\n')
 
610
        show_log(branch,
 
611
                 lf,
 
612
                 None,
 
613
                 verbose=True,
 
614
                 direction='forward',
 
615
                 start_revision=base_idx+1,
 
616
                 end_revision=len(new_rh),
 
617
                 search=None)
 
618