Rev 3488: Implement the reverted line scenario. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/annotation

John Arbash Meinel john at arbash-meinel.com
Wed Jun 11 23:20:36 BST 2008


At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/annotation

------------------------------------------------------------
revno: 3488
revision-id: john at arbash-meinel.com-20080611222029-wwcckhnvnyl9xs6r
parent: john at arbash-meinel.com-20080611220815-ohmlsr99zpo0mze8
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: annotation
timestamp: Wed 2008-06-11 17:20:29 -0500
message:
  Implement the reverted line scenario.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_annotation_policy.py'
--- a/bzrlib/tests/test_annotation_policy.py	2008-06-11 22:08:15 +0000
+++ b/bzrlib/tests/test_annotation_policy.py	2008-06-11 22:20:29 +0000
@@ -38,7 +38,7 @@
         make it easier for subclasses to properly mark them.
     :cvar _revision_graph: The graph of how revisions fit together.
         {rev_id:[parents]}
-    :ivar name: The name of this test
+    :cvar name: The name of this test
     :ivar _policies: The policies that this scenario applies to. If set as
         None, then the suite will apply this scenario to *all* known policies.
     :ivar _overrides: A dictionary of {revid:[overrides]} where overrides is a
@@ -50,9 +50,9 @@
 
     _annotated_texts = None
     _revision_graph = None
+    name = None
 
-    def __init__(self, name, policies, overrides):
-        self.name = name
+    def __init__(self, policies, overrides):
         self._policies = policies
         self._overrides = overrides
 
@@ -62,10 +62,10 @@
         """Return the annotated text for requseted revision."""
         annotated = []
         for line in self._annotated_texts[revision_id].splitlines(True):
-            revision_id, text = line.split(' ', 1)
-            if revision_id == 'None':
-                revision_id = None
-            annotated.append((revision_id, text))
+            source, text = line.split(' ', 1)
+            if source == 'None':
+                source = None
+            annotated.append((source, text))
         if revision_id in self._overrides:
             annotated = annotated[:]
             for line_num, rev_id, text in self._overrides[revision_id]:
@@ -199,34 +199,40 @@
 
 class TrivialAnnotationScenario(AnnotationScenario):
 
+    name = 'trivial'
     _annotated_texts = {'base': 'base one line\n',
                         'first': 'base one line\n'
                                  'first line\n',
                        }
     _revision_graph = {'base':(), 'first':('base',)}
 
-# Trivial applies to all policies
-TrivialAnnotationScenario('trivial', None, {})
+# It is expected that all implementations will give the same results. This is
+# mostly to check that the basic apis are all available
+TrivialAnnotationScenario(None, {})
 
 
 class DuplicateLineScenario(AnnotationScenario):
-
-    # For the 'duplicate' series, both sides introduce the same change, which
-    # then gets merged around. The last-modified should properly reflect this.
-    # We always change the fourth line so that the file is properly tracked as
-    # being modified in each revision. In reality, this probably would happen
-    # over many revisions, and it would be a different line that changes.
-    #
-    # The actual annotations will vary slightly based on the algorithm. For the
-    # default algorithm, the values are as noted.
-    #
-    # BASE
-    #  |\
-    #  A B  # line should be annotated as new for A and B
-    #  |\|
-    #  C D  # we now have to resolve the mismatch
-    #  |/
-    #  E    # and then decide what to do when this gets merged back
+    """Two branches introduce the same line.
+
+    For the 'duplicate' series, both sides introduce the same change, which
+    then gets merged around. The last-modified should properly reflect this.
+    We always change the fourth line so that the file is properly tracked as
+    being modified in each revision. In reality, this probably would happen
+    over many revisions, and it would be a different line that changes.
+    
+    The actual annotations will vary slightly based on the algorithm. For the
+    default algorithm, the values are as noted.
+    
+      BASE
+       |\
+       A B  # line should be annotated as new for A and B
+       |\|
+       C D  # we now have to resolve the mismatch
+       |/
+       E    # and then decide what to do when this gets merged back
+    """
+
+    name = 'duplicated'
 
     _annotated_texts = {
 'rev-base': """\
@@ -279,17 +285,46 @@
                       }
 
 
-DuplicateLineScenario('duplicate', ['right-head', 'simple-right'],
+DuplicateLineScenario(['right-head', 'simple-right'],
     {'rev-D':[(1, 'rev-A', 'alt-second\n')],
      'rev-E':[(1, 'rev-A', 'alt-second\n')],
     })
 
-DuplicateLineScenario('duplicate', ['merge-node'],
+DuplicateLineScenario(['merge-node'],
     {'rev-D':[(1, 'rev-D', 'alt-second\n')],
      'rev-E':[(1, 'rev-D', 'alt-second\n')],
     })
 
 
+class MergeRevertedLineScenario(AnnotationScenario):
+    """A line was modified and then reverted in a branch.
+
+      A    # Common text, has line 'foo'
+      |\
+      B C  # No change in W, X changes 'foo' to 'bar'
+      | |
+      | D  # Y reverts 'bar' back to 'foo'
+      |/
+      E
+    """
+
+    name = 'merge-reverted-line'
+
+    _revision_graph = {'rev-A':(), 'rev-B':('rev-A',), 'rev-C':('rev-A',),
+                       'rev-D':('rev-C',), 'rev-E':('rev-B', 'rev-D')}
+
+    _annotated_texts = {'rev-A':'rev-A foo\n',
+                        'rev-B':'rev-A foo\n',
+                        'rev-C':'rev-C bar\n',
+                        'rev-D':'rev-D foo\n',
+                        'rev-E':'None foo\n',
+                       }
+
+# Currently all implementations offer this value
+MergeRevertedLineScenario(None, {'rev-E':[(0, 'rev-D', 'foo\n')]})
+                       
+
+
 def load_tests(basic_tests, module, loader):
     result = loader.suiteClass()
 



More information about the bazaar-commits mailing list