Rev 2639: fix annotate merge to not require Tree.get_weave in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Jul 20 14:31:46 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2639
revision-id: pqm at pqm.ubuntu.com-20070720133143-r74lo566tluurmfp
parent: pqm at pqm.ubuntu.com-20070720081024-5xhlp7r8ufwxt6nf
parent: abentley at panoramicfeedback.com-20070720125633-9wek52fpzqtatsfh
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-07-20 14:31:43 +0100
message:
  fix annotate merge to not require Tree.get_weave
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/inventory.py            inventory.py-20050309040759-6648b84ca2005b37
  bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
  bzrlib/merge.py                merge.py-20050513021216-953b65a438527106
  bzrlib/revisiontree.py         revisiontree.py-20060724012533-bg8xyryhxd0o0i0h-1
  bzrlib/tests/test_merge_core.py test_merge_core.py-20050824132511-eb99b23a0eec641b
  bzrlib/tests/tree_implementations/test_tree.py test_tree.py-20061215160206-usu7lwcj8aq2n3br-1
  bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.54
    merged: abentley at panoramicfeedback.com-20070720125633-9wek52fpzqtatsfh
    parent: abentley at panoramicfeedback.com-20070720124527-rlyrmhdnovpj8vz7
    parent: pqm at pqm.ubuntu.com-20070720081024-5xhlp7r8ufwxt6nf
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Fri 2007-07-20 08:56:33 -0400
    message:
      Merge bzr.dev
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.53
    merged: abentley at panoramicfeedback.com-20070720124527-rlyrmhdnovpj8vz7
    parent: abentley at panoramicfeedback.com-20070719154417-gb6sri5503b1u89w
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Fri 2007-07-20 08:45:27 -0400
    message:
      Restore old method of adjusting partents
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.52
    merged: abentley at panoramicfeedback.com-20070719154417-gb6sri5503b1u89w
    parent: abentley at panoramicfeedback.com-20070717201334-xjv6yqp0zw0q16qs
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Thu 2007-07-19 11:44:17 -0400
    message:
      Tweak from review comments
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.51
    merged: abentley at panoramicfeedback.com-20070717201334-xjv6yqp0zw0q16qs
    parent: abentley at panoramicfeedback.com-20070717200413-jpganazttxzryrx8
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Tue 2007-07-17 16:13:34 -0400
    message:
      Update NEWS
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.50
    merged: abentley at panoramicfeedback.com-20070717200413-jpganazttxzryrx8
    parent: abentley at panoramicfeedback.com-20070717200342-sq5gq5m9fwu1a5xu
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Tue 2007-07-17 16:04:13 -0400
    message:
      Deprecate RevisionTree.get_weave
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.49
    merged: abentley at panoramicfeedback.com-20070717200342-sq5gq5m9fwu1a5xu
    parent: abentley at panoramicfeedback.com-20070717193816-e92ovxrfhq0st34d
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Tue 2007-07-17 16:03:42 -0400
    message:
      fix deprecations in remerge
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.48
    merged: abentley at panoramicfeedback.com-20070717193816-e92ovxrfhq0st34d
    parent: abentley at panoramicfeedback.com-20070717191823-43x0n5d5hy6qd6sl
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Tue 2007-07-17 15:38:16 -0400
    message:
      Add tests for annotate and plan_merge
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.47
    merged: abentley at panoramicfeedback.com-20070717191823-43x0n5d5hy6qd6sl
    parent: abentley at panoramicfeedback.com-20070717182849-ffu3wxsll06lhc9a
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Tue 2007-07-17 15:18:23 -0400
    message:
      Fix remerge --weave
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.46
    merged: abentley at panoramicfeedback.com-20070717182849-ffu3wxsll06lhc9a
    parent: abentley at panoramicfeedback.com-20070717174318-putlxtqf0b4op8d4
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Tue 2007-07-17 14:28:49 -0400
    message:
      Move plan merge to tree
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.45
    merged: abentley at panoramicfeedback.com-20070717174318-putlxtqf0b4op8d4
    parent: aaron.bentley at utoronto.ca-20070711045443-oi9vk0jgepts5k5s
    parent: pqm at pqm.ubuntu.com-20070717110203-zzmtp28nunhsoz12
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Tue 2007-07-17 13:43:18 -0400
    message:
      Merge from bzr.dev
