Rev 3297: * ``VersionedFile.get_graph`` is deprecated, with no replacement method. in http://people.ubuntu.com/~robertc/baz2.0/versioned_files

Robert Collins robertc at robertcollins.net
Wed Mar 26 21:42:59 GMT 2008


At http://people.ubuntu.com/~robertc/baz2.0/versioned_files

------------------------------------------------------------
revno: 3297
revision-id: robertc at robertcollins.net-20080326214235-3wmnqamcgytwif89
parent: robertc at robertcollins.net-20080326011541-h9cxdap8x5pafq13
committer: Robert Collins <robertc at robertcollins.net>
branch nick: versionedfile.apicleanup
timestamp: Thu 2008-03-27 08:42:35 +1100
message:
   * ``VersionedFile.get_graph`` is deprecated, with no replacement method.
     The method was size(history) and not desirable. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
  bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
  bzrlib/reconcile.py            reweave_inventory.py-20051108164726-1e5e0934febac06e
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/repofmt/knitrepo.py     knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
  bzrlib/repofmt/weaverepo.py    presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
  bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
  bzrlib/revision.py             revision.py-20050309040759-e77802c08f3999d5
  bzrlib/smart/repository.py     repository.py-20061128022038-vr5wy5bubyb8xttk-1
  bzrlib/tests/interversionedfile_implementations/test_join.py test_join.py-20060302012326-9b5e9b0f0a03fedc
  bzrlib/tests/repository_implementations/test_reconcile.py test_reconcile.py-20060223022332-572ef70a3288e369
  bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
  bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
  bzrlib/versionedfile.py        versionedfile.py-20060222045106-5039c71ee3b65490
=== modified file 'NEWS'
--- a/NEWS	2008-03-26 01:15:41 +0000
+++ b/NEWS	2008-03-26 21:42:35 +0000
@@ -63,6 +63,9 @@
       show_merge_revno methods. The latter had been deprecated since the 0.17
       release. (James Westby)
 
+    * ``VersionedFile.get_graph`` is deprecated, with no replacement method.
+      The method was size(history) and not desirable. (Robert Collins)
+
     * ``VersionedFile.get_parents`` is deprecated, please use
       ``VersionedFile.get_parent_map``. (Robert Collins)
 

=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2008-03-14 10:55:37 +0000
+++ b/bzrlib/branch.py	2008-03-26 21:42:35 +0000
@@ -192,7 +192,17 @@
         :return: A dictionary mapping revision_id => dotted revno.
         """
         last_revision = self.last_revision()
-        revision_graph = self.repository.get_revision_graph(last_revision)
+        graph = self.repository.get_graph()
+        search = graph._make_breadth_first_searcher([last_revision])
+        transitive_ids = set()
+        map(transitive_ids.update, list(search))
+        revision_graph = graph.get_parent_map(transitive_ids)
+        # Filter ghosts, and null:
+        if _mod_revision.NULL_REVISION in revision_graph:
+            del revision_graph[_mod_revision.NULL_REVISION]
+        for key, parents in revision_graph.items():
+            revision_graph[key] = tuple(parent for parent in parents if parent
+                in revision_graph)
         merge_sorted_revisions = tsort.merge_sort(
             revision_graph,
             last_revision,

=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py	2008-03-20 01:31:04 +0000
+++ b/bzrlib/knit.py	2008-03-26 21:42:35 +0000
@@ -101,7 +101,7 @@
     RevisionNotPresent,
     RevisionAlreadyPresent,
     )
-from bzrlib.tuned_gzip import GzipFile, bytes_to_gzip
+from bzrlib.graph import Graph
 from bzrlib.osutils import (
     contains_whitespace,
     contains_linebreaks,
@@ -110,9 +110,10 @@
     )
 from bzrlib.symbol_versioning import DEPRECATED_PARAMETER, deprecated_passed
 from bzrlib.tsort import topo_sort
+from bzrlib.tuned_gzip import GzipFile, bytes_to_gzip
 import bzrlib.ui
+from bzrlib.versionedfile import VersionedFile, InterVersionedFile
 import bzrlib.weave
-from bzrlib.versionedfile import VersionedFile, InterVersionedFile
 
 
 # TODO: Split out code specific to this format into an associated object.
@@ -2673,8 +2674,14 @@
         see join() for the parameter definitions.
         """
         version_ids = self._get_source_version_ids(version_ids, ignore_missing)
