~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/annotate.py

extend list_files() with from_dir and recursive parameters

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2004, 2005, 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
28
28
import sys
29
29
import time
30
30
 
31
 
from bzrlib.lazy_import import lazy_import
32
 
lazy_import(globals(), """
33
31
from bzrlib import (
 
32
    errors,
 
33
    osutils,
34
34
    patiencediff,
35
35
    tsort,
36
36
    )
37
 
""")
38
 
from bzrlib import (
39
 
    errors,
40
 
    osutils,
41
 
    )
42
37
from bzrlib.config import extract_email_address
43
38
from bzrlib.repository import _strip_NULL_ghosts
44
39
from bzrlib.revision import CURRENT_REVISION, Revision
193
188
        # or something.
194
189
        last_revision = current_rev.revision_id
195
190
        # XXX: Partially Cloned from branch, uses the old_get_graph, eep.
196
 
        # XXX: The main difficulty is that we need to inject a single new node
197
 
        #      (current_rev) into the graph before it gets numbered, etc.
198
 
        #      Once KnownGraph gets an 'add_node()' function, we can use
199
 
        #      VF.get_known_graph_ancestry().
200
191
        graph = repository.get_graph()
201
192
        revision_graph = dict(((key, value) for key, value in
202
193
            graph.iter_ancestry(current_rev.parent_ids) if value is not None))
317
308
 
318
309
 
319
310
def _get_matching_blocks(old, new):
320
 
    matcher = patiencediff.PatienceSequenceMatcher(None, old, new)
 
311
    matcher = patiencediff.PatienceSequenceMatcher(None,
 
312
        old, new)
321
313
    return matcher.get_matching_blocks()
322
314
 
323
315
 
324
 
_break_annotation_tie = None
325
 
 
326
 
def _old_break_annotation_tie(annotated_lines):
 
316
def _break_annotation_tie(annotated_lines):
327
317
    """Chose an attribution between several possible ones.
328
318
 
329
319
    :param annotated_lines: A list of tuples ((file_id, rev_id), line) where
404
394
                        # If the result is not stable, there is a risk a
405
395
                        # performance degradation as criss-cross merges will
406
396
                        # flip-flop the attribution.
407
 
                        if _break_annotation_tie is None:
408
 
                            output_append(
409
 
                                _old_break_annotation_tie([left, right]))
410
 
                        else:
411
 
                            output_append(_break_annotation_tie([left, right]))
 
397
                        output_append(_break_annotation_tie([left, right]))
412
398
        last_child_idx = child_idx + match_len
413
399
 
414
400
 
458
444
        # If left and right agree on a range, just push that into the output
459
445
        lines_extend(annotated_lines[left_idx:left_idx + match_len])
460
446
    return lines
461
 
 
462
 
 
463
 
try:
464
 
    from bzrlib._annotator_pyx import Annotator
465
 
except ImportError, e:
466
 
    osutils.failed_to_load_extension(e)
467
 
    from bzrlib._annotator_py import Annotator