~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/annotate.py

  • Committer: Martin Pool
  • Date: 2010-07-21 09:58:42 UTC
  • mfrom: (4797.58.7 2.1)
  • mto: (5050.3.13 2.2)
  • mto: This revision was merged to the branch mainline in revision 5365.
  • Revision ID: mbp@canonical.com-20100721095842-hz0obu8gl0x05nty
merge up 2.1 to 2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005-2010 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
from bzrlib import (
 
34
    patiencediff,
 
35
    tsort,
 
36
    )
 
37
""")
31
38
from bzrlib import (
32
39
    errors,
33
40
    osutils,
34
 
    patiencediff,
35
 
    tsort,
36
41
    )
37
42
from bzrlib.config import extract_email_address
38
43
from bzrlib.repository import _strip_NULL_ghosts
188
193
        # or something.
189
194
        last_revision = current_rev.revision_id
190
195
        # 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().
191
200
        graph = repository.get_graph()
192
201
        revision_graph = dict(((key, value) for key, value in
193
202
            graph.iter_ancestry(current_rev.parent_ids) if value is not None))
308
317
 
309
318
 
310
319
def _get_matching_blocks(old, new):
311
 
    matcher = patiencediff.PatienceSequenceMatcher(None,
312
 
        old, new)
 
320
    matcher = patiencediff.PatienceSequenceMatcher(None, old, new)
313
321
    return matcher.get_matching_blocks()
314
322
 
315
323
 
316
 
def _break_annotation_tie(annotated_lines):
 
324
_break_annotation_tie = None
 
325
 
 
326
def _old_break_annotation_tie(annotated_lines):
317
327
    """Chose an attribution between several possible ones.
318
328
 
319
329
    :param annotated_lines: A list of tuples ((file_id, rev_id), line) where
394
404
                        # If the result is not stable, there is a risk a
395
405
                        # performance degradation as criss-cross merges will
396
406
                        # flip-flop the attribution.
397
 
                        output_append(_break_annotation_tie([left, right]))
 
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]))
398
412
        last_child_idx = child_idx + match_len
399
413
 
400
414
 
444
458
        # If left and right agree on a range, just push that into the output
445
459
        lines_extend(annotated_lines[left_idx:left_idx + match_len])
446
460
    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