-        graph = self.source.get_graph(version_ids)
-        order = topo_sort(graph.items())
+        # --- the below is factorable out with VersionedFile.join, but wait for
+        # VersionedFiles, it may all be simpler then.
+        graph = Graph(self.source)
+        search = graph._make_breadth_first_searcher(version_ids)
+        transitive_ids = set()
+        map(transitive_ids.update, list(search))
+        parent_map = self.source.get_parent_map(transitive_ids)
+        order = topo_sort(parent_map.items())
 
         def size_of_content(content):
             return sum(len(line) for line in content.text())
@@ -2741,7 +2748,8 @@
     
             if not needed_versions:
                 return 0
-            full_list = topo_sort(self.source.get_graph())
+            full_list = topo_sort(
+                self.source.get_parent_map(self.source.versions()))
     
             version_list = [i for i in full_list if (not self.target.has_version(i)
                             and i in needed_versions)]
@@ -2843,7 +2851,8 @@
     
             if not needed_versions:
                 return 0
-            full_list = topo_sort(self.source.get_graph())
+            full_list = topo_sort(
+                self.source.get_parent_map(self.source.versions()))
     
             version_list = [i for i in full_list if (not self.target.has_version(i)
                             and i in needed_versions)]

=== modified file 'bzrlib/log.py'
--- a/bzrlib/log.py	2008-03-24 14:23:15 +0000
+++ b/bzrlib/log.py	2008-03-26 21:42:35 +0000
@@ -459,11 +459,18 @@
     weave_modifed_revisions = set(file_weave.versions())
     # build the ancestry of each revision in the graph
     # - only listing the ancestors that change the specific file.
-    rev_graph = branch.repository.get_revision_graph(mainline_revisions[-1])
-    sorted_rev_list = topo_sort(rev_graph)
+    graph = branch.repository.get_graph()
+    # This asks for all mainline revisions, which means we only have to spider
+    # sideways, rather than depth history. That said, its still size-of-history
+    # and should be addressed.
+    search = graph._make_breadth_first_searcher(mainline_revisions)
+    transitive_ids = set()
+    map(transitive_ids.update, list(search))
+    parent_map = graph.get_parent_map(transitive_ids)
+    sorted_rev_list = topo_sort(parent_map.items())
     ancestry = {}
     for rev in sorted_rev_list:
-        parents = rev_graph[rev]
+        parents = parent_map[rev]
         if rev not in weave_modifed_revisions and len(parents) == 1:
             # We will not be adding anything new, so just use a reference to
             # the parent ancestry.
@@ -477,7 +484,7 @@
         ancestry[rev] = rev_ancestry
 
     def is_merging_rev(r):
-        parents = rev_graph[r]
+        parents = parent_map[r]
         if len(parents) > 1:
             leftparent = parents[0]
             for rightparent in parents[1:]:
@@ -505,8 +512,24 @@
         for revision_id in revision_ids:
             yield revision_id, str(rev_nos[revision_id]), 0
         return
+    graph = branch.repository.get_graph()
+    # This asks for all mainline revisions, which means we only have to spider
+    # sideways, rather than depth history. That said, its still size-of-history
+    # and should be addressed.
+    search = graph._make_breadth_first_searcher(mainline_revs)
+    transitive_ids = set()
+    map(transitive_ids.update, list(search))
+    parent_map = graph.get_parent_map(transitive_ids)
+    # filter out ghosts; merge_sort errors on ghosts.
+    rev_graph = {}
+    # Filter ghosts, and null:
+    if NULL_REVISION in parent_map:
+        del parent_map[NULL_REVISION]
+    for key, parents in parent_map.iteritems():
+        rev_graph[key] = tuple(parent for parent in parents if parent in
+            parent_map)
     merge_sorted_revisions = merge_sort(
-        branch.repository.get_revision_graph(mainline_revs[-1]),
+        rev_graph,
         mainline_revs[-1],
         mainline_revs,
         generate_revno=True)

