Rev 3490: implement 'left' policy, and update the test for it. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/annotation
John Arbash Meinel
john at arbash-meinel.com
Wed Jun 11 23:33:03 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/annotation
------------------------------------------------------------
revno: 3490
revision-id: john at arbash-meinel.com-20080611223256-m300jv9r7rxsu56w
parent: john at arbash-meinel.com-20080611222634-cnteyr7i7sglt317
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: annotation
timestamp: Wed 2008-06-11 17:32:56 -0500
message:
implement 'left' policy, and update the test for it.
Rename right_head.py => right.py since it has both right-head and simple-right.
-------------- next part --------------
=== modified file 'bzrlib/annotation_policy/__init__.py'
--- a/bzrlib/annotation_policy/__init__.py 2008-06-11 22:04:00 +0000
+++ b/bzrlib/annotation_policy/__init__.py 2008-06-11 22:32:56 +0000
@@ -259,11 +259,19 @@
help="Assign ambiguous lines to the revision which merges them."
" (after checking heads())")
registry.register_lazy('simple-right',
- 'bzrlib.annotation_policy.right_head', 'SimpleRightAnnotationPolicy',
+ 'bzrlib.annotation_policy.right', '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',
+ 'bzrlib.annotation_policy.right', 'RightHeadAnnotationPolicy',
help="Assign ambiguous lines to the revision that was merged"
" (after checking heads())")
+registry.register_lazy('simple-left',
+ 'bzrlib.annotation_policy.left', 'SimpleLeftAnnotationPolicy',
+ help="Assign ambiguous lines to the basis tree"
+ " (no heads() check)")
+registry.register_lazy('left-head',
+ 'bzrlib.annotation_policy.left', 'LeftHeadAnnotationPolicy',
+ help="Assign ambiguous lines to the basis tree"
+ " (after checking heads())")
registry.default_key = 'merge-node'
=== added file 'bzrlib/annotation_policy/left.py'
--- a/bzrlib/annotation_policy/left.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/annotation_policy/left.py 2008-06-11 22:32:56 +0000
@@ -0,0 +1,44 @@
+# Copyright (C) 2008 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""Annotate by assigning results to the left node"""
+
+from bzrlib import annotation_policy
+
+
+class SimpleLeftAnnotationPolicy(annotation_policy.AnnotationPolicy):
+ """Assign ambiguous lines to the left parent."""
+
+ def _do_resolve_ambiguous(self, revision_id, left, right):
+ """See AnnotationPolicy._do_resolve_ambiguous"""
+ # Always return left
+ return left
+
+
+class LeftHeadAnnotationPolicy(annotation_policy.AnnotationPolicy):
+ """Assign ambiguous lines to the first parent."""
+
+ def _do_resolve_ambiguous(self, revision_id, left, right):
+ """See AnnotationPolicy._do_resolve_ambiguous"""
+ if self._heads_provider is None:
+ return left
+ heads = self._heads_provider.heads((left[0], right[0]))
+ if len(heads) == 1:
+ return (iter(heads).next(), left[1])
+ else:
+ # Both claim different origins
+ # give it to left
+ return left
=== renamed file 'bzrlib/annotation_policy/right_head.py' => 'bzrlib/annotation_policy/right.py'
=== modified file 'bzrlib/tests/test_annotation_policy.py'
--- a/bzrlib/tests/test_annotation_policy.py 2008-06-11 22:26:34 +0000
+++ b/bzrlib/tests/test_annotation_policy.py 2008-06-11 22:32:56 +0000
@@ -295,6 +295,11 @@
'rev-E':[(1, 'rev-A', 'alt-second\n')],
})
+DuplicateLineScenario(['left-head', 'simple-left'],
+ {'rev-D':[(1, 'rev-B', 'alt-second\n')],
+ 'rev-E':[(1, 'rev-A', 'alt-second\n')],
+ })
+
DuplicateLineScenario(['merge-node'],
{'rev-D':[(1, 'rev-D', 'alt-second\n')],
'rev-E':[(1, 'rev-D', 'alt-second\n')],
@@ -325,8 +330,11 @@
'rev-E':'None foo\n',
}
-# Currently all implementations offer this value
-MergeRevertedLineScenario(None, {'rev-E':[(0, 'rev-D', 'foo\n')]})
+MergeRevertedLineScenario(['merge-node', 'right-head', 'simple-right',
+ 'left-head'],
+ {'rev-E':[(0, 'rev-D', 'foo\n')]})
+MergeRevertedLineScenario(['simple-left'],
+ {'rev-E':[(0, 'rev-A', 'foo\n')]})
class TrunkRevertedLineScenario(AnnotationScenario):
@@ -354,7 +362,8 @@
}
# Currently all implementations offer this value
-TrunkRevertedLineScenario(['merge-node', 'right-head'],
+TrunkRevertedLineScenario(['merge-node', 'right-head', 'left-head',
+ 'simple-left'],
{'rev-E':[(0, 'rev-D', 'foo\n')]})
# simple-right always assumes that the right branch is correct, so it changes
# the value
More information about the bazaar-commits
mailing list