/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2359.1.1 by Kent Gibson
Fix ``bzr log <file>`` so it only logs the revisions that changed the file, and does it faster.
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
369 by Martin Pool
- Split out log printing into new show_log function
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.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
369 by Martin Pool
- Split out log printing into new show_log function
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.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
369 by Martin Pool
- Split out log printing into new show_log function
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
375 by Martin Pool
- New command touching-revisions and function to trace
17
18
527 by Martin Pool
- refactor log command
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
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
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
2466.12.2 by Kent Gibson
shift log output with only merge revisions to the left margin
45
relative to its left-most parent, not the delta relative to the last
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
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.
527 by Martin Pool
- refactor log command
50
"""
51
2997.1.2 by Kent Gibson
Move all imports to top of log.py
52
import codecs
53
from itertools import (
54
    izip,
55
    )
1624.1.3 by Robert Collins
Convert log to use the new tsort.merge_sort routine.
56
import re
2997.1.2 by Kent Gibson
Move all imports to top of log.py
57
import sys
58
from warnings import (
59
    warn,
60
    )
1185.33.41 by Martin Pool
Fix regression of 'bzr log -v' - it wasn't showing changed files at all. (#4676)
61
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
62
from bzrlib.lazy_import import lazy_import
63
lazy_import(globals(), """
3535.5.1 by John Arbash Meinel
cleanup a few imports to be lazily loaded.
64
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
65
from bzrlib import (
3063.3.2 by Lukáš Lalinský
Move the name and e-mail address extraction logic to config.parse_username.
66
    config,
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
67
    errors,
3535.5.1 by John Arbash Meinel
cleanup a few imports to be lazily loaded.
68
    repository as _mod_repository,
69
    revision as _mod_revision,
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
70
    revisionspec,
3535.5.1 by John Arbash Meinel
cleanup a few imports to be lazily loaded.
71
    trace,
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
72
    tsort,
73
    )
74
""")
75
3535.5.1 by John Arbash Meinel
cleanup a few imports to be lazily loaded.
76
from bzrlib import (
2221.4.10 by Aaron Bentley
Implement log options using RegistryOption
77
    registry,
2997.1.2 by Kent Gibson
Move all imports to top of log.py
78
    )
79
from bzrlib.osutils import (
80
    format_date,
2997.1.3 by Alexander Belchenko
file wrapper around stdout should use terminal encoding, not user_encoding.
81
    get_terminal_encoding,
2997.1.2 by Kent Gibson
Move all imports to top of log.py
82
    terminal_width,
83
    )
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
84
375 by Martin Pool
- New command touching-revisions and function to trace
85
86
def find_touching_revisions(branch, file_id):
87
    """Yield a description of revisions which affect the file_id.
88
89
    Each returned element is (revno, revision_id, description)
90
91
    This is the list of revisions where the file is either added,
92
    modified, renamed or deleted.
93
94
    TODO: Perhaps some way to limit this to only particular revisions,
522 by Martin Pool
todo
95
    or to traverse a non-mainline set of revisions?
375 by Martin Pool
- New command touching-revisions and function to trace
96
    """
97
    last_ie = None
98
    last_path = None
99
    revno = 1
100
    for revision_id in branch.revision_history():
1185.67.2 by Aaron Bentley
Renamed Branch.storage to Branch.repository
101
        this_inv = branch.repository.get_revision_inventory(revision_id)
375 by Martin Pool
- New command touching-revisions and function to trace
102
        if file_id in this_inv:
103
            this_ie = this_inv[file_id]
104
            this_path = this_inv.id2path(file_id)
105
        else:
106
            this_ie = this_path = None
107
108
        # now we know how it was last time, and how it is in this revision.
109
        # are those two states effectively the same or not?
110
111
        if not this_ie and not last_ie:
112
            # not present in either
113
            pass
114
        elif this_ie and not last_ie:
115
            yield revno, revision_id, "added " + this_path
116
        elif not this_ie and last_ie:
117
            # deleted here
118
            yield revno, revision_id, "deleted " + last_path
119
        elif this_path != last_path:
120
            yield revno, revision_id, ("renamed %s => %s" % (last_path, this_path))
121
        elif (this_ie.text_size != last_ie.text_size
122
              or this_ie.text_sha1 != last_ie.text_sha1):
123
            yield revno, revision_id, "modified " + this_path
124
125
        last_ie = this_ie
126
        last_path = this_path
127
        revno += 1
128
129
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
130
def _enumerate_history(branch):
131
    rh = []
132
    revno = 1
133
    for rev_id in branch.revision_history():
134
        rh.append((revno, rev_id))
135
        revno += 1
136
    return rh
137
138
378 by Martin Pool
- New usage bzr log FILENAME
139
def show_log(branch,
794 by Martin Pool
- Merge John's nice short-log format.
140
             lf,
527 by Martin Pool
- refactor log command
141
             specific_fileid=None,
378 by Martin Pool
- New usage bzr log FILENAME
142
             verbose=False,
567 by Martin Pool
- New form 'bzr log -r FROM:TO'
143
             direction='reverse',
144
             start_revision=None,
900 by Martin Pool
- patch from john to search for matching commits
145
             end_revision=None,
2466.9.1 by Kent Gibson
add bzr log --limit
146
             search=None,
147
             limit=None):
369 by Martin Pool
- Split out log printing into new show_log function
148
    """Write out human-readable log of commits to this branch.
149
3874.2.2 by Vincent Ladeuil
Cleanup show_log doc string.
150
    :param lf: The LogFormatter object showing the output.
151
152
    :param specific_fileid: If not None, list only the commits affecting the
153
        specified file, rather than all commits.
154
155
    :param verbose: If True show added/changed/deleted/renamed files.
156
157
    :param direction: 'reverse' (default) is latest to earliest; 'forward' is
158
        earliest to latest.
159
160
    :param start_revision: If not None, only show revisions >= start_revision
161
162
    :param end_revision: If not None, only show revisions <= end_revision
163
164
    :param search: If not None, only show revisions with matching commit
165
        messages
166
167
    :param limit: If set, shows only 'limit' revisions, all revisions are shown
168
        if None or 0.
