Rev 2981: Per-file graph heads detection during commit for pack repositories. in http://people.ubuntu.com/~robertc/baz2.0/commit.merge-speed
Robert Collins
robertc at robertcollins.net
Mon Nov 12 22:58:09 GMT 2007
At http://people.ubuntu.com/~robertc/baz2.0/commit.merge-speed
------------------------------------------------------------
revno: 2981
revision-id:robertc at robertcollins.net-20071112225758-co7hf9fpdonhkzs8
parent: robertc at robertcollins.net-20071112210301-da1gpusi4p68xhxj
committer: Robert Collins <robertc at robertcollins.net>
branch nick: commit.merge-speed
timestamp: Tue 2007-11-13 09:57:58 +1100
message:
Per-file graph heads detection during commit for pack repositories.
modified:
bzrlib/graph.py graph_walker.py-20070525030359-y852guab65d4wtn0-1
bzrlib/index.py index.py-20070712131115-lolkarso50vjr64s-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py 2007-10-24 06:48:13 +0000
+++ b/bzrlib/graph.py 2007-11-12 22:57:58 +0000
@@ -19,7 +19,6 @@
tsort,
)
from bzrlib.deprecated_graph import (node_distances, select_farthest)
-from bzrlib.revision import NULL_REVISION
# DIAGRAM of terminology
# A
=== modified file 'bzrlib/index.py'
--- a/bzrlib/index.py 2007-10-18 01:17:01 +0000
+++ b/bzrlib/index.py 2007-11-12 22:57:58 +0000
@@ -32,6 +32,7 @@
lazy_import(globals(), """
from bzrlib import trace
from bzrlib.bisect_multi import bisect_multi_bytes
+from bzrlib.revision import NULL_REVISION
from bzrlib.trace import mutter
""")
from bzrlib import debug, errors
@@ -994,6 +995,38 @@
self.__class__.__name__,
', '.join(map(repr, self._indices)))
+ def get_parents(self, revision_ids):
+ """See StackedParentsProvider.get_parents.
+
+ This implementation thunks the graph.Graph.get_parents api across to
+ GraphIndex.
+
+ :param revision_ids: An iterable of graph keys for this graph.
+ :return: A list of parent details for each key in revision_ids.
+ Each parent details will be one of:
+ * None when the key was missing
+ * (NULL_REVISION,) when the key has no parents.
+ * (parent_key, parent_key...) otherwise.
+ """
+ search_keys = set(revision_ids)
+ if NULL_REVISION in search_keys:
+ search_keys.remove(NULL_REVISION)
+ found_parents = {NULL_REVISION:[]}
+ for index, key, value, refs in self.iter_entries(search_keys):
+ parents = refs[0]
+ if not parents:
+ parents = (NULL_REVISION,)
+ else:
+ parents = refs[0]
+ found_parents[key] = parents
+ result = []
+ for key in revision_ids:
+ try:
+ result.append(found_parents[key])
+ except KeyError:
+ result.append(None)
+ return result
+
def insert_index(self, pos, index):
"""Insert a new index in the list of indices to query.
=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py 2007-11-07 13:10:37 +0000
+++ b/bzrlib/repofmt/pack_repo.py 2007-11-12 22:57:58 +0000
@@ -26,6 +26,7 @@
pack,
ui,
)
+from bzrlib.graph import Graph
from bzrlib.index import (
GraphIndex,
GraphIndexBuilder,
@@ -72,11 +73,24 @@
added text, reducing memory and object pressure.
"""
+ def __init__(self, repository, parents, config, timestamp=None,
+ timezone=None, committer=None, revprops=None,
+ revision_id=None):
+ CommitBuilder.__init__(self, repository, parents, config,
+ timestamp=timestamp, timezone=timezone, committer=committer,
+ revprops=revprops, revision_id=revision_id)
+ self._file_graph = Graph(
+ repository._pack_collection.text_index.combined_index)
+
def _add_text_to_weave(self, file_id, new_lines, parents, nostore_sha):
return self.repository._pack_collection._add_text_to_weave(file_id,
self._new_revision_id, new_lines, parents, nostore_sha,
self.random_revid)
+ def heads(self, file_id, revision_ids):
+ keys = [(file_id, revision_id) for revision_id in revision_ids]
+ return set([key[1] for key in self._file_graph.heads(keys)])
+
class PackRootCommitBuilder(RootCommitBuilder):
"""A subclass of RootCommitBuilder to add texts with pack semantics.
@@ -85,11 +99,24 @@
added text, reducing memory and object pressure.
"""
+ def __init__(self, repository, parents, config, timestamp=None,
+ timezone=None, committer=None, revprops=None,
+ revision_id=None):
+ CommitBuilder.__init__(self, repository, parents, config,
+ timestamp=timestamp, timezone=timezone, committer=committer,
+ revprops=revprops, revision_id=revision_id)
+ self._file_graph = Graph(
+ repository._pack_collection.text_index.combined_index)
+
def _add_text_to_weave(self, file_id, new_lines, parents, nostore_sha):
return self.repository._pack_collection._add_text_to_weave(file_id,
self._new_revision_id, new_lines, parents, nostore_sha,
self.random_revid)
+ def heads(self, file_id, revision_ids):
+ keys = [(file_id, revision_id) for revision_id in revision_ids]
+ return set([key[1] for key in self._file_graph.heads(keys)])
+
class Pack(object):
"""An in memory proxy for a pack and its indices.
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-11-12 21:03:01 +0000
+++ b/bzrlib/repository.py 2007-11-12 22:57:58 +0000
@@ -74,8 +74,8 @@
# the default CommitBuilder does not manage trees whose root is versioned.
_versioned_root = False
- def __init__(self, repository, parents, config, timestamp=None,
- timezone=None, committer=None, revprops=None,
+ def __init__(self, repository, parents, config, timestamp=None,
+ timezone=None, committer=None, revprops=None,
revision_id=None):
"""Initiate a CommitBuilder.
More information about the bazaar-commits
mailing list