=== modified file 'bzrlib/reconcile.py'
--- a/bzrlib/reconcile.py	2008-03-19 04:39:04 +0000
+++ b/bzrlib/reconcile.py	2008-03-26 21:42:35 +0000
@@ -333,10 +333,10 @@
 
         # we have topological order of revisions and non ghost parents ready.
         self._setup_steps(len(self.revisions))
-        graph = self.revisions.get_graph()
-        parent_map = self.revisions.get_parent_map(graph.keys())
+        revision_ids = self.revisions.versions()
+        graph = self.revisions.get_parent_map(revision_ids)
         for rev_id in TopoSorter(graph.items()).iter_topo_order():
-            parents = parent_map[rev_id]
+            parents = graph[rev_id]
             # double check this really is in topological order, ignoring existing ghosts.
             unavailable = [p for p in parents if p not in new_inventory_vf and
                 p in self.revisions]

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2008-03-14 10:55:37 +0000
+++ b/bzrlib/remote.py	2008-03-26 21:42:35 +0000
@@ -361,6 +361,7 @@
         self._ensure_real()
         return self._real_repository._generate_text_key_index()
 
+    @symbol_versioning.deprecated_method(symbol_versioning.one_four)
     def get_revision_graph(self, revision_id=None):
         """See Repository.get_revision_graph()."""
         if revision_id is None:
@@ -836,6 +837,10 @@
             # We already found out that the server can't understand
             # Repository.get_parent_map requests, so just fetch the whole
             # graph.
+            # XXX: Note that this will issue a deprecation warning. This is ok
+            # :- its because we're working with a deprecated server anyway, and
+            # the user will almost certainly have seen a warning about the
+            # server version already.
             return self.get_revision_graph()
 
         keys = set(keys)

=== modified file 'bzrlib/repofmt/knitrepo.py'
--- a/bzrlib/repofmt/knitrepo.py	2008-03-19 04:39:04 +0000
+++ b/bzrlib/repofmt/knitrepo.py	2008-03-26 21:42:35 +0000
@@ -195,6 +195,7 @@
         revision_id = osutils.safe_revision_id(revision_id)
         return self.get_revision_reconcile(revision_id)
 
+    @symbol_versioning.deprecated_method(symbol_versioning.one_four)
     @needs_read_lock
     def get_revision_graph(self, revision_id=None):
         """Return a dictionary containing the revision graph.

=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2008-03-14 10:55:37 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2008-03-26 21:42:35 +0000
@@ -1928,6 +1928,7 @@
             found_parents[key[0]] = parents
         return found_parents
 
+    @symbol_versioning.deprecated_method(symbol_versioning.one_four)
     @needs_read_lock
     def get_revision_graph(self, revision_id=None):
         """Return a dictionary containing the revision graph.

=== modified file 'bzrlib/repofmt/weaverepo.py'
--- a/bzrlib/repofmt/weaverepo.py	2008-03-19 04:39:04 +0000
+++ b/bzrlib/repofmt/weaverepo.py	2008-03-26 21:42:35 +0000
@@ -43,6 +43,7 @@
     RepositoryFormat,
     )
 from bzrlib.store.text import TextStore
+from bzrlib.symbol_versioning import deprecated_method, one_four
 from bzrlib.trace import mutter
 
 
@@ -141,6 +142,7 @@
             self._check_revision_parents(rev, inv)
         return revs
 
+    @deprecated_method(one_four)
     @needs_read_lock
     def get_revision_graph(self, revision_id=None):
         """Return a dictionary containing the revision graph.
@@ -282,6 +284,7 @@
         self._check_revision_parents(r, inv)
         return r
 
+    @deprecated_method(one_four)
     @needs_read_lock
     def get_revision_graph(self, revision_id=None):
         """Return a dictionary containing the revision graph.

=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py	2008-03-19 04:39:04 +0000
+++ b/bzrlib/repository.py	2008-03-26 21:42:35 +0000
@@ -1338,9 +1338,8 @@
         """
         # All revisions, to find inventory parents.
         if ancestors is None:
-            # self.get_revision_graph_with_ghosts().get_ancestors() wasn't
-            # returning any ghosts anyway.
-            ancestors = self.get_revision_graph()
+            graph = self.get_graph()
+            ancestors = graph.get_parent_map(self.all_revision_ids())
         if text_key_references is None:
             text_key_references = self.find_text_key_references()
         pb = ui.ui_factory.nested_progress_bar()
@@ -1552,6 +1551,7 @@
         return self.get_revision(revision_id).inventory_sha1
 
     @needs_read_lock
+    @deprecated_method(symbol_versioning.one_four)
     def get_revision_graph(self, revision_id=None):
         """Return a dictionary containing the revision graph.
 