=== modified file 'NEWS'
--- a/NEWS	2007-07-20 06:09:24 +0000
+++ b/NEWS	2007-07-20 12:56:33 +0000
@@ -43,6 +43,8 @@
     * New bundle and merge directive formats are faster to generate, and
       more robust against email mangling.  (Aaron Bentley)
 
+    * Annotate merge now works when there are local changes. (Aaron Bentley)
+
   LIBRARY API BREAKS:
 
     * Deprecated dictionary ``bzrlib.option.SHORT_OPTIONS`` removed.
@@ -77,6 +79,9 @@
 
     * Deprecated ``change_entry`` in transform.py. (Ian Clatworthy)
 
+    * RevisionTree.get_weave is now deprecated.  Tree.plan_merge is now used
+      for performing annotate-merge.  (Aaron Bentley)
+
   TESTING:
 
     * Remove selftest ``--clean-output``, ``--numbered-dirs`` and

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2007-07-20 07:33:21 +0000
+++ b/bzrlib/builtins.py	2007-07-20 12:56:33 +0000
@@ -2857,14 +2857,23 @@
                     restore(tree.abspath(filename))
                 except errors.NotConflicted:
                     pass
-            conflicts = _mod_merge.merge_inner(
-                                      tree.branch, other_tree, base_tree,
-                                      this_tree=tree,
-                                      interesting_ids=interesting_ids,
-                                      other_rev_id=parents[1],
-                                      merge_type=merge_type,
-                                      show_base=show_base,
-                                      reprocess=reprocess)
+            # Disable pending merges, because the file texts we are remerging
+            # have not had those merges performed.  If we use the wrong parents
+            # list, we imply that the working tree text has seen and rejected
+            # all the changes from the other tree, when in fact those changes
+            # have not yet been seen.
+            tree.set_parent_ids(parents[:1])
+            try:
+                conflicts = _mod_merge.merge_inner(
+                                          tree.branch, other_tree, base_tree,
+                                          this_tree=tree,
+                                          interesting_ids=interesting_ids,
+                                          other_rev_id=parents[1],
+                                          merge_type=merge_type,
+                                          show_base=show_base,
+                                          reprocess=reprocess)
+            finally:
+                tree.set_parent_ids(parents)
         finally:
             tree.unlock()
         if conflicts > 0:

=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py	2007-07-03 02:33:32 +0000
+++ b/bzrlib/inventory.py	2007-07-17 20:04:13 +0000
@@ -609,14 +609,14 @@
 
         if self.file_id not in checker.checked_weaves:
             mutter('check weave {%s}', self.file_id)
-            w = tree.get_weave(self.file_id)
+            w = tree._get_weave(self.file_id)
             # Not passing a progress bar, because it creates a new
             # progress, which overwrites the current progress,
             # and doesn't look nice
             w.check()
             checker.checked_weaves[self.file_id] = True
         else:
-            w = tree.get_weave(self.file_id)
+            w = tree._get_weave(self.file_id)
 
         mutter('check version {%s} of {%s}', tree_revision_id, self.file_id)
         checker.checked_text_cnt += 1

=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py	2007-07-17 13:27:14 +0000
+++ b/bzrlib/knit.py	2007-07-20 12:56:33 +0000
@@ -76,6 +76,7 @@
     osutils,
     patiencediff,
     progress,
+    merge,
     ui,
     )
 from bzrlib.errors import (
@@ -1020,41 +1021,12 @@
         ver_a = osutils.safe_revision_id(ver_a)
         ver_b = osutils.safe_revision_id(ver_b)
         ancestors_b = set(self.get_ancestry(ver_b, topo_sorted=False))
-        def status_a(revision, text):
-            if revision in ancestors_b:
-                return 'killed-b', text
-            else:
-                return 'new-a', text
         
         ancestors_a = set(self.get_ancestry(ver_a, topo_sorted=False))
-        def status_b(revision, text):
-            if revision in ancestors_a:
-                return 'killed-a', text
-            else:
-                return 'new-b', text
-
         annotated_a = self.annotate(ver_a)
         annotated_b = self.annotate(ver_b)
-        plain_a = [t for (a, t) in annotated_a]
-        plain_b = [t for (a, t) in annotated_b]
-        blocks = KnitSequenceMatcher(None, plain_a, plain_b).get_matching_blocks()
-        a_cur = 0
-        b_cur = 0
-        for ai, bi, l in blocks:
-            # process all mismatched sections
-            # (last mismatched section is handled because blocks always
-            # includes a 0-length last block)
-            for revision, text in annotated_a[a_cur:ai]:
-                yield status_a(revision, text)
-            for revision, text in annotated_b[b_cur:bi]:
-                yield status_b(revision, text)
-
-            # and now the matched section
-            a_cur = ai + l
-            b_cur = bi + l
-            for text_a, text_b in zip(plain_a[ai:a_cur], plain_b[bi:b_cur]):
-                assert text_a == text_b
-                yield "unchanged", text_a
+        return merge._plan_annotate_merge(annotated_a, annotated_b,
+                                          ancestors_a, ancestors_b)
 
 
 class _KnitComponentFile(object):

=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py	2007-07-17 13:27:14 +0000
+++ b/bzrlib/merge.py	2007-07-20 12:56:33 +0000
@@ -22,6 +22,7 @@
 from bzrlib import (
     errors,
     osutils,
+    patiencediff,
     registry,
     revision as _mod_revision,
     )
@@ -49,7 +50,7 @@
 from bzrlib.transform import (TreeTransform, resolve_conflicts, cook_conflicts,
                               conflict_pass, FinalPaths, create_by_entry,
                               unique_add, ROOT_PARENT)
-from bzrlib.versionedfile import WeaveMerge
+from bzrlib.versionedfile import PlanWeaveMerge
 from bzrlib import ui
 
 # TODO: Report back as changes are merged in
@@ -918,52 +919,27 @@
                  interesting_ids=None, pb=DummyProgress(), pp=None,
                  reprocess=False, change_reporter=None,
                  interesting_files=None):
-        self.this_revision_tree = self._get_revision_tree(this_tree)
-        self.other_revision_tree = self._get_revision_tree(other_tree)
         super(WeaveMerger, self).__init__(working_tree, this_tree, 
                                           base_tree, other_tree, 
                                           interesting_ids=interesting_ids, 
                                           pb=pb, pp=pp, reprocess=reprocess,
                                           change_reporter=change_reporter)
 
-    def _get_revision_tree(self, tree):
-        """Return a revision tree related to this tree.
-        If the tree is a WorkingTree, the basis will be returned.
-        """
-        if getattr(tree, 'get_weave', False) is False:
-            # If we have a WorkingTree, try using the basis
-            return tree.branch.basis_tree()
-        else:
-            return tree
-
-    def _check_file(self, file_id):
-        """Check that the revision tree's version of the file matches."""
-        for tree, rt in ((self.this_tree, self.this_revision_tree), 
-                         (self.other_tree, self.other_revision_tree)):
-            if rt is tree:
-                continue
-            if tree.get_file_sha1(file_id) != rt.get_file_sha1(file_id):
-                raise WorkingTreeNotRevision(self.this_tree)
-
     def _merged_lines(self, file_id):
         """Generate the merged lines.
         There is no distinction between lines that are meant to contain <<<<<<<
         and conflicts.
         """
