Rev 3495: Merge in the latest annotation work. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/annotation_policy_cmd
John Arbash Meinel
john at arbash-meinel.com
Tue Jun 17 22:35:17 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/annotation_policy_cmd
------------------------------------------------------------
revno: 3495
revision-id: john at arbash-meinel.com-20080617213451-h2d53vmh54uxrxkc
parent: john at arbash-meinel.com-20080612163426-vnox9ay0bbnz30px
parent: john at arbash-meinel.com-20080617211951-t49i75urkd2rctz4
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: annotation_policy_cmd
timestamp: Tue 2008-06-17 16:34:51 -0500
message:
Merge in the latest annotation work.
modified:
bzrlib/annotate.py annotate.py-20050922133147-7c60541d2614f022
bzrlib/annotation_policy/__init__.py __init__.py-20080611181056-u2fq8m7hzdyzz9ot-1
bzrlib/annotation_policy/left.py left.py-20080611222924-6qr8t9nfe1t4j2ay-1
bzrlib/annotation_policy/merge_node.py merge_node.py-20080611181056-u2fq8m7hzdyzz9ot-2
bzrlib/annotation_policy/no_merge.py no_merge.py-20080611231003-1xiocuboddgf5u33-1
bzrlib/annotation_policy/right.py right_head.py-20080611181056-u2fq8m7hzdyzz9ot-3
bzrlib/tests/test_annotate.py test_annotate.py-20061213215015-sttc9agsxomls7q0-1
------------------------------------------------------------
revno: 3493.1.3
revision-id: john at arbash-meinel.com-20080617211951-t49i75urkd2rctz4
parent: john at arbash-meinel.com-20080617204640-p23gxho19zcyqu7m
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: annotation
timestamp: Tue 2008-06-17 16:19:51 -0500
message:
add a comment about no_merge
modified:
bzrlib/annotation_policy/no_merge.py no_merge.py-20080611231003-1xiocuboddgf5u33-1
------------------------------------------------------------
revno: 3493.1.2
revision-id: john at arbash-meinel.com-20080617204640-p23gxho19zcyqu7m
parent: john at arbash-meinel.com-20080617204106-lksom3sdqjt5sx5f
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: annotation
timestamp: Tue 2008-06-17 15:46:40 -0500
message:
more cleanups from Ian
modified:
bzrlib/annotation_policy/no_merge.py no_merge.py-20080611231003-1xiocuboddgf5u33-1
bzrlib/tests/test_annotate.py test_annotate.py-20061213215015-sttc9agsxomls7q0-1
------------------------------------------------------------
revno: 3493.1.1
revision-id: john at arbash-meinel.com-20080617204106-lksom3sdqjt5sx5f
parent: john at arbash-meinel.com-20080612163311-977q08c89jqwjcul
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: annotation
timestamp: Tue 2008-06-17 15:41:06 -0500
message:
Some review feedback from Ian.
Simplify the _resolve_ambiguous api.
modified:
bzrlib/annotate.py annotate.py-20050922133147-7c60541d2614f022
bzrlib/annotation_policy/__init__.py __init__.py-20080611181056-u2fq8m7hzdyzz9ot-1
bzrlib/annotation_policy/left.py left.py-20080611222924-6qr8t9nfe1t4j2ay-1
bzrlib/annotation_policy/merge_node.py merge_node.py-20080611181056-u2fq8m7hzdyzz9ot-2
bzrlib/annotation_policy/right.py right_head.py-20080611181056-u2fq8m7hzdyzz9ot-3
-------------- next part --------------
=== modified file 'bzrlib/annotate.py'
--- a/bzrlib/annotate.py 2008-06-12 16:34:26 +0000
+++ b/bzrlib/annotate.py 2008-06-17 21:34:51 +0000
@@ -172,8 +172,6 @@
(start_left, start_right, length_of_match).
:param heads_provider: An object which provids a .heads() call to resolve
if any revision ids are children of others.
- If None, then any ancestry disputes will be resolved with
- new_revision_id
:param policy: The name of a policy to use, None uses the default
"""
from bzrlib import annotation_policy
=== modified file 'bzrlib/annotation_policy/__init__.py'
--- a/bzrlib/annotation_policy/__init__.py 2008-06-12 16:33:11 +0000
+++ b/bzrlib/annotation_policy/__init__.py 2008-06-17 20:41:06 +0000
@@ -34,12 +34,12 @@
"""
def __init__(self, heads_provider):
- """Create a new AnnotationPolicy
+ """Create a new AnnotationPolicy.
- :param heads_provider: An object which provids a .heads() call to
+ :param heads_provider: An object which provides a .heads() call to
resolve if any revision ids are children of others.
Should also provide a 'cache(keys, head)' function.
- Can be None.
+
"""
self._sequence_matcher = patiencediff.PatienceSequenceMatcher
self._heads_provider = heads_provider
@@ -77,7 +77,6 @@
return self._do_annotate_many_parents(
annotated_parents_lines, left_matching_blocks,
plain_child_lines, child_revision_id)
- return lines
def _do_annotate_no_parents(self, plain_child_lines, child_revision_id):
"""Simplest case, no parents to consider."""
@@ -153,7 +152,7 @@
lines.extend((child_revision_id, l) for l in
plain_child_lines[last_child_match:start_child])
lines.extend(annotated_parent_lines[start_parent
- :start_parent+ match_len])
+ :start_parent + match_len])
last_child_match = start_child + match_len
return lines
@@ -209,7 +208,7 @@
annotated_child_lines, start_child, end_child,
annotated_right_lines, start_right, end_right,
revision_id):
- """Find lines in plain right_lines that match plain_child_lines
+ """Find lines in plain right_lines that match plain_child_lines.
:param output_lines: Append final annotated lines to this list
:param plain_child_lines: The unannotated new lines for the child text
@@ -244,8 +243,8 @@
output_extend(annotated_child_lines[
start_child + last_child_idx:start_child + child_idx])
for offset in xrange(match_len):
- left = annotated_child_lines[start_child+child_idx+offset]
- right = annotated_right_lines[start_right+right_idx+offset]
+ left = annotated_child_lines[start_child + child_idx + offset]
+ right = annotated_right_lines[start_right + right_idx + offset]
if left[0] == right[0]:
# The annotations match, just return the left one
output_append(left)
@@ -255,11 +254,11 @@
output_append(right)
else:
# Left and Right both claim this line
- output_append(self._resolve_ambiguous(revision_id, left,
- right))
+ output_append((self._resolve_ambiguous(revision_id,
+ left[0], right[0]), left[1]))
last_child_idx = child_idx + match_len
- def _resolve_ambiguous(self, revision_id, left, right):
+ def _resolve_ambiguous(self, revision_id, left_parent_id, right_parent_id):
"""Resolve an ambiguous annotation between texts.
This is the thunk layer, implementations should override
@@ -267,15 +266,19 @@
:param revision_id: The revision id to assign if this line is
considered newly introduced.
- :param left: (left_parent_id, text)
- :param right: (right_parent_id, text)
- :return: (annotation_id, text)
+ :param left_parent_id: The revision id the left parent assigned to this
+ line
+ :param right_parent_id: The revision id the right parent assigned to
+ this line
+ :return: annotation_id
"""
# TODO: Would it be cleaner to just pass in the revision ids, rather
# than (revision_id, text)?
- return self._do_resolve_ambiguous(revision_id, left, right)
+ return self._do_resolve_ambiguous(revision_id, left_parent_id,
+ right_parent_id)
- def _do_resolve_ambiguous(self, revision_id, left, right):
+ def _do_resolve_ambiguous(self, revision_id, left_parent_id,
+ right_parent_id):
"""See AnnotationPolicy._resolve_ambiguous
This is intended to be overriden by implementations.
=== modified file 'bzrlib/annotation_policy/left.py'
--- a/bzrlib/annotation_policy/left.py 2008-06-11 22:32:56 +0000
+++ b/bzrlib/annotation_policy/left.py 2008-06-17 20:41:06 +0000
@@ -22,23 +22,25 @@
class SimpleLeftAnnotationPolicy(annotation_policy.AnnotationPolicy):
"""Assign ambiguous lines to the left parent."""
- def _do_resolve_ambiguous(self, revision_id, left, right):
+ def _do_resolve_ambiguous(self, revision_id, left_parent_id,
+ right_parent_id):
"""See AnnotationPolicy._do_resolve_ambiguous"""
# Always return left
- return left
+ return left_parent_id
class LeftHeadAnnotationPolicy(annotation_policy.AnnotationPolicy):
"""Assign ambiguous lines to the first parent."""
- def _do_resolve_ambiguous(self, revision_id, left, right):
+ def _do_resolve_ambiguous(self, revision_id, left_parent_id,
+ right_parent_id):
"""See AnnotationPolicy._do_resolve_ambiguous"""
if self._heads_provider is None:
return left
- heads = self._heads_provider.heads((left[0], right[0]))
+ heads = self._heads_provider.heads((left_parent_id, right_parent_id))
if len(heads) == 1:
- return (iter(heads).next(), left[1])
+ return iter(heads).next()
else:
# Both claim different origins
# give it to left
- return left
+ return left_parent_id
=== modified file 'bzrlib/annotation_policy/merge_node.py'
--- a/bzrlib/annotation_policy/merge_node.py 2008-06-11 18:11:44 +0000
+++ b/bzrlib/annotation_policy/merge_node.py 2008-06-17 20:41:06 +0000
@@ -22,25 +22,26 @@
class MergeNodeAnnotationPolicy(annotation_policy.AnnotationPolicy):
"""Assign ambiguous lines to the node merging the results."""
- def _do_resolve_ambiguous(self, revision_id, left, right):
+ def _do_resolve_ambiguous(self, revision_id, left_parent_id,
+ right_parent_id):
"""We have an ambiguous line between two texts.
Resolve this somehow.
"""
if self._heads_provider is None:
# Without a heads provider, we just always pick 'tip'
- return (revision_id, left[1])
- heads = self._heads_provider.heads((left[0], right[0]))
+ return revision_id
+ heads = self._heads_provider.heads((left_parent_id, right_parent_id))
if len(heads) == 1:
- return (iter(heads).next(), left[1])
+ return iter(heads).next()
else:
# Both claim different origins
# We know that revision_id is the head for
# left and right, so cache it
self._heads_provider.cache(
- (revision_id, left[0]),
+ (revision_id, left_parent_id),
(revision_id,))
self._heads_provider.cache(
- (revision_id, right[0]),
+ (revision_id, right_parent_id),
(revision_id,))
- return (revision_id, left[1])
+ return revision_id
=== modified file 'bzrlib/annotation_policy/no_merge.py'
--- a/bzrlib/annotation_policy/no_merge.py 2008-06-12 16:33:11 +0000
+++ b/bzrlib/annotation_policy/no_merge.py 2008-06-17 21:19:51 +0000
@@ -20,15 +20,19 @@
class NoMergeAnnotationPolicy(annotation_policy.AnnotationPolicy):
- """Assign all lines based on the primary parent"""
+ """Assign all lines based on the primary parent.
+
+ We don't implemement "_do_resolve_ambiguous" because it should not be
+ possible to have ambiguous lines when you only compare with 1 parent.
+ """
def _do_annotate_two_parents(self, first_parent_lines,
first_matching_blocks,
second_parent_lines,
plain_child_lines,
child_revision_id):
- """Annotate versus two parents,
-
+ """Annotate versus two parents.
+
For this class, we always ignore other parents.
"""
return self._do_annotate_one_parent(first_parent_lines,
=== modified file 'bzrlib/annotation_policy/right.py'
--- a/bzrlib/annotation_policy/right.py 2008-06-11 22:32:56 +0000
+++ b/bzrlib/annotation_policy/right.py 2008-06-17 20:41:06 +0000
@@ -22,23 +22,25 @@
class SimpleRightAnnotationPolicy(annotation_policy.AnnotationPolicy):
"""Assign ambiguous lines to the right parent."""
- def _do_resolve_ambiguous(self, revision_id, left, right):
+ def _do_resolve_ambiguous(self, revision_id, left_parent_id,
+ right_parent_id):
"""See AnnotationPolicy._do_resolve_ambiguous"""
# Always return right
- return right
+ return right_parent_id
class RightHeadAnnotationPolicy(annotation_policy.AnnotationPolicy):
"""Assign ambiguous lines to the last merge parent."""
- def _do_resolve_ambiguous(self, revision_id, left, right):
+ def _do_resolve_ambiguous(self, revision_id, left_parent_id,
+ right_parent_id):
"""See AnnotationPolicy._do_resolve_ambiguous"""
if self._heads_provider is None:
- return right
- heads = self._heads_provider.heads((left[0], right[0]))
+ return right_parent_id
+ heads = self._heads_provider.heads((left_parent_id, right_parent_id))
if len(heads) == 1:
- return (iter(heads).next(), left[1])
+ return iter(heads).next()
else:
# Both claim different origins
# give it to right
- return right
+ return right_parent_id
=== modified file 'bzrlib/tests/test_annotate.py'
--- a/bzrlib/tests/test_annotate.py 2008-06-11 18:53:36 +0000
+++ b/bzrlib/tests/test_annotate.py 2008-06-17 20:46:40 +0000
@@ -23,8 +23,6 @@
annotate,
conflicts,
errors,
- graph,
- revision,
tests,
trace,
)
@@ -414,5 +412,3 @@
blocks = [(0, 1, 1), (1, 2, 0)]
self.annotateEqual([('rev2', 'a\n'), ('rev1', 'a\n')], [parent],
new_text, 'rev2', blocks)
-
-
More information about the bazaar-commits
mailing list