369 by Martin Pool
- Split out log printing into new show_log function
169
    """
1417.1.7 by Robert Collins
teach log it needs a read lock
170
    branch.lock_read()
171
    try:
2466.8.2 by Kent Gibson
Move begin/end calls from _show_log to show_log. Fix long line.
172
        if getattr(lf, 'begin_log', None):
173
            lf.begin_log()
174
1756.1.6 by Aaron Bentley
Revert locking fix
175
        _show_log(branch, lf, specific_fileid, verbose, direction,
2466.9.1 by Kent Gibson
add bzr log --limit
176
                  start_revision, end_revision, search, limit)
2466.8.2 by Kent Gibson
Move begin/end calls from _show_log to show_log. Fix long line.
177
178
        if getattr(lf, 'end_log', None):
179
            lf.end_log()
1417.1.7 by Robert Collins
teach log it needs a read lock
180
    finally:
181
        branch.unlock()
2490.1.2 by John Arbash Meinel
Cleanup according to PEP8 and some other small whitespace fixes
182
3302.1.1 by Aaron Bentley
Split out _iter_revision, allow view_revisions to be an iterator
183
1417.1.7 by Robert Collins
teach log it needs a read lock
184
def _show_log(branch,
185
             lf,
186
             specific_fileid=None,
187
             verbose=False,
188
             direction='reverse',
189
             start_revision=None,
190
             end_revision=None,
2466.9.1 by Kent Gibson
add bzr log --limit
191
             search=None,
192
             limit=None):
1417.1.7 by Robert Collins
teach log it needs a read lock
193
    """Worker function for show_log - see show_log."""
794 by Martin Pool
- Merge John's nice short-log format.
194
    if not isinstance(lf, LogFormatter):
195
        warn("not a LogFormatter instance: %r" % lf)
533 by Martin Pool
- fix up asking for the log for the root of a remote branch
196
197
    if specific_fileid:
3535.5.1 by John Arbash Meinel
cleanup a few imports to be lazily loaded.
198
        trace.mutter('get log for file_id %r', specific_fileid)
3302.1.2 by Aaron Bentley
Split out the major view_revision calculation logic
199
    generate_merge_revisions = getattr(lf, 'supports_merge_revisions', False)
200
    allow_single_merge_revision = getattr(lf,
201
        'supports_single_merge_revision', False)
202
    view_revisions = calculate_view_revisions(branch, start_revision,
203
                                              end_revision, direction,
204
                                              specific_fileid,
205
                                              generate_merge_revisions,
206
                                              allow_single_merge_revision)
207
    rev_tag_dict = {}
208
    generate_tags = getattr(lf, 'supports_tags', False)
209
    if generate_tags:
210
        if branch.supports_tags():
211
            rev_tag_dict = branch.tags.get_reverse_tag_dict()
212
213
    generate_delta = verbose and getattr(lf, 'supports_delta', False)
214
215
    # now we just print all the revisions
216
    log_count = 0
3642.1.5 by Robert Collins
Separate out batching of revisions.
217
    revision_iterator = make_log_rev_iterator(branch, view_revisions,
218
        generate_delta, search)
3642.1.2 by Robert Collins
Setup a log iterator that more closely matches what the code tries to do with repository operations.
219
    for revs in revision_iterator:
220
        for (rev_id, revno, merge_depth), rev, delta in revs:
221
            lr = LogRevision(rev, revno, merge_depth, delta,
222
                             rev_tag_dict.get(rev_id))
223
            lf.log_revision(lr)
224
            if limit:
225
                log_count += 1
226
                if log_count >= limit:
3660.1.1 by Robert Collins
Fix log --limit (broken by log filtering patch).
227
                    return
3302.1.2 by Aaron Bentley
Split out the major view_revision calculation logic
228
229
230
def calculate_view_revisions(branch, start_revision, end_revision, direction,
231
                             specific_fileid, generate_merge_revisions,
232
                             allow_single_merge_revision):
3842.2.4 by Vincent Ladeuil
Superficial fix for bug #300055.
233
    if (    not generate_merge_revisions
234
        and start_revision is end_revision is None
235
        and direction == 'reverse'
236
        and specific_fileid is None):
3302.1.3 by Aaron Bentley
Add optimization of the simple case of generating view revisions
237
        return _linear_view_revisions(branch)
238
3842.2.5 by Vincent Ladeuil
Better fix for bug #300055.
239
    mainline_revs, rev_nos, start_rev_id, end_rev_id = _get_mainline_revs(
240
        branch, start_revision, end_revision)
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
241
    if not mainline_revs:
3302.1.2 by Aaron Bentley
Split out the major view_revision calculation logic
242
        return []
1756.2.18 by Aaron Bentley
Factor out the revision list generation
243
2997.1.1 by Kent Gibson
Support logging single merge revisions with short and line log formatters.
244
    generate_single_revision = False
2985.1.1 by Aaron Bentley
Better behavior when user requests a log that cannot be viewed (Kent Gibson)
245
    if ((not generate_merge_revisions)
2978.3.2 by Kent Gibson
Use in rather than has_key
246
        and ((start_rev_id and (start_rev_id not in rev_nos))
247
            or (end_rev_id and (end_rev_id not in rev_nos)))):
2997.1.1 by Kent Gibson
Support logging single merge revisions with short and line log formatters.
248
        generate_single_revision = ((start_rev_id == end_rev_id)
3302.1.2 by Aaron Bentley
Split out the major view_revision calculation logic
249
            and allow_single_merge_revision)
2997.1.1 by Kent Gibson
Support logging single merge revisions with short and line log formatters.
250
        if not generate_single_revision:
3535.5.1 by John Arbash Meinel
cleanup a few imports to be lazily loaded.
251
            raise errors.BzrCommandError('Selected log formatter only supports'
252
                ' mainline revisions.')
2997.1.1 by Kent Gibson
Support logging single merge revisions with short and line log formatters.
253
        generate_merge_revisions = generate_single_revision
2359.1.1 by Kent Gibson
Fix ``bzr log <file>`` so it only logs the revisions that changed the file, and does it faster.
254
    view_revs_iter = get_view_revisions(mainline_revs, rev_nos, branch,
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
255
                          direction, include_merges=generate_merge_revisions)
3842.2.5 by Vincent Ladeuil
Better fix for bug #300055.
256
257
    if direction == 'reverse':
258
        start_rev_id, end_rev_id = end_rev_id, start_rev_id
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
259
    view_revisions = _filter_revision_range(list(view_revs_iter),
260
                                            start_rev_id,
261
                                            end_rev_id)
2997.1.1 by Kent Gibson
Support logging single merge revisions with short and line log formatters.
262
    if view_revisions and generate_single_revision:
263
        view_revisions = view_revisions[0:1]
2359.1.1 by Kent Gibson
Fix ``bzr log <file>`` so it only logs the revisions that changed the file, and does it faster.
264
    if specific_fileid:
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
265
        view_revisions = _filter_revisions_touching_file_id(branch,
3842.2.5 by Vincent Ladeuil
Better fix for bug #300055.
266
                                                            specific_fileid,
267
                                                            view_revisions)
2388.1.11 by Alexander Belchenko
changes after John's review
268
2466.12.2 by Kent Gibson
shift log output with only merge revisions to the left margin
269
    # rebase merge_depth - unless there are no revisions or 
270
    # either the first or last revision have merge_depth = 0.
271
    if view_revisions and view_revisions[0][2] and view_revisions[-1][2]:
2466.12.3 by Kent Gibson
Fix JAM's review comments for left align patch
272
        min_depth = min([d for r,n,d in view_revisions])
273
        if min_depth != 0:
2466.12.2 by Kent Gibson
shift log output with only merge revisions to the left margin
274
            view_revisions = [(r,n,d-min_depth) for r,n,d in view_revisions]
3302.1.2 by Aaron Bentley
Split out the major view_revision calculation logic
275
    return view_revisions
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
276
530 by Martin Pool
- put back verbose log support for reversed logs
277
3302.1.3 by Aaron Bentley
Add optimization of the simple case of generating view revisions
278
def _linear_view_revisions(branch):
279
    start_revno, start_revision_id = branch.last_revision_info()
280
    repo = branch.repository
281
    revision_ids = repo.iter_reverse_revision_history(start_revision_id)
282
    for num, revision_id in enumerate(revision_ids):
3302.1.4 by Aaron Bentley
Return revno as a string
283
        yield revision_id, str(start_revno - num), 0
3302.1.3 by Aaron Bentley
Add optimization of the simple case of generating view revisions
284
285
3642.1.1 by Robert Collins
Refactoring in log towards more pluggable revision selection.
286
def make_log_rev_iterator(branch, view_revisions, generate_delta, search):
287
    """Create a revision iterator for log.
288
289
    :param branch: The branch being logged.
290
    :param view_revisions: The revisions being viewed.
291
    :param generate_delta: Whether to generate a delta for each revision.
292
    :param search: A user text search string.
3642.1.7 by Robert Collins
Review feedback.
293
    :return: An iterator over lists of ((rev_id, revno, merge_depth), rev,
3642.1.2 by Robert Collins
Setup a log iterator that more closely matches what the code tries to do with repository operations.
294
        delta).
3642.1.1 by Robert Collins
Refactoring in log towards more pluggable revision selection.
295
    """
3642.1.5 by Robert Collins
Separate out batching of revisions.
296
    # Convert view_revisions into (view, None, None) groups to fit with
297
    # the standard interface here.
298
    if type(view_revisions) == list:
3642.1.7 by Robert Collins
Review feedback.
299
        # A single batch conversion is faster than many incremental ones.
300
        # As we have all the data, do a batch conversion.
3642.1.5 by Robert Collins
Separate out batching of revisions.
301
        nones = [None] * len(view_revisions)
302
        log_rev_iterator = iter([zip(view_revisions, nones, nones)])
303
    else:
304
        def _convert():
305
            for view in view_revisions:
306
                yield (view, None, None)
307
        log_rev_iterator = iter([_convert()])
3642.1.6 by Robert Collins
Make log revision filtering pluggable.
308
    for adapter in log_adapters:
309
        log_rev_iterator = adapter(branch, generate_delta, search,
310
            log_rev_iterator)
3642.1.1 by Robert Collins
Refactoring in log towards more pluggable revision selection.
311
    return log_rev_iterator
312
313
3642.1.7 by Robert Collins
Review feedback.
314
def _make_search_filter(branch, generate_delta, search, log_rev_iterator):
3642.1.1 by Robert Collins
Refactoring in log towards more pluggable revision selection.
315
    """Create a filtered iterator of log_rev_iterator matching on a regex.
