/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: Martin Pool
  • Date: 2007-09-14 06:31:28 UTC
  • mfrom: (2822 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2823.
  • Revision ID: mbp@sourcefrog.net-20070914063128-0p7mh6zfb4pzdg9p
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
from bzrlib.lockable_files import LockableFiles
34
34
from bzrlib.revision import NULL_REVISION
35
35
from bzrlib.smart import client, vfs
 
36
from bzrlib.symbol_versioning import (
 
37
    deprecated_method,
 
38
    zero_ninetyone,
 
39
    )
36
40
from bzrlib.trace import note
37
41
 
38
42
# Note: RemoteBzrDirFormat is in bzrdir.py
52
56
        self._real_bzrdir = None
53
57
 
54
58
        if _client is None:
55
 
            self._medium = transport.get_smart_client()
56
 
            self._client = client._SmartClient(self._medium)
 
59
            self._shared_medium = transport.get_shared_medium()
 
60
            self._client = client._SmartClient(self._shared_medium)
57
61
        else:
58
62
            self._client = _client
59
 
            self._medium = None
 
63
            self._shared_medium = None
60
64
            return
61
65
 
62
66
        path = self._path_for_remote_call(self._client)
240
244
            self._real_repository = None
241
245
        self.bzrdir = remote_bzrdir
242
246
        if _client is None:
243
 
            self._client = client._SmartClient(self.bzrdir._medium)
 
247
            self._client = client._SmartClient(self.bzrdir._shared_medium)
244
248
        else:
245
249
            self._client = _client
246
250
        self._format = format
248
252
        self._lock_token = None
249
253
        self._lock_count = 0
250
254
        self._leave_lock = False
 
255
        # for tests
 
256
        self._reconcile_does_inventory_gc = True
 
257
 
 
258
    def abort_write_group(self):
 
259
        """Complete a write group on the decorated repository.
 
260
        
 
261
        Smart methods peform operations in a single step so this api
 
262
        is not really applicable except as a compatibility thunk
 
263
        for older plugins that don't use e.g. the CommitBuilder
 
264
        facility.
 
265
        """
 
266
        self._ensure_real()
 
267
        return self._real_repository.abort_write_group()
 
268
 
 
269
    def commit_write_group(self):
 
270
        """Complete a write group on the decorated repository.
 
271
        
 
272
        Smart methods peform operations in a single step so this api
 
273
        is not really applicable except as a compatibility thunk
 
274
        for older plugins that don't use e.g. the CommitBuilder
 
275
        facility.
 
276
        """
 
277
        self._ensure_real()
 
278
        return self._real_repository.commit_write_group()
251
279
 
252
280
    def _ensure_real(self):
253
281
        """Ensure that there is a _real_repository set.
280
308
            lines = coded.split('\n')
281
309
            revision_graph = {}
282
310
            for line in lines:
283
 
                d = list(line.split())
 
311
                d = tuple(line.split())
284
312
                revision_graph[d[0]] = d[1:]
285
313
                
286
314
            return revision_graph
299
327
        assert response[0] in ('yes', 'no'), 'unexpected response code %s' % (response,)
300
328
        return response[0] == 'yes'
301
329
 
 
330
    def has_same_location(self, other):
 
331
        return (self.__class__ == other.__class__ and
 
332
                self.bzrdir.transport.base == other.bzrdir.transport.base)
 
333
        
302
334
    def get_graph(self, other_repository=None):
303
335
        """Return the graph for this repository format"""
304
336
        return self._real_repository.get_graph(other_repository)
337
369
        """See Repository.get_physical_lock_status()."""
338
370
        return False
339
371
 
 
372
    def is_in_write_group(self):
 
373
        """Return True if there is an open write group.
 
374
 
 
375
        write groups are only applicable locally for the smart server..
 
376
        """
 
377
        if self._real_repository:
 
378
            return self._real_repository.is_in_write_group()
 
379
 
 
380
    def is_locked(self):
 
381
        return self._lock_count >= 1
 
382
 
340
383
    def is_shared(self):
341
384
        """See Repository.is_shared()."""
342
385
        path = self.bzrdir._path_for_remote_call(self._client)
408
451
        elif self._lock_mode == 'r':
409
452
            self._real_repository.lock_read()
410
453
 
 
454
    def start_write_group(self):
 
455
        """Start a write group on the decorated repository.
 
456
        
 
457
        Smart methods peform operations in a single step so this api
 
458
        is not really applicable except as a compatibility thunk
 
459
        for older plugins that don't use e.g. the CommitBuilder
 
460
        facility.
 
461
        """
 
462
        self._ensure_real()
 
463
        return self._real_repository.start_write_group()
 
464
 
411
465
    def _unlock(self, token):
412
466
        path = self.bzrdir._path_for_remote_call(self._client)
413
467
        response = self._client.call('Repository.unlock', path, token)
419
473
            raise errors.UnexpectedSmartServerResponse(response)
420
474
 
421
475
    def unlock(self):
 
476
        if self._lock_count == 1 and self._lock_mode == 'w':
 
477
            # don't unlock if inside a write group.
 
478
            if self.is_in_write_group():
 
479
                raise errors.BzrError(
 
480
                    'Must end write groups before releasing write locks.')
422
481
        self._lock_count -= 1
423
482
        if not self._lock_count:
424
483
            mode = self._lock_mode
470
529
        self._ensure_real()
471
530
        return self._real_repository.revision_tree(revision_id)
472
531
 
 
532
    def get_serializer_format(self):
 
533
        self._ensure_real()
 
534
        return self._real_repository.get_serializer_format()
 
535
 
473
536
    def get_commit_builder(self, branch, parents, config, timestamp=None,
474
537
                           timezone=None, committer=None, revprops=None,
475
538
                           revision_id=None):
527
590
        return self._real_repository.fetch(
528
591
            source, revision_id=revision_id, pb=pb)
529
592
 
 
593
    def create_bundle(self, target, base, fileobj, format=None):
 
594
        self._ensure_real()
 
595
        self._real_repository.create_bundle(target, base, fileobj, format)
 
596
 
530
597
    @property
531
598
    def control_weaves(self):
532
599
        self._ensure_real()
546
613
        self._ensure_real()
547
614
        return self._real_repository.fileids_altered_by_revision_ids(revision_ids)
548
615
 
 
616
    def iter_files_bytes(self, desired_files):
 
617
        """See Repository.iter_file_bytes.
 
618
        """
 
619
        self._ensure_real()
 
620
        return self._real_repository.iter_files_bytes(desired_files)
 
621
 
549
622
    @needs_read_lock
550
623
    def get_signature_text(self, revision_id):
551
624
        self._ensure_real()
736
809
        assert isinstance(a_bzrdir, RemoteBzrDir)
737
810
        return a_bzrdir.create_branch()
738
811
 
 
812
    def supports_tags(self):
 
813
        # Remote branches might support tags, but we won't know until we
 
814
        # access the real remote branch.
 
815
        return True
 
816
 
739
817
 
740
818
class RemoteBranch(branch.Branch):
741
819
    """Branch stored on a server accessed by HPSS RPC.
759
837
        if _client is not None:
760
838
            self._client = _client
761
839
        else:
762
 
            self._client = client._SmartClient(self.bzrdir._medium)
 
840
            self._client = client._SmartClient(self.bzrdir._shared_medium)
763
841
        self.repository = remote_repository
764
842
        if real_branch is not None:
765
843
            self._real_branch = real_branch
1009
1087
        return result
1010
1088
 
1011
1089
    @needs_write_lock
1012
 
    def append_revision(self, *revision_ids):
1013
 
        self._ensure_real()
1014
 
        return self._real_branch.append_revision(*revision_ids)
1015
 
 
1016
 
    @needs_write_lock
1017
1090
    def pull(self, source, overwrite=False, stop_revision=None,
1018
1091
             **kwargs):
1019
1092
        # FIXME: This asks the real branch to run the hooks, which means