15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
from bzrlib import branch, errors
18
from bzrlib import branch, errors, repository
19
19
from bzrlib.bzrdir import BzrDir, BzrDirFormat
20
from bzrlib.branch import Branch
20
from bzrlib.branch import Branch, BranchFormat
21
21
from bzrlib.trace import mutter
22
22
from bzrlib.transport.smart import SmartTransport
42
42
def __init__(self, transport):
43
43
BzrDir.__init__(self, transport, RemoteBzrDirFormat)
44
44
self.client = transport.get_smart_client()
45
# this object holds a delegated bzrdir that uses file-level operations
46
# to talk to the other side
47
self._real_bzrdir = BzrDirFormat.get_default_format().open(transport, _found=True)
48
self._repository = None
51
def open_repository(self):
52
# OK just very fake response for now
53
if not self._repository:
54
self._repository = self._real_bzrdir.open_repository()
55
return self._repository
46
57
def open_branch(self):
58
# Very fake - use file-level transport
47
59
return RemoteBranch(self, self.client)
50
class RemoteBranch(branch.BzrBranch5):
61
def get_branch_transport(self, branch_format):
62
return self._real_bzrdir.get_branch_transport(branch_format)
65
class RemoteRepositoryFormat(repository.RepositoryFormatKnit1):
66
"""Format for repositories accessed over rpc.
68
Instances of this repository are represented by RemoteRepository
72
_matchingbzrdir = RemoteBzrDirFormat
75
class RemoteRepository(repository.Repository):
76
"""Repository accessed over rpc.
78
For the moment everything is delegated to IO-like operations over
84
class RemoteBranchFormat(branch.BranchFormat):
86
def open(self, a_bzrdir):
87
return RemoteBranch(a_bzrdir, a_bzrdir.client)
90
class RemoteBranch(branch.Branch):
91
"""Branch stored on a server accessed by HPSS RPC.
93
At the moment most operations are mapped down to simple file operations.
52
96
def __init__(self, my_bzrdir, smart_client):
53
97
self.bzrdir = my_bzrdir
54
98
self.client = smart_client
99
self.transport = my_bzrdir.transport
100
self.repository = self.bzrdir.open_repository()
101
real_format = BranchFormat.get_default_format()
102
self._real_branch = real_format.open(my_bzrdir, _found=True)
108
# TODO: implement write locking, passed through to the other end? Or
109
# perhaps we should not lock but rather do higher-level operations?
112
def revision_history(self):
113
return self._real_branch.revision_history()
57
116
# when first loaded, register this format.