~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/bzrdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-03 08:54:13 UTC
  • mfrom: (4070.2.8 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090303085413-35seprvnu885xorz
(robertc) Create new server verb BzrDir.cloning_metadir and alter
        Branch.sprout to prevent race conditions during stacked
        branching. (Robert Collins, Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
 
20
20
from bzrlib import branch, errors, repository
21
 
from bzrlib.bzrdir import BzrDir, BzrDirFormat
 
21
from bzrlib.bzrdir import BzrDir, BzrDirFormat, BzrDirMetaFormat1
22
22
from bzrlib.smart.request import (
23
23
    FailedSmartServerResponse,
24
24
    SmartServerRequest,
53
53
 
54
54
class SmartServerRequestBzrDir(SmartServerRequest):
55
55
 
 
56
    def do(self, path, *args):
 
57
        """Open a BzrDir at path, and return self.do_bzrdir_request(*args)."""
 
58
        self._bzrdir = BzrDir.open_from_transport(
 
59
            self.transport_from_client_path(path))
 
60
        return self.do_bzrdir_request(*args)
 
61
 
56
62
    def _boolean_to_yes_no(self, a_boolean):
57
63
        if a_boolean:
58
64
            return 'yes'
80
86
        return '/'.join(segments)
81
87
 
82
88
 
 
89
class SmartServerBzrDirRequestCloningMetaDir(SmartServerRequestBzrDir):
 
90
 
 
91
    def do_bzrdir_request(self, require_stacking):
 
92
        """Get the format that should be used when cloning from this dir."""
 
93
        if require_stacking == "True":
 
94
            require_stacking = True
 
95
        else:
 
96
            require_stacking = False
 
97
        control_format = self._bzrdir.cloning_metadir(
 
98
            require_stacking=require_stacking)
 
99
        control_name = control_format.network_name()
 
100
        # XXX: There should be a method that tells us that the format does/does not
 
101
        # have subformats.
 
102
        if isinstance(control_format, BzrDirMetaFormat1):
 
103
            branch_name = control_format.get_branch_format().network_name()
 
104
            repository_name = control_format.repository_format.network_name()
 
105
        else:
 
106
            # Only MetaDir has delegated formats today.
 
107
            branch_name = ''
 
108
            repository_name = ''
 
109
        return SuccessfulSmartServerResponse((control_name, repository_name,
 
110
            branch_name))
 
111
 
 
112
 
83
113
class SmartServerRequestCreateBranch(SmartServerRequestBzrDir):
84
114
 
85
115
    def do(self, path, network_name):