=== modified file 'bzrlib/revision.py'
--- a/bzrlib/revision.py	2008-03-10 15:39:56 +0000
+++ b/bzrlib/revision.py	2008-03-26 21:42:35 +0000
@@ -188,6 +188,7 @@
     return matches
 
 
+ at deprecated_function(symbol_versioning.one_four)
 def revision_graph(revision, revision_source):
     """Produce a graph of the ancestry of the specified revision.
     

=== modified file 'bzrlib/smart/repository.py'
--- a/bzrlib/smart/repository.py	2008-03-16 00:39:40 +0000
+++ b/bzrlib/smart/repository.py	2008-03-26 21:42:35 +0000
@@ -87,6 +87,18 @@
             repository.unlock()
 
 
+class SmartServerRepositoryReadLocked(SmartServerRepositoryRequest):
+    """Calls self.do_readlocked_repository_request."""
+
+    def do_repository_request(self, repository, *args):
+        """Read lock a repository for do_readlocked_repository_request."""
+        repository.lock_read()
+        try:
+            return self.do_readlocked_repository_request(repository, *args)
+        finally:
+            repository.unlock()
+
+
 class SmartServerRepositoryGetParentMap(SmartServerRepositoryRequest):
     """Bzr 1.2+ - get parent data for revisions during a graph search."""
     
@@ -173,10 +185,12 @@
             ('ok', ), bz2.compress('\n'.join(lines)))
 
 
-class SmartServerRepositoryGetRevisionGraph(SmartServerRepositoryRequest):
+class SmartServerRepositoryGetRevisionGraph(SmartServerRepositoryReadLocked):
     
-    def do_repository_request(self, repository, revision_id):
+    def do_readlocked_repository_request(self, repository, revision_id):
         """Return the result of repository.get_revision_graph(revision_id).
+
+        Deprecated as of bzr 1.4, but supported for older clients.
         
         :param repository: The repository to query in.
         :param revision_id: The utf8 encoded revision_id to get a graph from.
@@ -187,9 +201,22 @@
             revision_id = None
 
         lines = []
-        try:
-            revision_graph = repository.get_revision_graph(revision_id)
-        except errors.NoSuchRevision:
+        graph = repository.get_graph()
+        if revision_id:
+            search_ids = [revision_id]
+        else:
+            search_ids = repository.all_revision_ids()
+        search = graph._make_breadth_first_searcher(search_ids)
+        transitive_ids = set()
+        map(transitive_ids.update, list(search))
+        parent_map = graph.get_parent_map(transitive_ids)
+        revision_graph = {}
+        if _mod_revision.NULL_REVISION in parent_map:
+            del parent_map[_mod_revision.NULL_REVISION]
+        for key, parents in parent_map.iteritems():
+            revision_graph[key] = tuple(parent for parent in parents if
+                parent in parent_map)
+        if revision_id and revision_id not in revision_graph:
             # Note that we return an empty body, rather than omitting the body.
             # This way the client knows that it can always expect to find a body
             # in the response for this method, even in the error case.

=== modified file 'bzrlib/tests/interversionedfile_implementations/test_join.py'
--- a/bzrlib/tests/interversionedfile_implementations/test_join.py	2008-03-20 00:43:25 +0000
+++ b/bzrlib/tests/interversionedfile_implementations/test_join.py	2008-03-26 21:42:35 +0000
@@ -242,7 +242,6 @@
             self.assertTrue(source_ghosts)
         # legacy apis should behave
         self.assertEqual(['notbase'], source.get_ancestry(['notbase']))
-        self.assertEqual({'notbase':()}, source.get_graph())
         self.assertFalse(source.has_version('base'))
         # ghost data should have been preserved
         self.assertEqual(['base', 'notbase'], source.get_ancestry_with_ghosts(['notbase']))
@@ -254,13 +253,12 @@
         # if we add something that is fills out what is a ghost, then 
         # when joining into a ghost aware join it should flesh out the ghosts.
         source.add_lines('base', [], [])