316
317
    :param branch: The branch being logged.
318
    :param generate_delta: Whether to generate a delta for each revision.
319
    :param search: A user text search string.
320
    :param log_rev_iterator: An input iterator containing all revisions that
3642.1.2 by Robert Collins
Setup a log iterator that more closely matches what the code tries to do with repository operations.
321
        could be displayed, in lists.
3642.1.7 by Robert Collins
Review feedback.
322
    :return: An iterator over lists of ((rev_id, revno, merge_depth), rev,
3642.1.2 by Robert Collins
Setup a log iterator that more closely matches what the code tries to do with repository operations.
323
        delta).
3642.1.1 by Robert Collins
Refactoring in log towards more pluggable revision selection.
324
    """
325
    if search is None:
326
        return log_rev_iterator
327
    # Compile the search now to get early errors.
328
    searchRE = re.compile(search, re.IGNORECASE)
329
    return _filter_message_re(searchRE, log_rev_iterator)
330
331
332
def _filter_message_re(searchRE, log_rev_iterator):
3642.1.2 by Robert Collins
Setup a log iterator that more closely matches what the code tries to do with repository operations.
333
    for revs in log_rev_iterator:
3642.1.3 by Robert Collins
Split out delta generation from revision content reading, and structure it after message evaluation, increasing performance of log -v -m.
334
        new_revs = []
3642.1.2 by Robert Collins
Setup a log iterator that more closely matches what the code tries to do with repository operations.
335
        for (rev_id, revno, merge_depth), rev, delta in revs:
336
            if searchRE.search(rev.message):
3642.1.3 by Robert Collins
Split out delta generation from revision content reading, and structure it after message evaluation, increasing performance of log -v -m.
337
                new_revs.append(((rev_id, revno, merge_depth), rev, delta))
338
        yield new_revs
339
340
3642.1.7 by Robert Collins
Review feedback.
341
def _make_delta_filter(branch, generate_delta, search, log_rev_iterator):
3642.1.3 by Robert Collins
Split out delta generation from revision content reading, and structure it after message evaluation, increasing performance of log -v -m.
342
    """Add revision deltas to a log iterator if needed.
343
344
    :param branch: The branch being logged.
345
    :param generate_delta: Whether to generate a delta for each revision.
346
    :param search: A user text search string.
347
    :param log_rev_iterator: An input iterator containing all revisions that
348
        could be displayed, in lists.
3642.1.7 by Robert Collins
Review feedback.
349
    :return: An iterator over lists of ((rev_id, revno, merge_depth), rev,
3642.1.3 by Robert Collins
Split out delta generation from revision content reading, and structure it after message evaluation, increasing performance of log -v -m.
350
        delta).
351
    """
352
    if not generate_delta:
353
        return log_rev_iterator
354
    return _generate_deltas(branch.repository, log_rev_iterator)
355
356
357
def _generate_deltas(repository, log_rev_iterator):
3642.1.7 by Robert Collins
Review feedback.
358
    """Create deltas for each batch of revisions in log_rev_iterator."""
3642.1.3 by Robert Collins
Split out delta generation from revision content reading, and structure it after message evaluation, increasing performance of log -v -m.
359
    for revs in log_rev_iterator:
360
        revisions = [rev[1] for rev in revs]
361
        deltas = repository.get_deltas_for_revisions(revisions)
362
        revs = [(rev[0], rev[1], delta) for rev, delta in izip(revs, deltas)]
363
        yield revs
3642.1.2 by Robert Collins
Setup a log iterator that more closely matches what the code tries to do with repository operations.
364
365
3642.1.7 by Robert Collins
Review feedback.
366
def _make_revision_objects(branch, generate_delta, search, log_rev_iterator):
3642.1.4 by Robert Collins
Factor out revision object extraction from revision batching.
367
    """Extract revision objects from the repository
368
369
    :param branch: The branch being logged.
370
    :param generate_delta: Whether to generate a delta for each revision.
371
    :param search: A user text search string.
372
    :param log_rev_iterator: An input iterator containing all revisions that
373
        could be displayed, in lists.
3642.1.7 by Robert Collins
Review feedback.
374
    :return: An iterator over lists of ((rev_id, revno, merge_depth), rev,
3642.1.4 by Robert Collins
Factor out revision object extraction from revision batching.
375
        delta).
376
    """
3642.1.5 by Robert Collins
Separate out batching of revisions.
377
    repository = branch.repository
3642.1.4 by Robert Collins
Factor out revision object extraction from revision batching.
378
    for revs in log_rev_iterator:
379
        # r = revision_id, n = revno, d = merge depth
380
        revision_ids = [view[0] for view, _, _ in revs]
381
        revisions = repository.get_revisions(revision_ids)
382
        revs = [(rev[0], revision, rev[2]) for rev, revision in
383
            izip(revs, revisions)]
384
        yield revs
385
386
3642.1.7 by Robert Collins
Review feedback.
387
def _make_batch_filter(branch, generate_delta, search, log_rev_iterator):
3642.1.5 by Robert Collins
Separate out batching of revisions.
388
    """Group up a single large batch into smaller ones.
3642.1.2 by Robert Collins
Setup a log iterator that more closely matches what the code tries to do with repository operations.
389
390
    :param branch: The branch being logged.
391
    :param generate_delta: Whether to generate a delta for each revision.
392
    :param search: A user text search string.
3642.1.5 by Robert Collins
Separate out batching of revisions.
393
    :param log_rev_iterator: An input iterator containing all revisions that
394
        could be displayed, in lists.
3642.1.7 by Robert Collins
Review feedback.
395
    :return: An iterator over lists of ((rev_id, revno, merge_depth), rev, delta).
3642.1.2 by Robert Collins
Setup a log iterator that more closely matches what the code tries to do with repository operations.
396
    """
397
    repository = branch.repository
3302.1.1 by Aaron Bentley
Split out _iter_revision, allow view_revisions to be an iterator
398
    num = 9
3642.1.5 by Robert Collins
Separate out batching of revisions.
399
    for batch in log_rev_iterator:
400
        batch = iter(batch)
401
        while True:
402
            step = [detail for _, detail in zip(range(num), batch)]
403
            if len(step) == 0:
404
                break
405
            yield step
406
            num = min(int(num * 1.5), 200)
3302.1.1 by Aaron Bentley
Split out _iter_revision, allow view_revisions to be an iterator
407
408
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
409
def _get_mainline_revs(branch, start_revision, end_revision):
410
    """Get the mainline revisions from the branch.
411
    
412
    Generates the list of mainline revisions for the branch.
413
    
414
    :param  branch: The branch containing the revisions. 
415
416
    :param  start_revision: The first revision to be logged.
417
            For backwards compatibility this may be a mainline integer revno,
418
            but for merge revision support a RevisionInfo is expected.
419
420
    :param  end_revision: The last revision to be logged.
421
            For backwards compatibility this may be a mainline integer revno,
422
            but for merge revision support a RevisionInfo is expected.
423
424
    :return: A (mainline_revs, rev_nos, start_rev_id, end_rev_id) tuple.
