~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-03-03 06:02:49 UTC
  • mfrom: (5672.1.7 branch-revs-to-fetch)
  • Revision ID: pqm@pqm.ubuntu.com-20110303060249-l2zou9i59742nrqf
(spiv) Add Branch.heads_to_fetch API and HPSS request. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2194
2194
        self._ensure_real()
2195
2195
        return self._custom_format.supports_set_append_revisions_only()
2196
2196
 
 
2197
    def _use_default_local_heads_to_fetch(self):
 
2198
        # If the branch format is a metadir format *and* its heads_to_fetch
 
2199
        # implementation is not overridden vs the base class, we can use the
 
2200
        # base class logic rather than use the heads_to_fetch RPC.  This is
 
2201
        # usually cheaper in terms of net round trips, as the last-revision and
 
2202
        # tags info fetched is cached and would be fetched anyway.
 
2203
        self._ensure_real()
 
2204
        if isinstance(self._custom_format, branch.BranchFormatMetadir):
 
2205
            branch_class = self._custom_format._branch_class()
 
2206
            heads_to_fetch_impl = branch_class.heads_to_fetch.im_func
 
2207
            if heads_to_fetch_impl is branch.Branch.heads_to_fetch.im_func:
 
2208
                return True
 
2209
        return False
2197
2210
 
2198
2211
class RemoteBranch(branch.Branch, _RpcHelper, lock._RelockDebugMixin):
2199
2212
    """Branch stored on a server accessed by HPSS RPC.
2781
2794
        self._ensure_real()
2782
2795
        return self._real_branch.set_push_location(location)
2783
2796
 
 
2797
    def heads_to_fetch(self):
 
2798
        if self._format._use_default_local_heads_to_fetch():
 
2799
            # We recognise this format, and its heads-to-fetch implementation
 
2800
            # is the default one (tip + tags).  In this case it's cheaper to
 
2801
            # just use the default implementation rather than a special RPC as
 
2802
            # the tip and tags data is cached.
 
2803
            return branch.Branch.heads_to_fetch(self)
 
2804
        medium = self._client._medium
 
2805
        if medium._is_remote_before((2, 4)):
 
2806
            return self._vfs_heads_to_fetch()
 
2807
        try:
 
2808
            return self._rpc_heads_to_fetch()
 
2809
        except errors.UnknownSmartMethod:
 
2810
            medium._remember_remote_is_before((2, 4))
 
2811
            return self._vfs_heads_to_fetch()
 
2812
 
 
2813
    def _rpc_heads_to_fetch(self):
 
2814
        response = self._call('Branch.heads_to_fetch', self._remote_path())
 
2815
        if len(response) != 2:
 
2816
            raise errors.UnexpectedSmartServerResponse(response)
 
2817
        must_fetch, if_present_fetch = response
 
2818
        return set(must_fetch), set(if_present_fetch)
 
2819
 
 
2820
    def _vfs_heads_to_fetch(self):
 
2821
        self._ensure_real()
 
2822
        return self._real_branch.heads_to_fetch()
 
2823
 
2784
2824
 
2785
2825
class RemoteConfig(object):
2786
2826
    """A Config that reads and writes from smart verbs.