-        target.join(source, version_ids=['base']) 
+        target.join(source, version_ids=['base'])
         self.assertEqual(['base', 'notbase'], target.get_ancestry(['notbase']))
-        self.assertEqual({'notbase':('base',)}, target.get_parent_map(['notbase']))
         self.assertEqual({'base':(),
                           'notbase':('base', ),
                           },
-                         target.get_graph())
+                         target.get_parent_map(target.versions()))
         self.assertTrue(target.has_version('base'))
         # we have _with_ghost apis to give us ghost information.
         self.assertEqual(['base', 'notbase'], target.get_ancestry_with_ghosts(['notbase']))

=== modified file 'bzrlib/tests/repository_implementations/test_reconcile.py'
--- a/bzrlib/tests/repository_implementations/test_reconcile.py	2007-11-29 01:45:12 +0000
+++ b/bzrlib/tests/repository_implementations/test_reconcile.py	2008-03-26 21:42:35 +0000
@@ -345,9 +345,14 @@
         t = get_transport(self.get_url()).clone('wrong-first-parent')
         d = bzrlib.bzrdir.BzrDir.open_from_transport(t)
         repo = d.open_repository()
-        g = repo.get_revision_graph()
-        if tuple(g['wrong-first-parent']) == ('1', '2'):
-            raise TestSkipped('wrong-first-parent is not setup for testing')
+        repo.lock_read()
+        try:
+            g = repo.get_graph()
+            if g.get_parent_map(['wrong-first-parent'])['wrong-first-parent'] \
+                == ('1', '2'):
+                raise TestSkipped('wrong-first-parent is not setup for testing')
+        finally:
+            repo.unlock()
         self.checkUnreconciled(d, repo.reconcile())
         # nothing should have been altered yet : inventories without
         # revisions are not data loss incurring for current format
@@ -357,8 +362,12 @@
         # and no garbage inventories
         self.assertEqual(0, reconciler.garbage_inventories)
         # and should have been fixed:
-        g = repo.get_revision_graph()
-        self.assertEqual(('1', '2'), g['wrong-first-parent'])
+        repo.lock_read()
+        self.addCleanup(repo.unlock)
+        g = repo.get_graph()
+        self.assertEqual(
+            {'wrong-first-parent':('1', '2')},
+            g.get_parent_map(['wrong-first-parent']))
 
     def test_reconcile_wrong_order_secondary_inventory(self):
         # a wrong order in the parents for inventories is ignored.

=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py	2008-03-10 15:39:56 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py	2008-03-26 21:42:35 +0000
@@ -36,7 +36,7 @@
     )
 from bzrlib.revision import NULL_REVISION, Revision
 from bzrlib.smart import server
-from bzrlib.symbol_versioning import one_two, one_three
+from bzrlib.symbol_versioning import one_two, one_three, one_four
 from bzrlib.tests import (
     KnownFailure,
     TestCaseWithTransport,
@@ -915,24 +915,28 @@
                           'rev3':('rev2', ),
                           'rev4':('rev3', ),
                           },
-                         self.bzrdir.open_repository().get_revision_graph(None))
+            self.applyDeprecated(one_four,
+                self.bzrdir.open_repository().get_revision_graph, None))
         self.assertEqual({'rev1':()},
-                         self.bzrdir.open_repository().get_revision_graph('rev1'))
+            self.applyDeprecated(one_four,
+                self.bzrdir.open_repository().get_revision_graph, 'rev1'))
         self.assertEqual({'rev1':(),
                           'rev2':('rev1', )},
-                         self.bzrdir.open_repository().get_revision_graph('rev2'))
-        self.assertRaises(errors.NoSuchRevision,
-                          self.bzrdir.open_repository().get_revision_graph,
-                          'orphan')
+            self.applyDeprecated(one_four,
+                self.bzrdir.open_repository().get_revision_graph, 'rev2'))
+        self.assertRaises(errors.NoSuchRevision, self.applyDeprecated, one_four,
+            self.bzrdir.open_repository().get_revision_graph, 'orphan')
         # and ghosts are not mentioned
         self.assertEqual({'rev1':(),
                           'rev2':('rev1', ),
                           'rev3':('rev2', ),
                           },
-                         self.bzrdir.open_repository().get_revision_graph('rev3'))
+            self.applyDeprecated(one_four,
+                self.bzrdir.open_repository().get_revision_graph, 'rev3'))
         # and we can ask for the NULLREVISION graph
         self.assertEqual({},
-            self.bzrdir.open_repository().get_revision_graph(NULL_REVISION))
+            self.applyDeprecated(one_four,
+                self.bzrdir.open_repository().get_revision_graph, NULL_REVISION))
 
     def test_get_revision_graph_with_ghosts(self):
         # we can get a graph object with roots, ghosts, ancestors and

