~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__annotator.py

  • Committer: John Arbash Meinel
  • Date: 2009-07-08 17:09:03 UTC
  • mto: This revision was merged to the branch mainline in revision 4522.
  • Revision ID: john@arbash-meinel.com-20090708170903-nea7ru9bh2hdtf1w
Add support for compatibility with old '_break_annotation_tie' function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for Annotators."""
18
18
 
19
19
from bzrlib import (
 
20
    annotate,
20
21
    _annotator_py,
21
22
    errors,
22
23
    knit,
230
231
                         (self.fb_key, 'new content\n')],
231
232
                         self.ann.annotate_flat(self.ff_key))
232
233
 
 
234
    def test_annotate_flat_respects_break_ann_tie(self):
 
235
        tiebreaker = annotate._break_annotation_tie
 
236
        try:
 
237
            calls = []
 
238
            def custom_tiebreaker(annotated_lines):
 
239
                self.assertEqual(2, len(annotated_lines))
 
240
                left = annotated_lines[0]
 
241
                self.assertEqual(2, len(left))
 
242
                self.assertEqual('new content\n', left[1])
 
243
                right = annotated_lines[1]
 
244
                self.assertEqual(2, len(right))
 
245
                self.assertEqual('new content\n', right[1])
 
246
                calls.append((left[0], right[0]))
 
247
                # Our custom tiebreaker takes the *largest* value, rather than
 
248
                # the *smallest* value
 
249
                if left[0] < right[0]:
 
250
                    return right
 
251
                else:
 
252
                    return left
 
253
            annotate._break_annotation_tie = custom_tiebreaker
 
254
            self.make_many_way_common_merge_text()
 
255
            self.assertEqual([(self.fa_key, 'simple\n'),
 
256
                             (self.fe_key, 'new content\n')],
 
257
                             self.ann.annotate_flat(self.ff_key))
 
258
            self.assertEqual([(self.fe_key, self.fc_key),
 
259
                              (self.fe_key, self.fb_key)], calls)
 
260
        finally:
 
261
            annotate._break_annotation_tie = tiebreaker
 
262
 
233
263
 
234
264
    def test_needed_keys_simple(self):
235
265
        self.make_simple_text()