Rev 4476: Need to record the other annotations before we can record this, in http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate
John Arbash Meinel
john at arbash-meinel.com
Thu Jun 18 22:09:55 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate
------------------------------------------------------------
revno: 4476
revision-id: john at arbash-meinel.com-20090618210934-804pslw0ii5vsh0j
parent: john at arbash-meinel.com-20090618210201-o1dwswy4e6x7fpmb
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-rework-annotate
timestamp: Thu 2009-06-18 16:09:34 -0500
message:
Need to record the other annotations before we can record this,
otherwise popping the extra annotations fails.
Factor out an '_annotate_one' helper, as it makes the code cleaner, especially
since we added a progress bar.
-------------- next part --------------
=== modified file 'bzrlib/_annotator_py.py'
--- a/bzrlib/_annotator_py.py 2009-06-18 21:02:01 +0000
+++ b/bzrlib/_annotator_py.py 2009-06-18 21:09:34 +0000
@@ -155,19 +155,6 @@
last_parent = par_ann
last_res = new_ann
- def _init_annotations(self, key, num_lines):
- """Build a new annotation list for this key.
-
- :return: (this_annotation, annotations)
- this_annotation: a tuple indicating this line was only introduced
- by revision key
- annotations: A list of this_annotation keys
- """
- this_annotation = (key,)
- # Note: annotations will be mutated by calls to _update_from*
- annotations = [this_annotation] * num_lines
- return this_annotation, annotations
-
def _record_annotation(self, key, parent_keys, annotations):
self._annotations_cache[key] = annotations
for parent_key in parent_keys:
@@ -180,22 +167,25 @@
# well?
self._num_needed_children[parent_key] = num
+ def _annotate_one(self, key, text, num_lines):
+ this_annotation = (key,)
+ # Note: annotations will be mutated by calls to _update_from*
+ annotations = [this_annotation] * num_lines
+ parent_keys = self._parent_map[key]
+ if parent_keys:
+ self._update_from_one_parent(annotations, text, parent_keys[0])
+ for parent in parent_keys[1:]:
+ self._update_from_other_parents(annotations, text,
+ this_annotation, parent)
+ self._record_annotation(key, parent_keys, annotations)
+
def annotate(self, key):
"""Return annotated fulltext for the given key."""
keys = self._get_needed_texts(key)
pb = ui.ui_factory.nested_progress_bar()
try:
for text_key, text, num_lines in self._get_needed_texts(key, pb=pb):
- (this_annotation,
- annotations) = self._init_annotations(text_key, num_lines)
-
- parent_keys = self._parent_map[text_key]
- if parent_keys:
- self._update_from_one_parent(annotations, text, parent_keys[0])
- for parent in parent_keys[1:]:
- self._update_from_other_parents(annotations, text,
- this_annotation, parent)
- self._record_annotation(text_key, parent_keys, annotations)
+ self._annotate_one(text_key, text, num_lines)
finally:
pb.finished()
try:
=== modified file 'bzrlib/tests/test__annotator.py'
--- a/bzrlib/tests/test__annotator.py 2009-06-18 21:02:01 +0000
+++ b/bzrlib/tests/test__annotator.py 2009-06-18 21:09:34 +0000
@@ -259,6 +259,7 @@
self.assertEqual([self.fa_key, self.fb_key, self.fc_key,
self.fd_key, self.fe_key, self.ff_key,
], sorted(self.ann._text_cache.keys()))
+ self.ann._record_annotation(self.fa_key, [], [])
self.ann._record_annotation(self.fb_key, [self.fa_key], [])
self.assertEqual({self.fa_key: 2,
self.fb_key: 1,
@@ -269,8 +270,9 @@
}, self.ann._num_needed_children)
self.assertTrue(self.fa_key in self.ann._text_cache)
self.assertTrue(self.fa_key in self.ann._annotations_cache)
+ self.ann._record_annotation(self.fc_key, [self.fa_key], [])
self.ann._record_annotation(self.fd_key, [self.fb_key, self.fc_key], [])
- self.assertEqual({self.fa_key: 2,
+ self.assertEqual({self.fa_key: 1,
self.fb_key: 0,
self.fc_key: 0,
self.fd_key: 1,
@@ -280,6 +282,6 @@
self.assertTrue(self.fa_key in self.ann._text_cache)
self.assertTrue(self.fa_key in self.ann._annotations_cache)
self.assertFalse(self.fb_key in self.ann._text_cache)
- self.assertFalse(self.fa_key in self.ann._annotations_cache)
+ self.assertFalse(self.fb_key in self.ann._annotations_cache)
self.assertFalse(self.fc_key in self.ann._text_cache)
- self.assertFalse(self.fa_key in self.ann._annotations_cache)
+ self.assertFalse(self.fc_key in self.ann._annotations_cache)
More information about the bazaar-commits
mailing list