/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

Start adding a RemoteBzrDir, etc

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 Canonical Ltd
 
2
#
 
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.
 
7
#
 
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.
 
12
#
 
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
 
16
 
 
17
 
 
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
 
23
 
 
24
 
 
25
class RemoteBzrDirFormat(BzrDirFormat):
 
26
    """Format representing bzrdirs accessed via a smart server"""
 
27
    
 
28
    def probe_transport(self, transport):
 
29
        mutter("%r probe for bzrdir in %r" % (self, transport))
 
30
        if isinstance(transport, SmartTransport):
 
31
            return self
 
32
        else:
 
33
            raise errors.NoSmartServer(transport.base)
 
34
 
 
35
    def _open(self, transport):
 
36
        return RemoteBzrDir(transport)
 
37
 
 
38
 
 
39
class RemoteBzrDir(BzrDir):
 
40
    """Control directory on a remote server, accessed by HPSS."""
 
41
 
 
42
    def __init__(self, transport):
 
43
        BzrDir.__init__(self, transport, RemoteBzrDirFormat)
 
44
        self.client = transport.get_smart_client()
 
45
 
 
46
    def open_branch(self):
 
47
        return RemoteBranch(self, self.client)
 
48
 
 
49
 
 
50
class RemoteBranch(branch.BzrBranch5):
 
51
 
 
52
    def __init__(self, my_bzrdir, smart_client):
 
53
        self.bzrdir = my_bzrdir
 
54
        self.client = smart_client
 
55
 
 
56
 
 
57
# when first loaded, register this format.
 
58
#
 
59
# TODO: Actually this needs to be done earlier; we can hold off on loading
 
60
# this code until it's needed though.
 
61
 
 
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())