/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/smart/bzrdir.py

  • Committer: Jelmer Vernooij
  • Date: 2011-11-20 02:16:25 UTC
  • mto: This revision was merged to the branch mainline in revision 6318.
  • Revision ID: jelmer@samba.org-20111120021625-ckv3ro8u6v8yswme
Convert to iter_files_bytes_bz2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib.bzrdir import (
22
22
    BzrDir,
23
23
    BzrDirFormat,
24
 
    BzrDirMetaFormat1,
 
24
    BzrProber,
 
25
    )
 
26
from bzrlib.controldir import (
25
27
    network_format_registry,
26
28
    )
27
29
from bzrlib.smart.request import (
44
46
            # clients that don't anticipate errors from this method.
45
47
            answer = 'no'
46
48
        else:
47
 
            default_format = BzrDirFormat.get_default_format()
48
 
            real_bzrdir = default_format.open(t, _found=True)
 
49
            bzr_prober = BzrProber()
49
50
            try:
50
 
                real_bzrdir._format.probe_transport(t)
 
51
                bzr_prober.probe_transport(t)
51
52
            except (errors.NotBranchError, errors.UnknownFormatError):
52
53
                answer = 'no'
53
54
            else:
84
85
class SmartServerRequestBzrDir(SmartServerRequest):
85
86
 
86
87
    def do(self, path, *args):
87
 
        """Open a BzrDir at path, and return self.do_bzrdir_request(*args)."""
 
88
        """Open a BzrDir at path, and return `self.do_bzrdir_request(*args)`."""
88
89
        try:
89
90
            self._bzrdir = BzrDir.open_from_transport(
90
91
                self.transport_from_client_path(path))
119
120
        return '/'.join(segments)
120
121
 
121
122
 
 
123
class SmartServerBzrDirRequestHasWorkingTree(SmartServerRequestBzrDir):
 
124
 
 
125
    def do_bzrdir_request(self, name=None):
 
126
        """Check whether there is a working tree present.
 
127
 
 
128
        New in 2.5.0.
 
129
 
 
130
        :return: If there is a working tree present, 'yes'.
 
131
            Otherwise 'no'.
 
132
        """
 
133
        if self._bzrdir.has_workingtree():
 
134
            return SuccessfulSmartServerResponse(('yes', ))
 
135
        else:
 
136
            return SuccessfulSmartServerResponse(('no', ))
 
137
 
 
138
 
 
139
class SmartServerBzrDirRequestDestroyRepository(SmartServerRequestBzrDir):
 
140
 
 
141
    def do_bzrdir_request(self, name=None):
 
142
        """Destroy the repository.
 
143
 
 
144
        New in 2.5.0.
 
145
 
 
146
        :return: On success, 'ok'.
 
147
        """
 
148
        try:
 
149
            self._bzrdir.destroy_repository()
 
150
        except errors.NoRepositoryPresent, e:
 
151
            return FailedSmartServerResponse(('norepository',))
 
152
        return SuccessfulSmartServerResponse(('ok',))
 
153
 
 
154
 
122
155
class SmartServerBzrDirRequestCloningMetaDir(SmartServerRequestBzrDir):
123
156
 
124
157
    def do_bzrdir_request(self, require_stacking):
148
181
        control_format = self._bzrdir.cloning_metadir(
149
182
            require_stacking=require_stacking)
150
183
        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):
 
184
        if not control_format.fixed_components:
154
185
            branch_name = ('branch',
155
186
                control_format.get_branch_format().network_name())
156
187
            repository_name = control_format.repository_format.network_name()
179
210
 
180
211
        :param path: The path to the bzrdir.
181
212
        :param network_name: The network name of the branch type to create.
182
 
        :return: (ok, network_name)
 
213
        :return: ('ok', branch_format, repo_path, rich_root, tree_ref,
 
214
            external_lookup, repo_format)
183
215
        """
184
216
        bzrdir = BzrDir.open_from_transport(
185
217
            self.transport_from_client_path(path))
429
461
            # It is returned locked, but we need to do the lock to get the lock
430
462
            # token.
431
463
            repo.unlock()
432
 
            repo_lock_token = repo.lock_write() or ''
 
464
            repo_lock_token = repo.lock_write().repository_token or ''
433
465
            if repo_lock_token:
434
466
                repo.leave_lock_in_place()
435
467
            repo.unlock()