~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Robert Collins
  • Date: 2008-01-11 03:54:51 UTC
  • mto: (3172.5.3 remote.graph)
  • mto: This revision was merged to the branch mainline in revision 3176.
  • Revision ID: robertc@robertcollins.net-20080111035451-52at4031ohbmtoh2
Repository has a new method ``has_revisions`` which signals the presence
of many revisions by returning a set of the revisions listed which are
present. This can be done by index queries without reading data for parent
revision names etc. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    deprecated_method,
39
39
    zero_ninetyone,
40
40
    )
 
41
from bzrlib.revision import NULL_REVISION
41
42
from bzrlib.trace import note
42
43
 
43
44
# Note: RemoteBzrDirFormat is in bzrdir.py
367
368
 
368
369
    def has_revision(self, revision_id):
369
370
        """See Repository.has_revision()."""
370
 
        if revision_id is None:
 
371
        if revision_id == NULL_REVISION:
371
372
            # The null revision is always present.
372
373
            return True
373
374
        path = self.bzrdir._path_for_remote_call(self._client)
375
376
        assert response[0] in ('yes', 'no'), 'unexpected response code %s' % (response,)
376
377
        return response[0] == 'yes'
377
378
 
 
379
    def has_revisions(self, revision_ids):
 
380
        """See Repository.has_revisions()."""
 
381
        result = set()
 
382
        for revision_id in revision_ids:
 
383
            if self.has_revision(revision_id):
 
384
                result.add(revision_id)
 
385
        return result
 
386
 
378
387
    def has_same_location(self, other):
379
388
        return (self.__class__ == other.__class__ and
380
389
                self.bzrdir.transport.base == other.bzrdir.transport.base)