~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/bzrdir.py

(jameinel) Allow 'bzr serve' to interpret SIGHUP as a graceful shutdown.
 (bug #795025) (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    BzrDir,
23
23
    BzrDirFormat,
24
24
    BzrDirMetaFormat1,
 
25
    BzrProber,
 
26
    )
 
27
from bzrlib.controldir import (
25
28
    network_format_registry,
26
29
    )
27
30
from bzrlib.smart.request import (
44
47
            # clients that don't anticipate errors from this method.
45
48
            answer = 'no'
46
49
        else:
47
 
            default_format = BzrDirFormat.get_default_format()
48
 
            real_bzrdir = default_format.open(t, _found=True)
 
50
            bzr_prober = BzrProber()
49
51
            try:
50
 
                real_bzrdir._format.probe_transport(t)
 
52
                bzr_prober.probe_transport(t)
51
53
            except (errors.NotBranchError, errors.UnknownFormatError):
52
54
                answer = 'no'
53
55
            else:
84
86
class SmartServerRequestBzrDir(SmartServerRequest):
85
87
 
86
88
    def do(self, path, *args):
87
 
        """Open a BzrDir at path, and return self.do_bzrdir_request(*args)."""
 
89
        """Open a BzrDir at path, and return `self.do_bzrdir_request(*args)`."""
88
90
        try:
89
91
            self._bzrdir = BzrDir.open_from_transport(
90
92
                self.transport_from_client_path(path))
148
150
        control_format = self._bzrdir.cloning_metadir(
149
151
            require_stacking=require_stacking)
150
152
        control_name = control_format.network_name()
151
 
        # XXX: There should be a method that tells us that the format does/does
152
 
        # not have subformats.
153
 
        if isinstance(control_format, BzrDirMetaFormat1):
 
153
        if not control_format.fixed_components:
154
154
            branch_name = ('branch',
155
155
                control_format.get_branch_format().network_name())
156
156
            repository_name = control_format.repository_format.network_name()
179
179
 
180
180
        :param path: The path to the bzrdir.
181
181
        :param network_name: The network name of the branch type to create.
182
 
        :return: (ok, network_name)
 
182
        :return: ('ok', branch_format, repo_path, rich_root, tree_ref,
 
183
            external_lookup, repo_format)
183
184
        """
184
185
        bzrdir = BzrDir.open_from_transport(
185
186
            self.transport_from_client_path(path))
429
430
            # It is returned locked, but we need to do the lock to get the lock
430
431
            # token.
431
432
            repo.unlock()
432
 
            repo_lock_token = repo.lock_write() or ''
 
433
            repo_lock_token = repo.lock_write().repository_token or ''
433
434
            if repo_lock_token:
434
435
                repo.leave_lock_in_place()
435
436
            repo.unlock()