-        weave = self.this_revision_tree.get_weave(file_id)
-        this_revision_id = self.this_revision_tree.inventory[file_id].revision
-        other_revision_id = \
-            self.other_revision_tree.inventory[file_id].revision
-        wm = WeaveMerge(weave, this_revision_id, other_revision_id, 
-                        '<<<<<<< TREE\n', '>>>>>>> MERGE-SOURCE\n')
-        return wm.merge_lines(self.reprocess)
+        plan = self.this_tree.plan_file_merge(file_id, self.other_tree)
+        textmerge = PlanWeaveMerge(plan, '<<<<<<< TREE\n',
+            '>>>>>>> MERGE-SOURCE\n')
+        return textmerge.merge_lines(self.reprocess)
 
     def text_merge(self, file_id, trans_id):
         """Perform a (weave) text merge for a given file and file-id.
         If conflicts are encountered, .THIS and .OTHER files will be emitted,
         and a conflict will be noted.
         """
-        self._check_file(file_id)
         lines, conflicts = self._merged_lines(file_id)
         lines = list(lines)
         # Note we're checking whether the OUTPUT is binary in this case, 
@@ -1065,3 +1041,39 @@
     """
     from bzrlib import option
     return option._merge_type_registry
+
+
+def _plan_annotate_merge(annotated_a, annotated_b, ancestors_a, ancestors_b):
+    def status_a(revision, text):
+        if revision in ancestors_b:
+            return 'killed-b', text
+        else:
+            return 'new-a', text
+
+    def status_b(revision, text):
+        if revision in ancestors_a:
+            return 'killed-a', text
+        else:
+            return 'new-b', text
+
+    plain_a = [t for (a, t) in annotated_a]
+    plain_b = [t for (a, t) in annotated_b]
+    matcher = patiencediff.PatienceSequenceMatcher(None, plain_a, plain_b)
+    blocks = matcher.get_matching_blocks()
+    a_cur = 0
+    b_cur = 0
+    for ai, bi, l in blocks:
+        # process all mismatched sections
+        # (last mismatched section is handled because blocks always
+        # includes a 0-length last block)
+        for revision, text in annotated_a[a_cur:ai]:
+            yield status_a(revision, text)
+        for revision, text in annotated_b[b_cur:bi]:
+            yield status_b(revision, text)
+
+        # and now the matched section
+        a_cur = ai + l
+        b_cur = bi + l
+        for text_a, text_b in zip(plain_a[ai:a_cur], plain_b[bi:b_cur]):
+            assert text_a == text_b
+            yield "unchanged", text_a

=== modified file 'bzrlib/revisiontree.py'
--- a/bzrlib/revisiontree.py	2007-03-06 12:28:18 +0000
+++ b/bzrlib/revisiontree.py	2007-07-17 20:04:13 +0000
@@ -21,6 +21,7 @@
 from bzrlib import (
     osutils,
     revision,
+    symbol_versioning,
     )
 from bzrlib.tree import Tree
 
@@ -61,7 +62,11 @@
         """Return the revision id associated with this tree."""
         return self._revision_id
 
+    @symbol_versioning.deprecated_method(symbol_versioning.zero_nineteen)
     def get_weave(self, file_id):
+        return self._get_weave(file_id)
+
+    def _get_weave(self, file_id):
         file_id = osutils.safe_file_id(file_id)
         return self._weave_store.get_weave(file_id,
                 self._repository.get_transaction())
@@ -69,7 +74,7 @@
     def get_file_lines(self, file_id):
         file_id = osutils.safe_file_id(file_id)
         ie = self._inventory[file_id]
-        weave = self.get_weave(file_id)
+        weave = self._get_weave(file_id)
         return weave.get_lines(ie.revision)
 
     def get_file_text(self, file_id):
@@ -80,10 +85,11 @@
         file_id = osutils.safe_file_id(file_id)
         return StringIO(self.get_file_text(file_id))
 
-    def annotate_iter(self, file_id):
+    def annotate_iter(self, file_id,
+                      default_revision=revision.CURRENT_REVISION):
         """See Tree.annotate_iter"""
         file_id = osutils.safe_file_id(file_id)
-        w = self.get_weave(file_id)
+        w = self._get_weave(file_id)
         return w.annotate_iter(self.inventory[file_id].revision)
 
     def get_file_size(self, file_id):
@@ -148,6 +154,10 @@
         assert entry.text_size is not None
         return entry.text_size
 
+    def _get_ancestors(self, default_revision):
+        return set(self._repository.get_ancestry(self._revision_id,
+                                                 topo_sorted=False))
+
     def lock_read(self):
         self._repository.lock_read()
 

=== modified file 'bzrlib/tests/test_merge_core.py'
--- a/bzrlib/tests/test_merge_core.py	2007-07-06 00:58:58 +0000
+++ b/bzrlib/tests/test_merge_core.py	2007-07-17 18:28:49 +0000
@@ -480,9 +480,6 @@
         self.assert_(os.path.lexists('b/file.THIS'))
         self.assert_(os.path.lexists('b/file.BASE'))
         self.assert_(os.path.lexists('b/file.OTHER'))
-        self.assertRaises(WorkingTreeNotRevision, merge, ['a', -1], 
-                          [None, None], this_dir='b', check_clean=False,
-                          merge_type=WeaveMerger)
         wtb.revert([])
         self.assertEqual(merge(['a', -1], [None, None], this_dir='b', 
                                check_clean=False, merge_type=WeaveMerger), 1)

=== modified file 'bzrlib/tests/tree_implementations/test_tree.py'
--- a/bzrlib/tests/tree_implementations/test_tree.py	2007-03-12 03:31:12 +0000
+++ b/bzrlib/tests/tree_implementations/test_tree.py	2007-07-19 15:44:17 +0000
@@ -28,12 +28,40 @@
         tree = self.get_tree_no_parents_abc_content(work_tree)
         tree_revision = getattr(tree, 'get_revision_id', lambda: 'current:')()
         tree.lock_read()
-        try:
-            for revision, line in tree.annotate_iter('a-id'):
-                self.assertEqual('contents of a\n', line)
-                self.assertEqual(tree_revision, revision)
-        finally:
-            tree.unlock()
+        self.addCleanup(tree.unlock)
+        for revision, line in tree.annotate_iter('a-id'):
+            self.assertEqual('contents of a\n', line)
+            self.assertEqual(tree_revision, revision)
+        tree_revision = getattr(tree, 'get_revision_id', lambda: 'random:')()
+        for revision, line in tree.annotate_iter('a-id', 'random:'):
+            self.assertEqual('contents of a\n', line)
+            self.assertEqual(tree_revision, revision)
+
+
+class TestPlanFileMerge(TestCaseWithTree):
+
+    def test_plan_file_merge(self):
+        work_a = self.make_branch_and_tree('wta')
+        self.build_tree_contents([('wta/file', 'a\nb\nc\nd\n')])
+        work_a.add('file', 'file-id')
+        work_a.commit('base version')
+        work_b = work_a.bzrdir.sprout('wtb').open_workingtree()
+        self.build_tree_contents([('wta/file', 'b\nc\nd\ne\n')])
+        tree_a = self.workingtree_to_test_tree(work_a)
+        tree_a.lock_read()
+        self.addCleanup(tree_a.unlock)
+        self.build_tree_contents([('wtb/file', 'a\nc\nd\nf\n')])
+        tree_b = self.workingtree_to_test_tree(work_b)
+        tree_b.lock_read()
+        self.addCleanup(tree_b.unlock)
+        self.assertEqual([
+            ('killed-b', 'b\n'),
+            ('killed-a', 'a\n'),
+            ('unchanged', 'c\n'),
+            ('unchanged', 'd\n'),
+            ('new-a', 'e\n'),
+            ('new-b', 'f\n'),
+        ], list(tree_a.plan_file_merge('file-id', tree_b)))
 
 
 class TestReference(TestCaseWithTree):

=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py	2007-04-13 19:45:40 +0000
+++ b/bzrlib/tree.py	2007-07-19 15:44:17 +0000
@@ -25,6 +25,7 @@
 from bzrlib import (
     delta,
     osutils,
+    revision as _mod_revision,
     symbol_versioning,
     )
 from bzrlib.decorators import needs_read_lock
@@ -244,6 +245,23 @@
         """
         raise NotImplementedError(self.annotate_iter)
 
+    def plan_file_merge(self, file_id, other):
+        """Generate a merge plan based on annotations
+
+        If the file contains uncommitted changes in this tree, they will be
+        attributed to the 'current:' pseudo-revision.  If the file contains
+        uncommitted changes in the other tree, they will be assigned to the
+        'other:' pseudo-revision.
+        """
+        from bzrlib import merge
+        annotated_a = list(self.annotate_iter(file_id,
+                                              _mod_revision.CURRENT_REVISION))
+        annotated_b = list(other.annotate_iter(file_id, 'other:'))
+        ancestors_a = self._get_ancestors(_mod_revision.CURRENT_REVISION)
+        ancestors_b = other._get_ancestors('other:')
+        return merge._plan_annotate_merge(annotated_a, annotated_b,
+                                          ancestors_a, ancestors_b)
+
     inventory = property(_get_inventory,
                          doc="Inventory of this Tree")
 

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2007-07-12 12:42:45 +0000
+++ b/bzrlib/workingtree.py	2007-07-17 18:28:49 +0000
@@ -460,7 +460,7 @@
         return file(self.abspath(filename), 'rb')
 
     @needs_read_lock
-    def annotate_iter(self, file_id):
+    def annotate_iter(self, file_id, default_revision=CURRENT_REVISION):
         """See Tree.annotate_iter
 
         This implementation will use the basis tree implementation if possible.
@@ -493,10 +493,17 @@
                     continue
                 old.append(list(tree.annotate_iter(file_id)))
             return annotate.reannotate(old, self.get_file(file_id).readlines(),
-                                       CURRENT_REVISION)
+                                       default_revision)
         finally:
             basis.unlock()
 
+    def _get_ancestors(self, default_revision):
+        ancestors = set([default_revision])
+        for parent_id in self.get_parent_ids():
+            ancestors.update(self.branch.repository.get_ancestry(
+                             parent_id, topo_sorted=False))
+        return ancestors
+
     def get_parent_ids(self):
         """See Tree.get_parent_ids.
         

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-07-12 20:43:51 +0000
+++ b/bzrlib/workingtree_4.py	2007-07-17 20:04:13 +0000
@@ -1346,12 +1346,15 @@
         return "<%s of %s in %s>" % \
             (self.__class__.__name__, self._revision_id, self._dirstate)
 
-    def annotate_iter(self, file_id):
+    def annotate_iter(self, file_id,
+                      default_revision=_mod_revision.CURRENT_REVISION):
         """See Tree.annotate_iter"""
-        w = self._repository.weave_store.get_weave(file_id,
-                           self._repository.get_transaction())
+        w = self._get_weave(file_id)
         return w.annotate_iter(self.inventory[file_id].revision)
 
+    def _get_ancestors(self, default_revision):
+        return set(self._repository.get_ancestry(self._revision_id,
+                                                 topo_sorted=False))
     def _comparison_data(self, entry, path):
         """See Tree._comparison_data."""
         if entry is None:
@@ -1490,7 +1493,11 @@
             return parent_details[1]
         return None
 
+    @symbol_versioning.deprecated_method(symbol_versioning.zero_nineteen)
     def get_weave(self, file_id):
+        return self._get_weave(file_id)
+
+    def _get_weave(self, file_id):
         return self._repository.weave_store.get_weave(file_id,
                 self._repository.get_transaction())
 
@@ -1499,8 +1506,7 @@
 
     def get_file_lines(self, file_id):
         ie = self.inventory[file_id]
-        return self._repository.weave_store.get_weave(file_id,
-                self._repository.get_transaction()).get_lines(ie.revision)
+        return self._get_weave(file_id).get_lines(ie.revision)
 
     def get_file_size(self, file_id):
         return self.inventory[file_id].text_size




More information about the bazaar-commits mailing list