Rev 4310: Change RemoteRepository.has_revision to use get_parent_map to leverage the caching. in http://people.ubuntu.com/~robertc/baz2.0/pending/push.roundtrips
Robert Collins
robertc at robertcollins.net
Tue Apr 28 06:29:07 BST 2009
At http://people.ubuntu.com/~robertc/baz2.0/pending/push.roundtrips
------------------------------------------------------------
revno: 4310
revision-id: robertc at robertcollins.net-20090428052904-sttkmasfldpxlq2m
parent: robertc at robertcollins.net-20090428035556-z6ucu9363itcb9qx
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.roundtrips
timestamp: Tue 2009-04-28 15:29:04 +1000
message:
Change RemoteRepository.has_revision to use get_parent_map to leverage the caching.
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2009-04-27 23:14:00 +0000
+++ b/bzrlib/remote.py 2009-04-28 05:29:04 +0000
@@ -30,6 +30,7 @@
pack,
repository,
revision,
+ revision as _mod_revision,
symbol_versioning,
urlutils,
)
@@ -750,30 +751,24 @@
"""Return a source for streaming from this repository."""
return RemoteStreamSource(self, to_format)
+ @needs_read_lock
def has_revision(self, revision_id):
- """See Repository.has_revision()."""
- if revision_id == NULL_REVISION:
- # The null revision is always present.
- return True
- path = self.bzrdir._path_for_remote_call(self._client)
- response = self._call('Repository.has_revision', path, revision_id)
- if response[0] not in ('yes', 'no'):
- raise errors.UnexpectedSmartServerResponse(response)
- if response[0] == 'yes':
- return True
- for fallback_repo in self._fallback_repositories:
- if fallback_repo.has_revision(revision_id):
- return True
- return False
+ """True if this repository has a copy of the revision."""
+ # Copy of bzrlib.repository.Repository.has_revision
+ return revision_id in self.has_revisions((revision_id,))
+ @needs_read_lock
def has_revisions(self, revision_ids):
- """See Repository.has_revisions()."""
- # FIXME: This does many roundtrips, particularly when there are
- # fallback repositories. -- mbp 20080905
- result = set()
- for revision_id in revision_ids:
- if self.has_revision(revision_id):
- result.add(revision_id)
+ """Probe to find out the presence of multiple revisions.
+
+ :param revision_ids: An iterable of revision_ids.
+ :return: A set of the revision_ids that were present.
+ """
+ # Copy of bzrlib.repository.Repository.has_revisions
+ parent_map = self.get_parent_map(revision_ids)
+ result = set(parent_map)
+ if _mod_revision.NULL_REVISION in revision_ids:
+ result.add(_mod_revision.NULL_REVISION)
return result
def has_same_location(self, other):
More information about the bazaar-commits
mailing list