/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

[broken] some support for write operations over hpss

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
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
23
23
 
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
 
49
        self._branch = None
 
50
 
 
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
45
56
 
46
57
    def open_branch(self):
 
58
        # Very fake - use file-level transport
47
59
        return RemoteBranch(self, self.client)
48
60
 
49
 
 
50
 
class RemoteBranch(branch.BzrBranch5):
 
61
    def get_branch_transport(self, branch_format):
 
62
        return self._real_bzrdir.get_branch_transport(branch_format)
 
63
 
 
64
 
 
65
class RemoteRepositoryFormat(repository.RepositoryFormatKnit1):
 
66
    """Format for repositories accessed over rpc.
 
67
 
 
68
    Instances of this repository are represented by RemoteRepository 
 
69
    instances.
 
70
    """
 
71
 
 
72
    _matchingbzrdir = RemoteBzrDirFormat
 
73
 
 
74
 
 
75
class RemoteRepository(repository.Repository):
 
76
    """Repository accessed over rpc.
 
77
 
 
78
    For the moment everything is delegated to IO-like operations over 
 
79
    the transport.
 
80
    """
 
81
 
 
82
 
 
83
 
 
84
class RemoteBranchFormat(branch.BranchFormat):
 
85
 
 
86
    def open(self, a_bzrdir):
 
87
        return RemoteBranch(a_bzrdir, a_bzrdir.client)
 
88
 
 
89
 
 
90
class RemoteBranch(branch.Branch):
 
91
    """Branch stored on a server accessed by HPSS RPC.
 
92
 
 
93
    At the moment most operations are mapped down to simple file operations.
 
94
    """
51
95
 
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)
 
103
 
 
104
    def lock_read(self):
 
105
        pass
 
106
 
 
107
    def unlock(self):
 
108
        # TODO: implement write locking, passed through to the other end?  Or
 
109
        # perhaps we should not lock but rather do higher-level operations?
 
110
        pass
 
111
 
 
112
    def revision_history(self):
 
113
        return self._real_branch.revision_history()
55
114
 
56
115
 
57
116
# when first loaded, register this format.