/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: Ian Clatworthy
  • Date: 2009-01-18 00:52:24 UTC
  • mto: (3964.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3965.
  • Revision ID: ian.clatworthy@canonical.com-20090118005224-rkr66k4s31mgwy0z
first cut at log --show-diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
"""
51
51
 
52
52
import codecs
 
53
from cStringIO import StringIO
53
54
from itertools import (
54
55
    izip,
55
56
    )
64
65
 
65
66
from bzrlib import (
66
67
    config,
 
68
    diff,
67
69
    errors,
68
70
    repository as _mod_repository,
69
71
    revision as _mod_revision,
144
146
             start_revision=None,
145
147
             end_revision=None,
146
148
             search=None,
147
 
             limit=None):
 
149
             limit=None,
 
150
             show_diff=False):
148
151
    """Write out human-readable log of commits to this branch.
149
152
 
150
153
    :param lf: The LogFormatter object showing the output.
166
169
 
167
170
    :param limit: If set, shows only 'limit' revisions, all revisions are shown
168
171
        if None or 0.
 
172
 
 
173
    :param show_diff: If True, output a diff after each revision.
169
174
    """
170
175
    branch.lock_read()
171
176
    try:
173
178
            lf.begin_log()
174
179
 
175
180
        _show_log(branch, lf, specific_fileid, verbose, direction,
176
 
                  start_revision, end_revision, search, limit)
 
181
                  start_revision, end_revision, search, limit, show_diff)
177
182
 
178
183
        if getattr(lf, 'end_log', None):
179
184
            lf.end_log()
189
194
             start_revision=None,
190
195
             end_revision=None,
191
196
             search=None,
192
 
             limit=None):
 
197
             limit=None,
 
198
             show_diff=False):
193
199
    """Worker function for show_log - see show_log."""
194
200
    if not isinstance(lf, LogFormatter):
195
201
        warn("not a LogFormatter instance: %r" % lf)
213
219
    generate_delta = verbose and getattr(lf, 'supports_delta', False)
214
220
 
215
221
    # now we just print all the revisions
 
222
    repo = branch.repository
216
223
    log_count = 0
217
224
    revision_iterator = make_log_rev_iterator(branch, view_revisions,
218
225
        generate_delta, search)
221
228
            lr = LogRevision(rev, revno, merge_depth, delta,
222
229
                             rev_tag_dict.get(rev_id))
223
230
            lf.log_revision(lr)
 
231
            if show_diff:
 
232
                if len(rev.parent_ids) == 0:
 
233
                    ancestor_id = _mod_revision.NULL_REVISION
 
234
                else:
 
235
                    ancestor_id = rev.parent_ids[0]
 
236
                tree_1 = repo.revision_tree(ancestor_id)
 
237
                tree_2 = repo.revision_tree(rev_id)
 
238
                s = StringIO()
 
239
                diff.show_diff_trees(tree_1, tree_2, s, old_label='', new_label='')
 
240
                lf.to_file.write("diff:\n")
 
241
                lf.to_file.write(s.getvalue() + "\n")
224
242
            if limit:
225
243
                log_count += 1
226
244
                if log_count >= limit: