Rev 3486: Add a new annotation policy, and add support for testing if all annotation polices handle all the scenarios. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/annotation
John Arbash Meinel
john at arbash-meinel.com
Wed Jun 11 23:04:07 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/annotation
------------------------------------------------------------
revno: 3486
revision-id: john at arbash-meinel.com-20080611220400-d173fackfqd3gzyg
parent: john at arbash-meinel.com-20080611185336-0do4ivybwp5xwm7q
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: annotation
timestamp: Wed 2008-06-11 17:04:00 -0500
message:
Add a new annotation policy, and add support for testing if all annotation polices handle all the scenarios.
-------------- next part --------------
=== modified file 'bzrlib/annotation_policy/__init__.py'
--- a/bzrlib/annotation_policy/__init__.py 2008-06-11 18:11:44 +0000
+++ b/bzrlib/annotation_policy/__init__.py 2008-06-11 22:04:00 +0000
@@ -258,8 +258,12 @@
'bzrlib.annotation_policy.merge_node', 'MergeNodeAnnotationPolicy',
help="Assign ambiguous lines to the revision which merges them."
" (after checking heads())")
+registry.register_lazy('simple-right',
+ 'bzrlib.annotation_policy.right_head', 'SimpleRightAnnotationPolicy',
+ help="Assign ambiguous lines to the revision that was merged"
+ " (no heads() check)")
registry.register_lazy('right-head',
'bzrlib.annotation_policy.right_head', 'RightHeadAnnotationPolicy',
- help="Assign ambiguous lines to the merge revision."
+ help="Assign ambiguous lines to the revision that was merged"
" (after checking heads())")
registry.default_key = 'merge-node'
=== modified file 'bzrlib/annotation_policy/right_head.py'
--- a/bzrlib/annotation_policy/right_head.py 2008-06-11 18:11:44 +0000
+++ b/bzrlib/annotation_policy/right_head.py 2008-06-11 22:04:00 +0000
@@ -18,6 +18,16 @@
from bzrlib import annotation_policy
+
+class SimpleRightAnnotationPolicy(annotation_policy.AnnotationPolicy):
+ """Assign ambiguous lines to the right parent."""
+
+ def _do_resolve_ambiguous(self, revision_id, left, right):
+ """See AnnotationPolicy._do_resolve_ambiguous"""
+ # Always return right
+ return right
+
+
class RightHeadAnnotationPolicy(annotation_policy.AnnotationPolicy):
"""Assign ambiguous lines to the last merge parent."""
=== modified file 'bzrlib/debug.py'
--- a/bzrlib/debug.py 2008-05-07 22:47:56 +0000
+++ b/bzrlib/debug.py 2008-06-11 22:04:00 +0000
@@ -25,6 +25,7 @@
Options include:
+ * annotation - warn if annotation polices do not handle a scenario
* auth - show authentication sections used
* error - show stack traces for all top level exceptions
* evil - capture call sites that do expensive or badly-scaling operations.
=== modified file 'bzrlib/tests/test_annotation_policy.py'
--- a/bzrlib/tests/test_annotation_policy.py 2008-06-11 18:53:36 +0000
+++ b/bzrlib/tests/test_annotation_policy.py 2008-06-11 22:04:00 +0000
@@ -16,13 +16,14 @@
"""Whitebox tests for annotate policies."""
-
from bzrlib import (
annotation_policy,
+ debug,
errors,
graph,
patiencediff,
tests,
+ trace,
)
@@ -111,14 +112,30 @@
def scenarios_to_adaptions(self, ann_scenarios):
"""Convert the AnnotationScenario into concrete variables"""
result = []
+ all_policies = set(annotation_policy.registry.keys())
+ # For each scenario name, keep track of policies that handle it
+ scenario_policy_combinations = {}
for scenario in ann_scenarios:
policy = scenario._policy
if policy is not None:
result.append(self._get_vars_for_scenario(policy, scenario))
+ scenario_policy_combinations.setdefault(scenario.name,
+ set()).add(policy)
else:
# This applies to all scenarios
- for policy in annotation_policy.registry.keys():
+ for policy in all_policies:
result.append(self._get_vars_for_scenario(policy, scenario))
+ scenario_policy_combinations.setdefault(scenario.name,
+ set()).update(all_policies)
+ if 'annotation' in debug.debug_flags:
+ log = trace.warning
+ else:
+ log = trace.mutter
+ for name, policies in scenario_policy_combinations.iteritems():
+ missing = all_policies - policies
+ if missing:
+ log('Annotation scenario %r is not handled by policies: %s',
+ name, ', '.join(sorted(missing)))
return result
@@ -182,73 +199,6 @@
self.assertReannotate(parents_lines, child_lines, revision_id,
left_matching_blocks=matching_blocks)
-# def create_duplicate_lines_tree(self):
-# tree1 = self.make_branch_and_tree('tree1')
-# base_text = ''.join(l for r, l in duplicate_base)
-# a_text = ''.join(l for r, l in duplicate_A)
-# b_text = ''.join(l for r, l in duplicate_B)
-# c_text = ''.join(l for r, l in duplicate_C)
-# d_text = ''.join(l for r, l in duplicate_D)
-# e_text = ''.join(l for r, l in duplicate_E)
-# self.build_tree_contents([('tree1/file', base_text)])
-# tree1.add(['file'], ['file-id'])
-# tree1.commit('base', rev_id='rev-base')
-# tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
-#
-# self.build_tree_contents([('tree1/file', a_text),
-# ('tree2/file', b_text)])
-# tree1.commit('A', rev_id='rev-A')
-# tree2.commit('B', rev_id='rev-B')
-#
-# tree2.merge_from_branch(tree1.branch)
-# conflicts.resolve(tree2, None) # Resolve the conflicts
-# self.build_tree_contents([('tree2/file', d_text)])
-# tree2.commit('D', rev_id='rev-D')
-#
-# self.build_tree_contents([('tree1/file', c_text)])
-# tree1.commit('C', rev_id='rev-C')
-#
-# tree1.merge_from_branch(tree2.branch)
-# conflicts.resolve(tree1, None) # Resolve the conflicts
-# self.build_tree_contents([('tree1/file', e_text)])
-# tree1.commit('E', rev_id='rev-E')
-# return tree1
-#
-# def help_test_annotate_duplicate_lines(self):
-# # XXX: Should this be a repository_implementations test?
-# self.assertAnnotate(self._duplicate_base, [],
-# 'rev-base')
-# self.assertAnnotate(self._duplicate_A, repo, 'file-id', 'rev-A')
-# self.assertAnnotate(self._duplicate_B, repo, 'file-id', 'rev-B')
-# self.assertAnnotate(self._duplicate_C, repo, 'file-id', 'rev-C')
-# self.assertAnnotate(self._duplicate_D, repo, 'file-id', 'rev-D')
-# self.assertAnnotate(self._duplicate_E, repo, 'file-id', 'rev-E')
-#
-#
-# class TestMergeNodeAnnotationPolicy(TestAnnotationPolicy):
-# #
-# # BASE
-# # |\
-# # A B # line should be annotated as new for A and B
-# # |\|
-# # C D # line should 'converge' and say D
-# # |/
-# # E # D should supersede A and stay as D (not become E because C
-# # # references A)
-# _duplicate_D = annotation("""\
-# rev-base first
-# rev-D alt-second
-# rev-base third
-# rev-D fourth-D
-# """)
-#
-# _duplicate_E = annotation("""\
-# rev-base first
-# rev-D alt-second
-# rev-base third
-# rev-E fourth-E
-# """)
-
class TrivialAnnotationScenario(AnnotationScenario):
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py 2008-05-22 06:53:06 +0000
+++ b/bzrlib/tests/test_osutils.py 2008-06-11 22:04:00 +0000
@@ -1219,6 +1219,7 @@
Options include:
+ * annotation - warn if annotation polices do not handle a scenario
* auth - show authentication sections used
* error - show stack traces for all top level exceptions
* evil - capture call sites that do expensive or badly-scaling operations.
More information about the bazaar-commits
mailing list