84
88
def open_branch(self, _unsupported=False):
85
89
assert _unsupported == False, 'unsupported flag support not implemented yet.'
86
smartclient = client.SmartClient(self.client)
87
path = self._path_for_remote_call(smartclient)
88
response = smartclient.call('BzrDir.open_branch', path)
89
assert response[0] == 'ok', 'unexpected response code %s' % (response,)
90
if response[0] != 'ok':
91
# this should probably be a regular translate no ?
90
path = self._path_for_remote_call(self._client)
91
response = self._client.call('BzrDir.open_branch', path)
92
if response[0] == 'ok':
94
# branch at this location.
95
return RemoteBranch(self, self.find_repository())
97
# a branch reference, use the existing BranchReference logic.
98
format = BranchReferenceFormat()
99
return format.open(self, _found=True, location=response[1])
100
elif response == ('nobranch',):
92
101
raise errors.NotBranchError(path=self.root_transport.base)
94
# branch at this location.
95
return RemoteBranch(self, self.find_repository())
97
# a branch reference, use the existing BranchReference logic.
98
format = BranchReferenceFormat()
99
return format.open(self, _found=True, location=response[1])
103
assert False, 'unexpected response code %r' % (response,)
101
105
def open_repository(self):
102
smartclient = client.SmartClient(self.client)
103
path = self._path_for_remote_call(smartclient)
104
response = smartclient.call('BzrDir.find_repository', path)
106
path = self._path_for_remote_call(self._client)
107
response = self._client.call('BzrDir.find_repository', path)
105
108
assert response[0] in ('ok', 'norepository'), \
106
109
'unexpected response code %s' % (response,)
107
110
if response[0] == 'norepository':
225
229
return revision_graph
227
assert response[1] != ''
231
response_body = response[1].read_body_bytes()
232
assert response_body == ''
228
233
raise NoSuchRevision(self, revision_id)
230
235
def has_revision(self, revision_id):
231
236
"""See Repository.has_revision()."""
237
if revision_id is None:
238
# The null revision is always present.
232
240
path = self.bzrdir._path_for_remote_call(self._client)
233
241
response = self._client.call('Repository.has_revision', path, revision_id.encode('utf8'))
234
242
assert response[0] in ('ok', 'no'), 'unexpected response code %s' % (response,)
235
243
return response[0] == 'ok'
237
def gather_stats(self, revid, committers=None):
245
def gather_stats(self, revid=None, committers=None):
238
246
"""See Repository.gather_stats()."""
239
247
path = self.bzrdir._path_for_remote_call(self._client)
240
248
if revid in (None, NULL_REVISION):
243
251
fmt_revid = revid.encode('utf8')
244
if committers is None:
252
if committers is None or not committers:
245
253
fmt_committers = 'no'
247
255
fmt_committers = 'yes'
364
374
self._ensure_real()
365
375
return self._real_repository.break_lock()
377
### These methods are just thin shims to the VFS object for now.
379
def revision_tree(self, revision_id):
381
return self._real_repository.revision_tree(revision_id)
383
def get_commit_builder(self, branch, parents, config, timestamp=None,
384
timezone=None, committer=None, revprops=None,
386
# FIXME: It ought to be possible to call this without immediately
387
# triggering _ensure_real. For now it's the easiest thing to do.
389
builder = self._real_repository.get_commit_builder(branch, parents,
390
config, timestamp=timestamp, timezone=timezone,
391
committer=committer, revprops=revprops, revision_id=revision_id)
392
# Make the builder use this RemoteRepository rather than the real one.
393
builder.repository = self
397
def add_inventory(self, revid, inv, parents):
399
return self._real_repository.add_inventory(revid, inv, parents)
402
def add_revision(self, rev_id, rev, inv=None, config=None):
404
return self._real_repository.add_revision(
405
rev_id, rev, inv=inv, config=config)
408
def get_inventory(self, revision_id):
410
return self._real_repository.get_inventory(revision_id)
413
def get_revision(self, revision_id):
415
return self._real_repository.get_revision(revision_id)
418
def weave_store(self):
420
return self._real_repository.weave_store
422
def get_transaction(self):
424
return self._real_repository.get_transaction()
427
def clone(self, a_bzrdir, revision_id=None, basis=None):
429
return self._real_repository.clone(
430
a_bzrdir, revision_id=revision_id, basis=basis)
432
def make_working_trees(self):
435
def fetch(self, source, revision_id=None, pb=None):
437
return self._real_repository.fetch(
438
source, revision_id=revision_id, pb=pb)
441
def control_weaves(self):
443
return self._real_repository.control_weaves
446
def get_ancestry(self, revision_id):
448
return self._real_repository.get_ancestry(revision_id)
451
def get_inventory_weave(self):
453
return self._real_repository.get_inventory_weave()
455
def fileids_altered_by_revision_ids(self, revision_ids):
457
return self._real_repository.fileids_altered_by_revision_ids(revision_ids)
460
def get_signature_text(self, revision_id):
462
return self._real_repository.get_signature_text(revision_id)
465
def get_revision_graph_with_ghosts(self, revision_ids=None):
467
return self._real_repository.get_revision_graph_with_ghosts(
468
revision_ids=revision_ids)
471
def get_inventory_xml(self, revision_id):
473
return self._real_repository.get_inventory_xml(revision_id)
475
def deserialise_inventory(self, revision_id, xml):
477
return self._real_repository.deserialise_inventory(revision_id, xml)
479
def reconcile(self, other=None, thorough=False):
481
return self._real_repository.reconcile(other=other, thorough=thorough)
483
def all_revision_ids(self):
485
return self._real_repository.all_revision_ids()
488
def get_deltas_for_revisions(self, revisions):
490
return self._real_repository.get_deltas_for_revisions(revisions)
493
def get_revision_delta(self, revision_id):
495
return self._real_repository.get_revision_delta(revision_id)
498
def revision_trees(self, revision_ids):
500
return self._real_repository.revision_trees(revision_ids)
503
def get_revision_reconcile(self, revision_id):
505
return self._real_repository.get_revision_reconcile(revision_id)
508
def check(self, revision_ids):
510
return self._real_repository.check(revision_ids)
512
def copy_content_into(self, destination, revision_id=None, basis=None):
514
return self._real_repository.copy_content_into(
515
destination, revision_id=revision_id, basis=basis)
517
def set_make_working_trees(self, new_value):
518
raise NotImplementedError(self.set_make_working_trees)
521
def sign_revision(self, revision_id, gpg_strategy):
523
return self._real_repository.sign_revision(revision_id, gpg_strategy)
526
def get_revisions(self, revision_ids):
528
return self._real_repository.get_revisions(revision_ids)
530
def supports_rich_root(self):
531
# Perhaps this should return True depending on the real repository, but
532
# for now we just take the easy option and assume we can't handle rich
368
537
class RemoteBranchLockableFiles(object):
369
538
"""A 'LockableFiles' implementation that talks to a smart server.
481
661
elif response[0] == 'TokenMismatch':
482
662
raise errors.TokenMismatch(tokens, '(remote tokens)')
484
assert False, 'unexpected response code %s' % (response,)
664
assert False, 'unexpected response code %r' % (response,)
486
666
def lock_write(self, tokens=None):
487
667
if not self._lock_mode:
488
remote_tokens = self._lock_write(tokens)
668
remote_tokens = self._remote_lock_write(tokens)
489
669
self._lock_token, self._repo_lock_token = remote_tokens
490
670
assert self._lock_token, 'Remote server did not return a token!'
671
# TODO: We really, really, really don't want to call _ensure_real
672
# here, but it's the easiest way to ensure coherency between the
673
# state of the RemoteBranch and RemoteRepository objects and the
674
# physical locks. If we don't materialise the real objects here,
675
# then getting everything in the right state later is complex, so
676
# for now we just do it the lazy way.
677
# -- Andrew Bennetts, 2007-02-22.
491
679
if self._real_branch is not None:
492
680
self._real_branch.lock_write(tokens=remote_tokens)
493
681
if tokens is not None: