~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/annotate.py

  • Committer: Robert Collins
  • Date: 2010-05-06 07:48:22 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506074822-0bsgf2j4h8jx0xkk
Added ``bzrlib.tests.matchers`` as a place to put matchers, along with
our first in-tree matcher. See the module docstring for details.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 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
188
188
        # or something.
189
189
        last_revision = current_rev.revision_id
190
190
        # XXX: Partially Cloned from branch, uses the old_get_graph, eep.
 
191
        # XXX: The main difficulty is that we need to inject a single new node
 
192
        #      (current_rev) into the graph before it gets numbered, etc.
 
193
        #      Once KnownGraph gets an 'add_node()' function, we can use
 
194
        #      VF.get_known_graph_ancestry().
191
195
        graph = repository.get_graph()
192
196
        revision_graph = dict(((key, value) for key, value in
193
197
            graph.iter_ancestry(current_rev.parent_ids) if value is not None))
313
317
    return matcher.get_matching_blocks()
314
318
 
315
319
 
316
 
def _break_annotation_tie(annotated_lines):
 
320
_break_annotation_tie = None
 
321
 
 
322
def _old_break_annotation_tie(annotated_lines):
317
323
    """Chose an attribution between several possible ones.
318
324
 
319
325
    :param annotated_lines: A list of tuples ((file_id, rev_id), line) where
394
400
                        # If the result is not stable, there is a risk a
395
401
                        # performance degradation as criss-cross merges will
396
402
                        # flip-flop the attribution.
397
 
                        output_append(_break_annotation_tie([left, right]))
 
403
                        if _break_annotation_tie is None:
 
404
                            output_append(
 
405
                                _old_break_annotation_tie([left, right]))
 
406
                        else:
 
407
                            output_append(_break_annotation_tie([left, right]))
398
408
        last_child_idx = child_idx + match_len
399
409
 
400
410
 
444
454
        # If left and right agree on a range, just push that into the output
445
455
        lines_extend(annotated_lines[left_idx:left_idx + match_len])
446
456
    return lines
 
457
 
 
458
 
 
459
try:
 
460
    from bzrlib._annotator_pyx import Annotator
 
461
except ImportError, e:
 
462
    osutils.failed_to_load_extension(e)
 
463
    from bzrlib._annotator_py import Annotator