/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Robert Collins
  • Date: 2009-02-24 08:09:17 UTC
  • mfrom: (4037 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4038.
  • Revision ID: robertc@robertcollins.net-20090224080917-9k7ib4oj1godlp3k
Merge bzr (resolve conflicts).

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
            return self._client.call(method, *args)
56
56
        except errors.ErrorFromSmartServer, err:
57
57
            self._translate_error(err, **err_context)
58
 
        
 
58
 
59
59
    def _call_expecting_body(self, method, *args, **err_context):
60
60
        try:
61
61
            return self._client.call_expecting_body(method, *args)
62
62
        except errors.ErrorFromSmartServer, err:
63
63
            self._translate_error(err, **err_context)
64
 
        
 
64
 
65
65
    def _call_with_body_bytes_expecting_body(self, method, args, body_bytes,
66
66
                                             **err_context):
67
67
        try:
195
195
            # a branch reference, use the existing BranchReference logic.
196
196
            format = BranchReferenceFormat()
197
197
            return format.open(self, _found=True, location=reference_url)
198
 
                
 
198
 
199
199
    def open_repository(self):
200
200
        path = self._path_for_remote_call(self._client)
201
201
        verb = 'BzrDir.find_repositoryV2'
283
283
    on a per instance basis, and are not set (and should not be) at
284
284
    the class level.
285
285
 
286
 
    :ivar _custom_format: If set, a specific concrete repository format that 
 
286
    :ivar _custom_format: If set, a specific concrete repository format that
287
287
        will be used when initializing a repository with this
288
288
        RemoteRepositoryFormat.
289
289
    :ivar _creating_repo: If set, the repository object that this
360
360
            remote_repo = RemoteRepository(a_bzrdir, format)
361
361
            format._creating_repo = remote_repo
362
362
            return remote_repo
363
 
    
 
363
 
364
364
    def open(self, a_bzrdir):
365
365
        if not isinstance(a_bzrdir, RemoteBzrDir):
366
366
            raise AssertionError('%r is not a RemoteBzrDir' % (a_bzrdir,))
413
413
 
414
414
    def __init__(self, remote_bzrdir, format, real_repository=None, _client=None):
415
415
        """Create a RemoteRepository instance.
416
 
        
 
416
 
417
417
        :param remote_bzrdir: The bzrdir hosting this repository.
418
418
        :param format: The RemoteFormat object to use.
419
419
        :param real_repository: If not None, a local implementation of the
458
458
 
459
459
    def abort_write_group(self, suppress_errors=False):
460
460
        """Complete a write group on the decorated repository.
461
 
        
 
461
 
462
462
        Smart methods peform operations in a single step so this api
463
463
        is not really applicable except as a compatibility thunk
464
464
        for older plugins that don't use e.g. the CommitBuilder
472
472
 
473
473
    def commit_write_group(self):
474
474
        """Complete a write group on the decorated repository.
475
 
        
 
475
 
476
476
        Smart methods peform operations in a single step so this api
477
477
        is not really applicable except as a compatibility thunk
478
478
        for older plugins that don't use e.g. the CommitBuilder
554
554
        for line in lines:
555
555
            d = tuple(line.split())
556
556
            revision_graph[d[0]] = d[1:]
557
 
            
 
557
 
558
558
        return revision_graph
559
559
 
560
560
    def _get_sink(self):
745
745
 
746
746
    def start_write_group(self):
747
747
        """Start a write group on the decorated repository.
748
 
        
 
748
 
749
749
        Smart methods peform operations in a single step so this api
750
750
        is not really applicable except as a compatibility thunk
751
751
        for older plugins that don't use e.g. the CommitBuilder
802
802
 
803
803
    def _get_tarball(self, compression):
804
804
        """Return a TemporaryFile containing a repository tarball.
805
 
        
 
805
 
806
806
        Returns None if the server does not support sending tarballs.
807
807
        """
808
808
        import tempfile
854
854
 
855
855
    def add_fallback_repository(self, repository):
856
856
        """Add a repository to use for looking up data not held locally.
857
 
        
 
857
 
858
858
        :param repository: A repository.
859
859
        """
860
860
        # XXX: At the moment the RemoteRepository will allow fallbacks
929
929
    @needs_read_lock
930
930
    def search_missing_revision_ids(self, other, revision_id=None, find_ghosts=True):
931
931
        """Return the revision ids that other has that this does not.
932
 
        
 
932
 
933
933
        These are returned in topological order.
934
934
 
935
935
        revision_id: only return revision ids included by revision_id.
970
970
        self._ensure_real()
971
971
        return self._real_repository._get_versioned_file_checker(
972
972
            revisions, revision_versions_cache)
973
 
        
 
973
 
974
974
    def iter_files_bytes(self, desired_files):
975
975
        """See Repository.iter_file_bytes.
976
976
        """
1139
1139
    def reconcile(self, other=None, thorough=False):
1140
1140
        self._ensure_real()
1141
1141
        return self._real_repository.reconcile(other=other, thorough=thorough)
1142
 
        
 
1142
 
1143
1143
    def all_revision_ids(self):
1144
1144
        self._ensure_real()
1145
1145
        return self._real_repository.all_revision_ids()
1146
 
    
 
1146
 
1147
1147
    @needs_read_lock
1148
1148
    def get_deltas_for_revisions(self, revisions):
1149
1149
        self._ensure_real()
1416
1416
                if collection is not None:
1417
1417
                    collection.reload_pack_names()
1418
1418
            return []
1419
 
            
 
1419
 
1420
1420
    def _stream_to_byte_stream(self, stream, src_format):
1421
1421
        bytes = []
1422
1422
        pack_writer = pack.ContainerWriter(bytes.append)
1448
1448
 
1449
1449
class RemoteBranchLockableFiles(LockableFiles):
1450
1450
    """A 'LockableFiles' implementation that talks to a smart server.
1451
 
    
 
1451
 
1452
1452
    This is not a public interface class.
1453
1453
    """
1454
1454
 
1475
1475
        self._custom_format = None
1476
1476
 
1477
1477
    def __eq__(self, other):
1478
 
        return (isinstance(other, RemoteBranchFormat) and 
 
1478
        return (isinstance(other, RemoteBranchFormat) and
1479
1479
            self.__dict__ == other.__dict__)
1480
1480
 
1481
1481
    def get_format_description(self):
1701
1701
        too, in fact doing so might harm performance.
1702
1702
        """
1703
1703
        super(RemoteBranch, self)._clear_cached_state()
1704
 
        
 
1704
 
1705
1705
    @property
1706
1706
    def control_files(self):
1707
1707
        # Defer actually creating RemoteBranchLockableFiles until its needed,
1771
1771
            raise errors.UnexpectedSmartServerResponse(response)
1772
1772
        ok, branch_token, repo_token = response
1773
1773
        return branch_token, repo_token
1774
 
            
 
1774
 
1775
1775
    def lock_write(self, token=None):
1776
1776
        if not self._lock_mode:
1777
1777
            # Lock the branch and repo in one remote call.
1947
1947
        # Used by tests, when checking normalisation of given vs stored paths.
1948
1948
        self._ensure_real()
1949
1949
        return self._real_branch._get_parent_location()
1950
 
        
 
1950
 
1951
1951
    def set_parent(self, url):
1952
1952
        self._ensure_real()
1953
1953
        return self._real_branch.set_parent(url)
1959
1959
        else:
1960
1960
            self._ensure_real()
1961
1961
            return self._real_branch._set_parent_location(url)
1962
 
        
 
1962
 
1963
1963
    def set_stacked_on_url(self, stacked_location):
1964
1964
        """Set the URL this branch is stacked against.
1965
1965