425
    """
3449.2.1 by John Arbash Meinel
bzr uncommit doesn't need to work in terms of 'revision_history()'
426
    branch_revno, branch_last_revision = branch.last_revision_info()
427
    if branch_revno == 0:
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
428
        return None, None, None, None
429
430
    # For mainline generation, map start_revision and end_revision to 
431
    # mainline revnos. If the revision is not on the mainline choose the 
432
    # appropriate extreme of the mainline instead - the extra will be 
433
    # filtered later.
434
    # Also map the revisions to rev_ids, to be used in the later filtering
435
    # stage.
3842.2.4 by Vincent Ladeuil
Superficial fix for bug #300055.
436
    start_rev_id = None
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
437
    if start_revision is None:
438
        start_revno = 1
439
    else:
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
440
        if isinstance(start_revision, revisionspec.RevisionInfo):
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
441
            start_rev_id = start_revision.rev_id
442
            start_revno = start_revision.revno or 1
443
        else:
444
            branch.check_real_revno(start_revision)
445
            start_revno = start_revision
3842.2.4 by Vincent Ladeuil
Superficial fix for bug #300055.
446
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
447
    end_rev_id = None
448
    if end_revision is None:
3449.2.5 by John Arbash Meinel
Stop referencing the variable I removed.
449
        end_revno = branch_revno
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
450
    else:
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
451
        if isinstance(end_revision, revisionspec.RevisionInfo):
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
452
            end_rev_id = end_revision.rev_id
3449.2.5 by John Arbash Meinel
Stop referencing the variable I removed.
453
            end_revno = end_revision.revno or branch_revno
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
454
        else:
455
            branch.check_real_revno(end_revision)
456
            end_revno = end_revision
457
3535.5.1 by John Arbash Meinel
cleanup a few imports to be lazily loaded.
458
    if ((start_rev_id == _mod_revision.NULL_REVISION)
459
        or (end_rev_id == _mod_revision.NULL_REVISION)):
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
460
        raise errors.BzrCommandError('Logging revision 0 is invalid.')
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
461
    if start_revno > end_revno:
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
462
        raise errors.BzrCommandError("Start revision must be older than "
463
                                     "the end revision.")
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
464
3449.2.7 by John Arbash Meinel
Minor tweak from Ian
465
    if end_revno < start_revno:
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
466
        return None, None, None, None
3449.2.1 by John Arbash Meinel
bzr uncommit doesn't need to work in terms of 'revision_history()'
467
    cur_revno = branch_revno
468
    rev_nos = {}
469
    mainline_revs = []
470
    for revision_id in branch.repository.iter_reverse_revision_history(
471
                        branch_last_revision):
472
        if cur_revno < start_revno:
3449.2.2 by John Arbash Meinel
Fix bug #172649. Cleanup, and handle the case where we are logging to the first revision.
473
            # We have gone far enough, but we always add 1 more revision
3449.2.1 by John Arbash Meinel
bzr uncommit doesn't need to work in terms of 'revision_history()'
474
            rev_nos[revision_id] = cur_revno
475
            mainline_revs.append(revision_id)
476
            break
477
        if cur_revno <= end_revno:
478
            rev_nos[revision_id] = cur_revno
479
            mainline_revs.append(revision_id)
480
        cur_revno -= 1
3449.2.2 by John Arbash Meinel
Fix bug #172649. Cleanup, and handle the case where we are logging to the first revision.
481
    else:
482
        # We walked off the edge of all revisions, so we add a 'None' marker
483
        mainline_revs.append(None)
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
484
3449.2.1 by John Arbash Meinel
bzr uncommit doesn't need to work in terms of 'revision_history()'
485
    mainline_revs.reverse()
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
486
487
    # override the mainline to look like the revision history.
488
    return mainline_revs, rev_nos, start_rev_id, end_rev_id
489
490
491
def _filter_revision_range(view_revisions, start_rev_id, end_rev_id):
492
    """Filter view_revisions based on revision ranges.
493
494
    :param view_revisions: A list of (revision_id, dotted_revno, merge_depth) 
495
            tuples to be filtered.
496
497
    :param start_rev_id: If not NONE specifies the first revision to be logged.
498
            If NONE then all revisions up to the end_rev_id are logged.
499
500
    :param end_rev_id: If not NONE specifies the last revision to be logged.
501
            If NONE then all revisions up to the end of the log are logged.
502
503
    :return: The filtered view_revisions.
504
    """
3842.2.4 by Vincent Ladeuil
Superficial fix for bug #300055.
505
    if start_rev_id or end_rev_id:
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
506
        revision_ids = [r for r, n, d in view_revisions]
507
        if start_rev_id:
508
            start_index = revision_ids.index(start_rev_id)
509
        else:
510
            start_index = 0
511
        if start_rev_id == end_rev_id:
512
            end_index = start_index
513
        else:
514
            if end_rev_id:
515
                end_index = revision_ids.index(end_rev_id)
516
            else:
517
                end_index = len(view_revisions) - 1
518
        # To include the revisions merged into the last revision, 
519
        # extend end_rev_id down to, but not including, the next rev
520
        # with the same or lesser merge_depth
521
        end_merge_depth = view_revisions[end_index][2]
522
        try:
523
            for index in xrange(end_index+1, len(view_revisions)+1):
524
                if view_revisions[index][2] <= end_merge_depth:
525
                    end_index = index - 1
526
                    break
527
        except IndexError:
528
            # if the search falls off the end then log to the end as well
529
            end_index = len(view_revisions) - 1
530
        view_revisions = view_revisions[start_index:end_index+1]
531
    return view_revisions
532
533
3842.2.5 by Vincent Ladeuil
Better fix for bug #300055.
534
def _filter_revisions_touching_file_id(branch, file_id, view_revisions):
3711.3.23 by John Arbash Meinel
Documentation and cleanup.
535
    r"""Return the list of revision ids which touch a given file id.
2359.1.4 by John Arbash Meinel
Refactor the specific revisions for file id into a helper function.
536
2466.12.1 by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions.
537
    The function filters view_revisions and returns a subset.
2359.1.4 by John Arbash Meinel
Refactor the specific revisions for file id into a helper function.
538
    This includes the revisions which directly change the file id,
539
    and the revisions which merge these changes. So if the
540
    revision graph is::
3711.3.23 by John Arbash Meinel
Documentation and cleanup.
541
        A-.
542
        |\ \
543
        B C E
544
        |/ /
545
        D |
546
        |\|
547
        | F
2359.1.4 by John Arbash Meinel
Refactor the specific revisions for file id into a helper function.
548
        |/
3711.3.23 by John Arbash Meinel
Documentation and cleanup.
549
        G
550
551
    And 'C' changes a file, then both C and D will be returned. F will not be
552
    returned even though it brings the changes to C into the branch starting
553
    with E. (Note that if we were using F as the tip instead of G, then we
554
    would see C, D, F.)
555
556
    This will also be restricted based on a subset of the mainline.
557
558
    :param branch: The branch where we can get text revision information.
3842.2.5 by Vincent Ladeuil
Better fix for bug #300055.
559
3711.3.23 by John Arbash Meinel
Documentation and cleanup.
560
    :param file_id: Filter out revisions that do not touch file_id.
3842.2.5 by Vincent Ladeuil
Better fix for bug #300055.
561
3711.3.23 by John Arbash Meinel
Documentation and cleanup.
562
    :param view_revisions: A list of (revision_id, dotted_revno, merge_depth)
563
        tuples. This is the list of revisions which will be filtered. It is
3842.2.5 by Vincent Ladeuil
Better fix for bug #300055.
564
        assumed that view_revisions is in merge_sort order (i.e. newest
565
        revision first ).
566
2359.1.8 by John Arbash Meinel
doc
567
    :return: A list of (revision_id, dotted_revno, merge_depth) tuples.