=== modified file 'bzrlib/tests/test_log.py'
--- a/bzrlib/tests/test_log.py	2008-01-10 22:34:09 +0000
+++ b/bzrlib/tests/test_log.py	2008-03-26 21:42:35 +0000
@@ -685,6 +685,8 @@
     def test_get_view_revisions_forward(self):
         """Test the get_view_revisions method"""
         mainline_revs, rev_nos, wt = self.make_tree_with_commits()
+        wt.lock_read()
+        self.addCleanup(wt.unlock)
         revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
                                             'forward'))
         self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0)],
@@ -696,6 +698,8 @@
     def test_get_view_revisions_reverse(self):
         """Test the get_view_revisions with reverse"""
         mainline_revs, rev_nos, wt = self.make_tree_with_commits()
+        wt.lock_read()
+        self.addCleanup(wt.unlock)
         revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
                                             'reverse'))
         self.assertEqual([('3', '3', 0), ('2', '2', 0), ('1', '1', 0), ],
@@ -707,6 +711,8 @@
     def test_get_view_revisions_merge(self):
         """Test get_view_revisions when there are merges"""
         mainline_revs, rev_nos, wt = self.make_tree_with_merges()
+        wt.lock_read()
+        self.addCleanup(wt.unlock)
         revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
                                             'forward'))
         self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0),
@@ -721,6 +727,8 @@
     def test_get_view_revisions_merge_reverse(self):
         """Test get_view_revisions in reverse when there are merges"""
         mainline_revs, rev_nos, wt = self.make_tree_with_merges()
+        wt.lock_read()
+        self.addCleanup(wt.unlock)
         revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
                                             'reverse'))
         self.assertEqual([('4b', '4', 0), ('4a', '3.1.1', 1),
@@ -735,6 +743,8 @@
     def test_get_view_revisions_merge2(self):
         """Test get_view_revisions when there are merges"""
         mainline_revs, rev_nos, wt = self.make_tree_with_many_merges()
+        wt.lock_read()
+        self.addCleanup(wt.unlock)
         revisions = list(get_view_revisions(mainline_revs, rev_nos, wt.branch,
                                             'forward'))
         expected = [('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),

=== modified file 'bzrlib/versionedfile.py'
--- a/bzrlib/versionedfile.py	2008-03-19 04:48:03 +0000
+++ b/bzrlib/versionedfile.py	2008-03-26 21:42:35 +0000
@@ -30,6 +30,7 @@
     revision,
     ui,
     )
+from bzrlib.graph import Graph
 from bzrlib.transport.memory import MemoryTransport
 """)
 
@@ -775,8 +776,12 @@
             temp_source = self.target.create_empty("temp", MemoryTransport())
             target = temp_source
         version_ids = self._get_source_version_ids(version_ids, ignore_missing)
-        graph = self.source.get_graph(version_ids)
-        order = tsort.topo_sort(graph.items())
+        graph = Graph(self.source)
+        search = graph._make_breadth_first_searcher(version_ids)
+        transitive_ids = set()
+        map(transitive_ids.update, list(search))
+        parent_map = self.source.get_parent_map(transitive_ids)
+        order = tsort.topo_sort(parent_map.items())
         pb = ui.ui_factory.nested_progress_bar()
         parent_texts = {}
         try:
@@ -794,7 +799,6 @@
             # memory pressure reduction. RBC 20060313
             # pb.update('Converting versioned data', 0, len(order))
             total = len(order)
-            parent_map = self.source.get_parent_map(order)
             for index, version in enumerate(order):
                 pb.update('Converting versioned data', index, total)
                 _, _, parent_text = target.add_lines(version,




More information about the bazaar-commits mailing list