Rev 5143: (Jelmer) Add Repository.get_known_graph_ancestry(). in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Sat Apr 10 19:03:58 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5143 [merge]
revision-id: pqm at pqm.ubuntu.com-20100410180354-4dft6p3nf7fvg50f
parent: pqm at pqm.ubuntu.com-20100410105439-cr8xiumgfetq517v
parent: jelmer at samba.org-20100410012200-y089oi8jwvx9khyh
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2010-04-10 19:03:54 +0100
message:
(Jelmer) Add Repository.get_known_graph_ancestry().
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/fetch.py fetch.py-20050818234941-26fea6105696365d
bzrlib/graph.py graph_walker.py-20070525030359-y852guab65d4wtn0-1
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
=== modified file 'NEWS'
--- a/NEWS 2010-04-10 09:22:04 +0000
+++ b/NEWS 2010-04-10 18:03:54 +0000
@@ -287,6 +287,9 @@
* New method ``BzrDir.list_branches()`` that returns a sequence of branches
present in a control directory. (Jelmer Vernooij)
+* New method ``Repository.get_known_graph_ancestry()``.
+ (Jelmer Vernooij, #495502)
+
* New transport methods ``readlink``, ``symlink`` and ``hardlink``.
(Neil Santos)
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2010-04-02 15:06:55 +0000
+++ b/bzrlib/branch.py 2010-04-10 18:03:54 +0000
@@ -447,11 +447,10 @@
# start_revision_id.
if self._merge_sorted_revisions_cache is None:
last_revision = self.last_revision()
- last_key = (last_revision,)
- known_graph = self.repository.revisions.get_known_graph_ancestry(
- [last_key])
+ known_graph = self.repository.get_known_graph_ancestry(
+ [last_revision])
self._merge_sorted_revisions_cache = known_graph.merge_sort(
- last_key)
+ last_revision)
filtered = self._filter_merge_sorted_revisions(
self._merge_sorted_revisions_cache, start_revision_id,
stop_revision_id, stop_rule)
=== modified file 'bzrlib/fetch.py'
--- a/bzrlib/fetch.py 2010-02-23 07:43:11 +0000
+++ b/bzrlib/fetch.py 2010-03-21 21:39:33 +0000
@@ -28,8 +28,6 @@
from bzrlib.lazy_import import lazy_import
lazy_import(globals(), """
from bzrlib import (
- graph as _mod_graph,
- static_tuple,
tsort,
versionedfile,
)
@@ -249,7 +247,7 @@
if len(revs) > 100:
# XXX: not covered by tests, should have a flag to always run
# this. -- mbp 20100129
- graph = _get_rich_root_heads_graph(self.source, revs)
+ graph = self.source_repo.get_known_graph_ancestry(revs)
new_roots_stream = _new_root_data_stream(
root_id_order, rev_id_to_root_id, parent_map, self.source, graph)
return [('texts', new_roots_stream)]
@@ -257,11 +255,7 @@
def _get_rich_root_heads_graph(source_repo, revision_ids):
"""Get a Graph object suitable for asking heads() for new rich roots."""
- st = static_tuple.StaticTuple
- revision_keys = [st(r_id).intern() for r_id in revision_ids]
- known_graph = source_repo.revisions.get_known_graph_ancestry(
- revision_keys)
- return _mod_graph.GraphThunkIdsToKeys(known_graph)
+ return
def _new_root_data_stream(
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py 2010-02-17 17:11:16 +0000
+++ b/bzrlib/graph.py 2010-04-10 01:22:00 +0000
@@ -1685,12 +1685,18 @@
def __init__(self, graph):
self._graph = graph
+ def topo_sort(self):
+ return [r for (r,) in self._graph.topo_sort()]
+
def heads(self, ids):
"""See Graph.heads()"""
as_keys = [(i,) for i in ids]
head_keys = self._graph.heads(as_keys)
return set([h[0] for h in head_keys])
+ def merge_sort(self, tip_revision):
+ return self._graph.merge_sort((tip_revision,))
+
_counters = [0,0,0,0,0,0,0]
try:
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2010-03-11 18:00:23 +0000
+++ b/bzrlib/remote.py 2010-03-21 21:39:33 +0000
@@ -29,6 +29,7 @@
repository,
revision,
revision as _mod_revision,
+ static_tuple,
symbol_versioning,
)
from bzrlib.branch import BranchReferenceFormat
@@ -903,6 +904,15 @@
parents_provider = self._make_parents_provider(other_repository)
return graph.Graph(parents_provider)
+ @needs_read_lock
+ def get_known_graph_ancestry(self, revision_ids):
+ """Return the known graph for a set of revision ids and their ancestors.
+ """
+ st = static_tuple.StaticTuple
+ revision_keys = [st(r_id).intern() for r_id in revision_ids]
+ known_graph = self.revisions.get_known_graph_ancestry(revision_keys)
+ return graph.GraphThunkIdsToKeys(known_graph)
+
def gather_stats(self, revid=None, committers=None):
"""See Repository.gather_stats()."""
path = self.bzrdir._path_for_remote_call(self._client)
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2010-03-26 10:25:47 +0000
+++ b/bzrlib/repository.py 2010-04-10 18:03:54 +0000
@@ -40,6 +40,7 @@
lru_cache,
osutils,
revision as _mod_revision,
+ static_tuple,
symbol_versioning,
trace,
tsort,
@@ -2626,6 +2627,15 @@
def _make_parents_provider(self):
return self
+ @needs_read_lock
+ def get_known_graph_ancestry(self, revision_ids):
+ """Return the known graph for a set of revision ids and their ancestors.
+ """
+ st = static_tuple.StaticTuple
+ revision_keys = [st(r_id).intern() for r_id in revision_ids]
+ known_graph = self.revisions.get_known_graph_ancestry(revision_keys)
+ return graph.GraphThunkIdsToKeys(known_graph)
+
def get_graph(self, other_repository=None):
"""Return the graph walker for this repository format"""
parents_provider = self._make_parents_provider()
=== modified file 'bzrlib/tests/per_repository/test_repository.py'
--- a/bzrlib/tests/per_repository/test_repository.py 2010-02-23 07:43:11 +0000
+++ b/bzrlib/tests/per_repository/test_repository.py 2010-04-10 01:22:00 +0000
@@ -724,6 +724,25 @@
self.assertTrue('ghost' not in parents)
self.assertEqual(parents['rev2'], ('rev1', 'ghost'))
+ def test_get_known_graph_ancestry(self):
+ tree = self.make_branch_and_tree('here')
+ tree.lock_write()
+ self.addCleanup(tree.unlock)
+ # A
+ # |\
+ # | B
+ # |/
+ # C
+ tree.commit('initial commit', rev_id='A')
+ tree_other = tree.bzrdir.sprout('there').open_workingtree()
+ tree_other.commit('another', rev_id='B')
+ tree.merge_from_branch(tree_other.branch)
+ tree.commit('another', rev_id='C')
+ kg = tree.branch.repository.get_known_graph_ancestry(
+ ['C'])
+ self.assertEqual(['C'], list(kg.heads(['A', 'B', 'C'])))
+ self.assertEqual(['A', 'B', 'C'], list(kg.topo_sort()))
+
def test_parent_map_type(self):
tree = self.make_branch_and_tree('here')
tree.lock_write()
More information about the bazaar-commits
mailing list