2359.1.4 by John Arbash Meinel
Refactor the specific revisions for file id into a helper function.
568
    """
3711.3.23 by John Arbash Meinel
Documentation and cleanup.
569
    # Lookup all possible text keys to determine which ones actually modified
570
    # the file.
571
    text_keys = [(file_id, rev_id) for rev_id, revno, depth in view_revisions]
3711.3.16 by John Arbash Meinel
Doc update.
572
    # Looking up keys in batches of 1000 can cut the time in half, as well as
573
    # memory consumption. GraphIndex *does* like to look for a few keys in
574
    # parallel, it just doesn't like looking for *lots* of keys in parallel.
3711.3.19 by John Arbash Meinel
Add a TODO discussing how our index requests should evolve.
575
    # TODO: This code needs to be re-evaluated periodically as we tune the
576
    #       indexing layer. We might consider passing in hints as to the known
577
    #       access pattern (sparse/clustered, high success rate/low success
578
    #       rate). This particular access is clustered with a low success rate.
3711.3.15 by John Arbash Meinel
Work around GraphIndex inefficiencies by requesting keys 1000 at a time.
579
    get_parent_map = branch.repository.texts.get_parent_map
580
    modified_text_revisions = set()
581
    chunk_size = 1000
582
    for start in xrange(0, len(text_keys), chunk_size):
583
        next_keys = text_keys[start:start + chunk_size]
3711.3.23 by John Arbash Meinel
Documentation and cleanup.
584
        # Only keep the revision_id portion of the key
3711.3.15 by John Arbash Meinel
Work around GraphIndex inefficiencies by requesting keys 1000 at a time.
585
        modified_text_revisions.update(
586
            [k[1] for k in get_parent_map(next_keys)])
587
    del text_keys, next_keys
3711.3.14 by John Arbash Meinel
Change the per-file log algorithm dramatically.
588
589
    result = []
590
    # Track what revisions will merge the current revision, replace entries
591
    # with 'None' when they have been added to result
592
    current_merge_stack = [None]
3711.3.23 by John Arbash Meinel
Documentation and cleanup.
593
    for info in view_revisions:
3711.3.14 by John Arbash Meinel
Change the per-file log algorithm dramatically.
594
        rev_id, revno, depth = info
595
        if depth == len(current_merge_stack):
596
            current_merge_stack.append(info)
597
        else:
598
            del current_merge_stack[depth + 1:]
599
            current_merge_stack[-1] = info
600
601
        if rev_id in modified_text_revisions:
602
            # This needs to be logged, along with the extra revisions
603
            for idx in xrange(len(current_merge_stack)):
604
                node = current_merge_stack[idx]
605
                if node is not None:
606
                    result.append(node)
607
                    current_merge_stack[idx] = None
3711.3.4 by John Arbash Meinel
Significantly faster, but consuming more memory.
608
    return result
2359.1.4 by John Arbash Meinel
Refactor the specific revisions for file id into a helper function.
609
610
1756.2.20 by Aaron Bentley
Optimize log formats that don't show merges
611
def get_view_revisions(mainline_revs, rev_nos, branch, direction,
1756.2.22 by Aaron Bentley
Apply review comments
612
                       include_merges=True):
1756.2.18 by Aaron Bentley
Factor out the revision list generation
613
    """Produce an iterator of revisions to show
614
    :return: an iterator of (revision_id, revno, merge_depth)
615
    (if there is no revno for a revision, None is supplied)
616
    """
1756.2.22 by Aaron Bentley
Apply review comments
617
    if include_merges is False:
1756.2.20 by Aaron Bentley
Optimize log formats that don't show merges
618
        revision_ids = mainline_revs[1:]
619
        if direction == 'reverse':
620
            revision_ids.reverse()
621
        for revision_id in revision_ids:
1988.4.2 by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions,
622
            yield revision_id, str(rev_nos[revision_id]), 0
1756.2.20 by Aaron Bentley
Optimize log formats that don't show merges
623
        return
3287.6.1 by Robert Collins
* ``VersionedFile.get_graph`` is deprecated, with no replacement method.
624
    graph = branch.repository.get_graph()
625
    # This asks for all mainline revisions, which means we only have to spider
626
    # sideways, rather than depth history. That said, its still size-of-history
627
    # and should be addressed.
3373.5.4 by John Arbash Meinel
Track down another bogus location. Only triggered with --long
628
    # mainline_revisions always includes an extra revision at the beginning, so
629
    # don't request it.
3287.6.8 by Robert Collins
Reduce code duplication as per review.
630
    parent_map = dict(((key, value) for key, value in
3373.5.4 by John Arbash Meinel
Track down another bogus location. Only triggered with --long
631
        graph.iter_ancestry(mainline_revs[1:]) if value is not None))
3287.6.1 by Robert Collins
* ``VersionedFile.get_graph`` is deprecated, with no replacement method.
632
    # filter out ghosts; merge_sort errors on ghosts.
3535.5.1 by John Arbash Meinel
cleanup a few imports to be lazily loaded.
633
    rev_graph = _mod_repository._strip_NULL_ghosts(parent_map)
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
634
    merge_sorted_revisions = tsort.merge_sort(
3287.6.1 by Robert Collins
* ``VersionedFile.get_graph`` is deprecated, with no replacement method.
635
        rev_graph,
1756.2.18 by Aaron Bentley
Factor out the revision list generation
636
        mainline_revs[-1],
1988.4.2 by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions,
637
        mainline_revs,
638
        generate_revno=True)
1756.2.18 by Aaron Bentley
Factor out the revision list generation
639
640
    if direction == 'forward':
641
        # forward means oldest first.
1756.2.25 by Aaron Bentley
Sort revisions at each depth, instead of just mainline revisions.
642
        merge_sorted_revisions = reverse_by_depth(merge_sorted_revisions)
1756.2.18 by Aaron Bentley
Factor out the revision list generation
643
    elif direction != 'reverse':
644
        raise ValueError('invalid direction %r' % direction)
645
3677.1.4 by Vincent Ladeuil
Replace 'reverse' by 'backward' when talking about revision order.
646
    for sequence, rev_id, merge_depth, revno, end_of_merge in merge_sorted_revisions:
1988.4.2 by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions,
647
        yield rev_id, '.'.join(map(str, revno)), merge_depth
1756.2.18 by Aaron Bentley
Factor out the revision list generation
648
649
1756.2.25 by Aaron Bentley
Sort revisions at each depth, instead of just mainline revisions.
650
def reverse_by_depth(merge_sorted_revisions, _depth=0):
651
    """Reverse revisions by depth.
1756.2.24 by Aaron Bentley
Forward sorting shows merges under mainline revision
652
1756.2.25 by Aaron Bentley
Sort revisions at each depth, instead of just mainline revisions.
653
    Revisions with a different depth are sorted as a group with the previous
654
    revision of that depth.  There may be no topological justification for this,
1756.2.24 by Aaron Bentley
Forward sorting shows merges under mainline revision
655
    but it looks much nicer.
656
    """
3842.2.6 by Vincent Ladeuil
Fix typo.
657
    # Add a fake revision at start so that we can always attach sub revisions
3842.2.4 by Vincent Ladeuil
Superficial fix for bug #300055.
658
    merge_sorted_revisions = [(None, None, _depth)] + merge_sorted_revisions
1756.2.24 by Aaron Bentley
Forward sorting shows merges under mainline revision
659
    zd_revisions = []
660
    for val in merge_sorted_revisions:
1756.2.25 by Aaron Bentley
Sort revisions at each depth, instead of just mainline revisions.
661
        if val[2] == _depth:
3842.2.4 by Vincent Ladeuil
Superficial fix for bug #300055.
662
            # Each revision at the current depth becomes a chunk grouping all
663
            # higher depth revisions.
1756.2.24 by Aaron Bentley
Forward sorting shows merges under mainline revision
664
            zd_revisions.append([val])
665
        else:
666
            zd_revisions[-1].append(val)
1756.2.25 by Aaron Bentley
Sort revisions at each depth, instead of just mainline revisions.
667
    for revisions in zd_revisions:
668
        if len(revisions) > 1:
3842.2.4 by Vincent Ladeuil
Superficial fix for bug #300055.
669
            # We have higher depth revisions, let reverse them locally
1756.2.25 by Aaron Bentley
Sort revisions at each depth, instead of just mainline revisions.
670
            revisions[1:] = reverse_by_depth(revisions[1:], _depth + 1)
1756.2.24 by Aaron Bentley
Forward sorting shows merges under mainline revision
671
    zd_revisions.reverse()
672
    result = []
673
    for chunk in zd_revisions:
674
        result.extend(chunk)
3842.2.4 by Vincent Ladeuil
Superficial fix for bug #300055.
675
    if _depth == 0:
676
        # Top level call, get rid of the fake revisions that have been added
677
        result = [r for r in result if r[0] is not None and r[1] is not None]
1756.2.24 by Aaron Bentley
Forward sorting shows merges under mainline revision
678
    return result
679
680
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
681
class LogRevision(object):
682
    """A revision to be logged (by LogFormatter.log_revision).
