1
# Copyright (C) 2006 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
from bzrlib import branch, errors
19
from bzrlib.bzrdir import BzrDir, BzrDirFormat
20
from bzrlib.branch import Branch
21
from bzrlib.trace import mutter
22
from bzrlib.transport.smart import SmartTransport
25
class RemoteBzrDirFormat(BzrDirFormat):
26
"""Format representing bzrdirs accessed via a smart server"""
28
def probe_transport(self, transport):
29
mutter("%r probe for bzrdir in %r" % (self, transport))
30
if isinstance(transport, SmartTransport):
33
raise errors.NoSmartServer(transport.base)
35
def _open(self, transport):
36
return RemoteBzrDir(transport)
39
class RemoteBzrDir(BzrDir):
40
"""Control directory on a remote server, accessed by HPSS."""
42
def __init__(self, transport):
43
BzrDir.__init__(self, transport, RemoteBzrDirFormat)
44
self.client = transport.get_smart_client()
46
def open_branch(self):
47
return RemoteBranch(self, self.client)
50
class RemoteBranch(branch.BzrBranch5):
52
def __init__(self, my_bzrdir, smart_client):
53
self.bzrdir = my_bzrdir
54
self.client = smart_client
57
# when first loaded, register this format.
59
# TODO: Actually this needs to be done earlier; we can hold off on loading
60
# this code until it's needed though.
62
# We can't use register_control_format because it adds it at a lower priority
63
# than the existing branches, whereas this should take priority.
64
BzrDirFormat._control_formats.insert(0, RemoteBzrDirFormat())