333
333
_mod_bzrdir.BzrDirMetaFormat1._set_repository_format) #.im_func)
336
class RemoteControlStore(config.IniFileStore):
337
"""Control store which attempts to use HPSS calls to retrieve control store.
339
Note that this is specific to bzr-based formats.
342
def __init__(self, bzrdir):
343
super(RemoteControlStore, self).__init__()
345
self._real_store = None
347
def lock_write(self, token=None):
349
return self._real_store.lock_write(token)
353
return self._real_store.unlock()
357
# We need to be able to override the undecorated implementation
358
self.save_without_locking()
360
def save_without_locking(self):
361
super(RemoteControlStore, self).save()
363
def _ensure_real(self):
364
self.bzrdir._ensure_real()
365
if self._real_store is None:
366
self._real_store = config.ControlStore(self.bzrdir)
368
def external_url(self):
369
return self.bzrdir.user_url
371
def _load_content(self):
372
medium = self.bzrdir._client._medium
373
path = self.bzrdir._path_for_remote_call(self.bzrdir._client)
375
response, handler = self.bzrdir._call_expecting_body(
376
'BzrDir.get_config_file', path)
377
except errors.UnknownSmartMethod:
379
return self._real_store._load_content()
380
if len(response) and response[0] != 'ok':
381
raise errors.UnexpectedSmartServerResponse(response)
382
return handler.read_body_bytes()
384
def _save_content(self, content):
385
# FIXME JRV 2011-11-22: Ideally this should use a
386
# HPSS call too, but at the moment it is not possible
387
# to write lock control directories.
389
return self._real_store._save_content(content)
336
392
class RemoteBzrDir(_mod_bzrdir.BzrDir, _RpcHelper):
337
393
"""Control directory on a remote server, accessed via bzr:// or similar."""
718
774
def _get_config(self):
719
775
return RemoteBzrDirConfig(self)
777
def _get_config_store(self):
778
return RemoteControlStore(self)
722
781
class RemoteRepositoryFormat(vf_repository.VersionedFileRepositoryFormat):
723
782
"""Format for repositories accessed over a _SmartClient.
2601
class RemoteBranchStore(config.IniFileStore):
2602
"""Branch store which attempts to use HPSS calls to retrieve branch store.
2604
Note that this is specific to bzr-based formats.
2607
def __init__(self, branch):
2608
super(RemoteBranchStore, self).__init__()
2609
self.branch = branch
2611
self._real_store = None
2613
def lock_write(self, token=None):
2614
return self.branch.lock_write(token)
2617
return self.branch.unlock()
2621
# We need to be able to override the undecorated implementation
2622
self.save_without_locking()
2624
def save_without_locking(self):
2625
super(RemoteBranchStore, self).save()
2627
def external_url(self):
2628
return self.branch.user_url
2630
def _load_content(self):
2631
path = self.branch._remote_path()
2633
response, handler = self.branch._call_expecting_body(
2634
'Branch.get_config_file', path)
2635
except errors.UnknownSmartMethod:
2637
return self._real_store._load_content()
2638
if len(response) and response[0] != 'ok':
2639
raise errors.UnexpectedSmartServerResponse(response)
2640
return handler.read_body_bytes()
2642
def _save_content(self, content):
2643
path = self.branch._remote_path()
2645
response, handler = self.branch._call_with_body_bytes_expecting_body(
2646
'Branch.put_config_file', (path,
2647
self.branch._lock_token, self.branch._repo_lock_token),
2649
except errors.UnknownSmartMethod:
2651
return self._real_store._save_content(content)
2652
handler.cancel_read_body()
2653
if response != ('ok', ):
2654
raise errors.UnexpectedSmartServerResponse(response)
2656
def _ensure_real(self):
2657
self.branch._ensure_real()
2658
if self._real_store is None:
2659
self._real_store = config.BranchStore(self.branch)
2541
2662
class RemoteBranch(branch.Branch, _RpcHelper, lock._RelockDebugMixin):
2542
2663
"""Branch stored on a server accessed by HPSS RPC.
2632
2753
def _get_config(self):
2633
2754
return RemoteBranchConfig(self)
2756
def _get_config_store(self):
2757
return RemoteBranchStore(self)
2635
2759
def _get_real_transport(self):
2636
2760
# if we try vfs access, return the real branch's vfs transport
2637
2761
self._ensure_real()