683
684
    A simple wrapper for the attributes of a revision to be logged.
685
    The attributes may or may not be populated, as determined by the 
686
    logging options and the log formatter capabilities.
687
    """
688
2490.1.2 by John Arbash Meinel
Cleanup according to PEP8 and some other small whitespace fixes
689
    def __init__(self, rev=None, revno=None, merge_depth=0, delta=None,
690
                 tags=None):
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
691
        self.rev = rev
692
        self.revno = revno
693
        self.merge_depth = merge_depth
694
        self.delta = delta
695
        self.tags = tags
696
697
794 by Martin Pool
- Merge John's nice short-log format.
698
class LogFormatter(object):
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
699
    """Abstract class to display log messages.
700
701
    At a minimum, a derived class must implement the log_revision method.
702
703
    If the LogFormatter needs to be informed of the beginning or end of
704
    a log it should implement the begin_log and/or end_log hook methods.
705
706
    A LogFormatter should define the following supports_XXX flags 
707
    to indicate which LogRevision attributes it supports:
708
709
    - supports_delta must be True if this log formatter supports delta.
710
        Otherwise the delta attribute may not be populated.
711
    - supports_merge_revisions must be True if this log formatter supports 
2997.1.1 by Kent Gibson
Support logging single merge revisions with short and line log formatters.
712
        merge revisions.  If not, and if supports_single_merge_revisions is
713
        also not True, then only mainline revisions will be passed to the 
714
        formatter.
715
    - supports_single_merge_revision must be True if this log formatter
716
        supports logging only a single merge revision.  This flag is
717
        only relevant if supports_merge_revisions is not True.
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
718
    - supports_tags must be True if this log formatter supports tags.
719
        Otherwise the tags attribute may not be populated.
3144.7.1 by Guillermo Gonzalez
* added show_properties to LonLogFormat and the hooks to register custom functions
720
721
    Plugins can register functions to show custom revision properties using
3144.7.13 by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring
722
    the properties_handler_registry. The registered function
3144.7.1 by Guillermo Gonzalez
* added show_properties to LonLogFormat and the hooks to register custom functions
723
    must respect the following interface description:
3144.7.2 by Guillermo Gonzalez
* cleanup a bit the interface
724
        def my_show_properties(properties_dict):
725
            # code that returns a dict {'name':'value'} of the properties 
726
            # to be shown
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
727
    """
1704.2.20 by Martin Pool
log --line shows revision numbers (Alexander)
728
2388.1.8 by Erik Bagfors
Redo based on input from Alexander
729
    def __init__(self, to_file, show_ids=False, show_timezone='original'):
794 by Martin Pool
- Merge John's nice short-log format.
730
        self.to_file = to_file
731
        self.show_ids = show_ids
732
        self.show_timezone = show_timezone
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
733
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
734
# TODO: uncomment this block after show() has been removed.
735
# Until then defining log_revision would prevent _show_log calling show() 
736
# in legacy formatters.
737
#    def log_revision(self, revision):
738
#        """Log a revision.
739
#
740
#        :param  revision:   The LogRevision to be logged.
741
#        """
742
#        raise NotImplementedError('not implemented in abstract base')
743
1185.35.19 by Aaron Bentley
Tweaked short-log as Meinel suggested
744
    def short_committer(self, rev):
3063.3.2 by Lukáš Lalinský
Move the name and e-mail address extraction logic to config.parse_username.
745
        name, address = config.parse_username(rev.committer)
746
        if name:
3063.3.1 by Lukáš Lalinský
Fall back to showing e-mail in ``log --short/--line`` if the committer/author has only e-mail.
747
            return name
3063.3.2 by Lukáš Lalinský
Move the name and e-mail address extraction logic to config.parse_username.
748
        return address
2388.1.11 by Alexander Belchenko
changes after John's review
749
2671.5.4 by Lukáš Lalinsky
Replace the committer with the author in log, the committer is displayed only in the long format and only if it's different from the author.
750
    def short_author(self, rev):
3063.3.2 by Lukáš Lalinský
Move the name and e-mail address extraction logic to config.parse_username.
751
        name, address = config.parse_username(rev.get_apparent_author())
752
        if name:
3063.3.1 by Lukáš Lalinský
Fall back to showing e-mail in ``log --short/--line`` if the committer/author has only e-mail.
753
            return name
3063.3.2 by Lukáš Lalinský
Move the name and e-mail address extraction logic to config.parse_username.
754
        return address
2671.5.4 by Lukáš Lalinsky
Replace the committer with the author in log, the committer is displayed only in the long format and only if it's different from the author.
755
3144.7.9 by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors
756
    def show_properties(self, revision, indent):
3144.7.8 by Guillermo Gonzalez
* added error handling (and logging) to LogFormatter.show_properties when a handler raise an error
757
        """Displays the custom properties returned by each registered handler.
758
        
3144.7.13 by Guillermo Gonzalez
* fixed typo LogFormatter.show_properties in docstring
759
        If a registered handler raises an error it is propagated.
3144.7.5 by Guillermo Gonzalez
* some improvements to the doctstring in show_properties method and in LogFormatter
760
        """
3144.7.9 by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors
761
        for key, handler in properties_handler_registry.iteritems():
762
            for key, value in handler(revision).items():
763
                self.to_file.write(indent + key + ': ' + value + '\n')
3144.7.8 by Guillermo Gonzalez
* added error handling (and logging) to LogFormatter.show_properties when a handler raise an error
764
2388.1.11 by Alexander Belchenko
changes after John's review
765
794 by Martin Pool
- Merge John's nice short-log format.
766
class LongLogFormatter(LogFormatter):
2388.1.11 by Alexander Belchenko
changes after John's review
767
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
768
    supports_merge_revisions = True
769
    supports_delta = True
770
    supports_tags = True
2388.1.10 by Alexander Belchenko
Slightly reworked: use None instead of [] as default tags list; PEP-8
771
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
772
    def log_revision(self, revision):
773
        """Log a revision, either merged or not."""
2671.2.5 by Lukáš Lalinský
Fixes for comments from the mailing list.
774
        indent = '    ' * revision.merge_depth
1433 by Robert Collins
merge in and make incremental Gustavo Niemeyers nested log patch, and remove all bare exceptions in store and transport packages.
775
        to_file = self.to_file
2911.6.1 by Blake Winton
Change 'print >> f,'s to 'f.write('s.
776
        to_file.write(indent + '-' * 60 + '\n')
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
777
        if revision.revno is not None:
2911.6.3 by Blake Winton
Implemented suggestions from John Arbash Meinel.
778
            to_file.write(indent + 'revno: %s\n' % (revision.revno,))
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
779
        if revision.tags:
2911.6.1 by Blake Winton
Change 'print >> f,'s to 'f.write('s.
780
            to_file.write(indent + 'tags: %s\n' % (', '.join(revision.tags)))
1433 by Robert Collins
merge in and make incremental Gustavo Niemeyers nested log patch, and remove all bare exceptions in store and transport packages.
781
        if self.show_ids:
3257.2.1 by Adeodato Simó
Add a space after "revision-id:" in log output.
782
            to_file.write(indent + 'revision-id: ' + revision.rev.revision_id)
2911.6.1 by Blake Winton
Change 'print >> f,'s to 'f.write('s.
783
            to_file.write('\n')
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
784
            for parent_id in revision.rev.parent_ids:
2911.6.3 by Blake Winton
Implemented suggestions from John Arbash Meinel.
785
                to_file.write(indent + 'parent: %s\n' % (parent_id,))
3144.7.11 by Guillermo Gonzalez
* updates LongLogFormatter to pass revision instead of the properties dict to show_properties method
786
        self.show_properties(revision.rev, indent)
2671.2.2 by Lukáš Lalinský
Move setting of the author revision property to MutableTree.commit. Don't use try/except KeyError in LongLogFormatter to display authors and branch-nicks. Removed warning about missing e-mail in the authors name.
787
2671.5.7 by Lukáš Lalinsky
Rename get_author to get_apparent_author, revert the long log back to displaying the committer.
788
        author = revision.rev.properties.get('author', None)
789
        if author is not None:
2911.6.3 by Blake Winton
Implemented suggestions from John Arbash Meinel.
790
            to_file.write(indent + 'author: %s\n' % (author,))
791
        to_file.write(indent + 'committer: %s\n' % (revision.rev.committer,))
2671.2.2 by Lukáš Lalinský
Move setting of the author revision property to MutableTree.commit. Don't use try/except KeyError in LongLogFormatter to display authors and branch-nicks. Removed warning about missing e-mail in the authors name.
792
793
        branch_nick = revision.rev.properties.get('branch-nick', None)
794
        if branch_nick is not None:
2911.6.3 by Blake Winton
Implemented suggestions from John Arbash Meinel.
795
            to_file.write(indent + 'branch nick: %s\n' % (branch_nick,))
2671.2.2 by Lukáš Lalinský
Move setting of the author revision property to MutableTree.commit. Don't use try/except KeyError in LongLogFormatter to display authors and branch-nicks. Removed warning about missing e-mail in the authors name.
796
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
797
        date_str = format_date(revision.rev.timestamp,
798
                               revision.rev.timezone or 0,
1433 by Robert Collins
merge in and make incremental Gustavo Niemeyers nested log patch, and remove all bare exceptions in store and transport packages.
799
                               self.show_timezone)
2911.6.3 by Blake Winton
Implemented suggestions from John Arbash Meinel.
800
        to_file.write(indent + 'timestamp: %s\n' % (date_str,))
1433 by Robert Collins
merge in and make incremental Gustavo Niemeyers nested log patch, and remove all bare exceptions in store and transport packages.
801
2911.6.1 by Blake Winton
Change 'print >> f,'s to 'f.write('s.
802
        to_file.write(indent + 'message:\n')
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
803
        if not revision.rev.message:
2911.6.1 by Blake Winton
Change 'print >> f,'s to 'f.write('s.
804
            to_file.write(indent + '  (no message)\n')
1433 by Robert Collins
merge in and make incremental Gustavo Niemeyers nested log patch, and remove all bare exceptions in store and transport packages.
805
        else:
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
806
            message = revision.rev.message.rstrip('\r\n')
1185.31.20 by John Arbash Meinel
Stripping trailing newlines when displaying log messages
807
            for l in message.split('\n'):
2911.6.3 by Blake Winton
Implemented suggestions from John Arbash Meinel.
808
                to_file.write(indent + '  %s\n' % (l,))
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
809
        if revision.delta is not None:
2466.11.1 by Kent Gibson
Long log format reports deltas on merge revisions.
810
            revision.delta.show(to_file, self.show_ids, indent=indent)
794 by Martin Pool
- Merge John's nice short-log format.
811
812
813
class ShortLogFormatter(LogFormatter):
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
814
815
    supports_delta = True
2997.1.1 by Kent Gibson
Support logging single merge revisions with short and line log formatters.
816
    supports_single_merge_revision = True
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
817
818
    def log_revision(self, revision):
794 by Martin Pool
- Merge John's nice short-log format.
819
        to_file = self.to_file
2483.2.2 by John Arbash Meinel
Add [merge] after the timestamp for revisions with merges.
820
        is_merge = ''
2483.2.5 by John Arbash Meinel
[merge] bzr.dev 2501
821
        if len(revision.rev.parent_ids) > 1:
2483.2.2 by John Arbash Meinel
Add [merge] after the timestamp for revisions with merges.
822
            is_merge = ' [merge]'
2911.6.1 by Blake Winton
Change 'print >> f,'s to 'f.write('s.
823
        to_file.write("%5s %s\t%s%s\n" % (revision.revno,
2671.5.4 by Lukáš Lalinsky
Replace the committer with the author in log, the committer is displayed only in the long format and only if it's different from the author.
824
                self.short_author(revision.rev),
2483.2.5 by John Arbash Meinel
[merge] bzr.dev 2501
825
                format_date(revision.rev.timestamp,
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
826
                            revision.rev.timezone or 0,
1185.35.19 by Aaron Bentley
Tweaked short-log as Meinel suggested
827
                            self.show_timezone, date_fmt="%Y-%m-%d",
2483.2.5 by John Arbash Meinel
[merge] bzr.dev 2501
828
                            show_offset=False),
2911.6.1 by Blake Winton
Change 'print >> f,'s to 'f.write('s.
829
                is_merge))
794 by Martin Pool
- Merge John's nice short-log format.
830
        if self.show_ids:
2911.6.3 by Blake Winton
Implemented suggestions from John Arbash Meinel.
831
            to_file.write('      revision-id:%s\n' % (revision.rev.revision_id,))
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
832
        if not revision.rev.message:
2911.6.1 by Blake Winton
Change 'print >> f,'s to 'f.write('s.
833
            to_file.write('      (no message)\n')
794 by Martin Pool
- Merge John's nice short-log format.
834
        else:
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
835
            message = revision.rev.message.rstrip('\r\n')
1185.31.20 by John Arbash Meinel
Stripping trailing newlines when displaying log messages
836
            for l in message.split('\n'):
2911.6.3 by Blake Winton
Implemented suggestions from John Arbash Meinel.
837
                to_file.write('      %s\n' % (l,))
794 by Martin Pool
- Merge John's nice short-log format.
838
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
839
        # TODO: Why not show the modified files in a shorter form as
840
        # well? rewrap them single lines of appropriate length
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
841
        if revision.delta is not None:
842
            revision.delta.show(to_file, self.show_ids)
2911.6.1 by Blake Winton
Change 'print >> f,'s to 'f.write('s.
843
        to_file.write('\n')
794 by Martin Pool
- Merge John's nice short-log format.
844
1704.2.20 by Martin Pool
log --line shows revision numbers (Alexander)
845
1185.12.25 by Aaron Bentley
Added one-line log format
846
class LineLogFormatter(LogFormatter):
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
847
2997.1.1 by Kent Gibson
Support logging single merge revisions with short and line log formatters.
848
    supports_single_merge_revision = True
849
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
850
    def __init__(self, *args, **kwargs):
851
        super(LineLogFormatter, self).__init__(*args, **kwargs)
852
        self._max_chars = terminal_width() - 1
853
1185.12.25 by Aaron Bentley
Added one-line log format
854
    def truncate(self, str, max_len):
855
        if len(str) <= max_len:
856
            return str
857
        return str[:max_len-3]+'...'
858
859
    def date_string(self, rev):
3842.2.4 by Vincent Ladeuil
Superficial fix for bug #300055.
860
        return format_date(rev.timestamp, rev.timezone or 0,
1185.12.25 by Aaron Bentley
Added one-line log format
861
                           self.show_timezone, date_fmt="%Y-%m-%d",
862
                           show_offset=False)
863
864
    def message(self, rev):
865
        if not rev.message:
866
            return '(no message)'
867
        else:
868
            return rev.message
869
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
870
    def log_revision(self, revision):
2911.6.1 by Blake Winton
Change 'print >> f,'s to 'f.write('s.
871
        self.to_file.write(self.log_string(revision.revno, revision.rev,
872
                                              self._max_chars))
873
        self.to_file.write('\n')
2466.8.1 by Kent Gibson
Reworked LogFormatter API to simplify extending the attributes of the revision being logged. Added support for begin_log() and end_log() hooks in LogFormatters.
874
1704.2.20 by Martin Pool
log --line shows revision numbers (Alexander)
875
    def log_string(self, revno, rev, max_chars):
876
        """Format log info into one string. Truncate tail of string
3677.1.1 by Vincent Ladeuil
Begin fixing bug #233817.
877
        :param  revno:      revision number or None.
1704.2.20 by Martin Pool
log --line shows revision numbers (Alexander)
878
                            Revision numbers counts from 1.
879
        :param  rev:        revision info object
880
        :param  max_chars:  maximum length of resulting string
881
        :return:            formatted truncated string
882
        """
883
        out = []
884
        if revno:
885
            # show revno only when is not None
1988.4.2 by Robert Collins
``bzr log`` Now shows dotted-decimal revision numbers for all revisions,
886
            out.append("%s:" % revno)
2671.5.4 by Lukáš Lalinsky
Replace the committer with the author in log, the committer is displayed only in the long format and only if it's different from the author.
887
        out.append(self.truncate(self.short_author(rev), 20))
1185.12.25 by Aaron Bentley
Added one-line log format
888
        out.append(self.date_string(rev))
1740.2.5 by Aaron Bentley
Merge from bzr.dev
889
        out.append(rev.get_summary())
1185.12.25 by Aaron Bentley
Added one-line log format
890
        return self.truncate(" ".join(out).rstrip('\n'), max_chars)
794 by Martin Pool
- Merge John's nice short-log format.
891
1704.2.20 by Martin Pool
log --line shows revision numbers (Alexander)
892
1185.12.27 by Aaron Bentley
Use line log for pending merges
893
def line_log(rev, max_chars):
894
    lf = LineLogFormatter(None)
1704.2.20 by Martin Pool
log --line shows revision numbers (Alexander)
895
    return lf.log_string(None, rev, max_chars)
1185.12.27 by Aaron Bentley
Use line log for pending merges
896
2221.4.10 by Aaron Bentley
Implement log options using RegistryOption
897
898
class LogFormatterRegistry(registry.Registry):
899
    """Registry for log formatters"""
900
901
    def make_formatter(self, name, *args, **kwargs):
902
        """Construct a formatter from arguments.
903
904
        :param name: Name of the formatter to construct.  'short', 'long' and
905
            'line' are built-in.
906
        """
907
        return self.get(name)(*args, **kwargs)
908
909
    def get_default(self, branch):
910
        return self.get(branch.get_config().log_format())
911
912
913
log_formatter_registry = LogFormatterRegistry()
914
915
916
log_formatter_registry.register('short', ShortLogFormatter,
917
                                'Moderately short log format')
918
log_formatter_registry.register('long', LongLogFormatter,
919
                                'Detailed log format')
920
log_formatter_registry.register('line', LineLogFormatter,
921
                                'Log format with one line per revision')
922
794 by Martin Pool
- Merge John's nice short-log format.
923
1553.2.1 by Erik Bågfors
Support for plugins to register log formatters and set default formatter
924
def register_formatter(name, formatter):
2221.4.10 by Aaron Bentley
Implement log options using RegistryOption
925
    log_formatter_registry.register(name, formatter)
926
1553.2.1 by Erik Bågfors
Support for plugins to register log formatters and set default formatter
927
794 by Martin Pool
- Merge John's nice short-log format.
928
def log_formatter(name, *args, **kwargs):
1393.1.56 by Martin Pool
- doc and small refactoring of log code
929
    """Construct a formatter from arguments.
930
1185.12.27 by Aaron Bentley
Use line log for pending merges
931
    name -- Name of the formatter to construct; currently 'long', 'short' and
932
        'line' are supported.
1393.1.56 by Martin Pool
- doc and small refactoring of log code
933
    """
794 by Martin Pool
- Merge John's nice short-log format.
934
    try:
2221.4.10 by Aaron Bentley
Implement log options using RegistryOption
935
        return log_formatter_registry.make_formatter(name, *args, **kwargs)
1553.2.2 by Erik Bågfors
Made "unknown log formatter" error message work
936
    except KeyError:
3224.5.1 by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop.
937
        raise errors.BzrCommandError("unknown log formatter: %r" % name)
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
938
2221.4.10 by Aaron Bentley
Implement log options using RegistryOption
939
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
940
def show_one_log(revno, rev, delta, verbose, to_file, show_timezone):
1759.2.1 by Jelmer Vernooij
Fix some types (found using aspell).
941
    # deprecated; for compatibility
974.1.26 by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472
942
    lf = LongLogFormatter(to_file=to_file, show_timezone=show_timezone)
943
    lf.show(revno, rev, delta)
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
944
2490.1.4 by John Arbash Meinel
Update bzrlib.log.show_changed_revisions to use the new api
945
1551.17.2 by Aaron Bentley
Stop showing deltas in pull -v output
946
def show_changed_revisions(branch, old_rh, new_rh, to_file=None,
947
                           log_format='long'):
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
948
    """Show the change in revision history comparing the old revision history to the new one.
949
950
    :param branch: The branch where the revisions exist
951
    :param old_rh: The old revision history
952
    :param new_rh: The new revision history
953
    :param to_file: A file to write the results to. If None, stdout will be used
954
    """
955
    if to_file is None:
2997.1.3 by Alexander Belchenko
file wrapper around stdout should use terminal encoding, not user_encoding.
956
        to_file = codecs.getwriter(get_terminal_encoding())(sys.stdout,
957
            errors='replace')
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
958
    lf = log_formatter(log_format,
959
                       show_ids=False,
960
                       to_file=to_file,
961
                       show_timezone='original')
962
963
    # This is the first index which is different between
964
    # old and new
965
    base_idx = None
966
    for i in xrange(max(len(new_rh),
967
                        len(old_rh))):
968
        if (len(new_rh) <= i
969
            or len(old_rh) <= i
970
            or new_rh[i] != old_rh[i]):
971
            base_idx = i
972
            break
973
974
    if base_idx is None:
975
        to_file.write('Nothing seems to have changed\n')
976
        return
977
    ## TODO: It might be nice to do something like show_log
978
    ##       and show the merged entries. But since this is the
979
    ##       removed revisions, it shouldn't be as important
980
    if base_idx < len(old_rh):
981
        to_file.write('*'*60)
982
        to_file.write('\nRemoved Revisions:\n')
983
        for i in range(base_idx, len(old_rh)):
1185.67.2 by Aaron Bentley
Renamed Branch.storage to Branch.repository
984
            rev = branch.repository.get_revision(old_rh[i])
2490.1.4 by John Arbash Meinel
Update bzrlib.log.show_changed_revisions to use the new api
985
            lr = LogRevision(rev, i+1, 0, None)
986
            lf.log_revision(lr)
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
987
        to_file.write('*'*60)
988
        to_file.write('\n\n')
989
    if base_idx < len(new_rh):
990
        to_file.write('Added Revisions:\n')
991
        show_log(branch,
992
                 lf,
993
                 None,
1551.17.2 by Aaron Bentley
Stop showing deltas in pull -v output
994
                 verbose=False,
1185.32.2 by John Arbash Meinel
Refactor pull --verbose into a log.py function, add tests.
995
                 direction='forward',
996
                 start_revision=base_idx+1,
997
                 end_revision=len(new_rh),
998
                 search=None)
999
3144.7.4 by Guillermo Gonzalez
* move the function regisstry into a real Registry instead of a list
1000
3144.7.9 by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors
1001
properties_handler_registry = registry.Registry()
3830.4.1 by Jelmer Vernooij
Add base classes for foreign branches.
1002
properties_handler_registry.register_lazy("foreign",
1003
                                          "bzrlib.foreign",
1004
                                          "show_foreign_properties")
1005
3642.1.6 by Robert Collins
Make log revision filtering pluggable.
1006
1007
# adapters which revision ids to log are filtered. When log is called, the
1008
# log_rev_iterator is adapted through each of these factory methods.
1009
# Plugins are welcome to mutate this list in any way they like - as long
1010
# as the overall behaviour is preserved. At this point there is no extensible
1011
# mechanism for getting parameters to each factory method, and until there is
1012
# this won't be considered a stable api.
1013
log_adapters = [
1014
    # core log logic
3642.1.7 by Robert Collins
Review feedback.
1015
    _make_batch_filter,
3642.1.6 by Robert Collins
Make log revision filtering pluggable.
1016
    # read revision objects
3642.1.7 by Robert Collins
Review feedback.
1017
    _make_revision_objects,
3642.1.6 by Robert Collins
Make log revision filtering pluggable.
1018
    # filter on log messages
3642.1.7 by Robert Collins
Review feedback.
1019
    _make_search_filter,
3642.1.6 by Robert Collins
Make log revision filtering pluggable.
1020
    # generate deltas for things we will show
3642.1.7 by Robert Collins
Review feedback.
1021
    _make_delta_filter
3642.1.6 by Robert Collins
Make log revision filtering pluggable.
1022
    ]