~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: Jelmer Vernooij
  • Date: 2010-12-20 02:23:31 UTC
  • mto: This revision was merged to the branch mainline in revision 5577.
  • Revision ID: jelmer@samba.org-20101220022331-hbm91o1ps9gjrlns
Add testr magic for bzr selftest --list

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    branch,
22
22
    bzrdir,
23
23
    config,
 
24
    controldir,
24
25
    debug,
25
26
    errors,
26
27
    graph,
32
33
    revision as _mod_revision,
33
34
    static_tuple,
34
35
    symbol_versioning,
 
36
    urlutils,
35
37
)
36
38
from bzrlib.branch import BranchReferenceFormat, BranchWriteLockResult
37
39
from bzrlib.bzrdir import BzrDir, RemoteBzrDirFormat
213
215
        if len(branch_info) != 2:
214
216
            raise errors.UnexpectedSmartServerResponse(response)
215
217
        branch_ref, branch_name = branch_info
216
 
        format = bzrdir.network_format_registry.get(control_name)
 
218
        format = controldir.network_format_registry.get(control_name)
217
219
        if repo_name:
218
220
            format.repository_format = repository.network_format_registry.get(
219
221
                repo_name)
245
247
        self._ensure_real()
246
248
        self._real_bzrdir.destroy_repository()
247
249
 
248
 
    def create_branch(self, name=None):
 
250
    def create_branch(self, name=None, repository=None):
249
251
        # as per meta1 formats - just delegate to the format object which may
250
252
        # be parameterised.
251
253
        real_branch = self._format.get_branch_format().initialize(self,
252
 
            name=name)
 
254
            name=name, repository=repository)
253
255
        if not isinstance(real_branch, RemoteBranch):
254
 
            result = RemoteBranch(self, self.find_repository(), real_branch,
255
 
                                  name=name)
 
256
            if not isinstance(repository, RemoteRepository):
 
257
                raise AssertionError(
 
258
                    'need a RemoteRepository to use with RemoteBranch, got %r'
 
259
                    % (repository,))
 
260
            result = RemoteBranch(self, repository, real_branch, name=name)
256
261
        else:
257
262
            result = real_branch
258
263
        # BzrDir.clone_on_transport() uses the result of create_branch but does
270
275
        self._real_bzrdir.destroy_branch(name=name)
271
276
        self._next_open_branch_result = None
272
277
 
273
 
    def create_workingtree(self, revision_id=None, from_branch=None):
 
278
    def create_workingtree(self, revision_id=None, from_branch=None,
 
279
        accelerator_tree=None, hardlink=False):
274
280
        raise errors.NotLocalUrl(self.transport.base)
275
281
 
276
282
    def find_branch_format(self, name=None):
648
654
 
649
655
 
650
656
class RemoteRepository(_RpcHelper, lock._RelockDebugMixin,
651
 
    bzrdir.ControlComponent):
 
657
    controldir.ControlComponent):
652
658
    """Repository accessed over rpc.
653
659
 
654
660
    For the moment most operations are performed using local transport-backed
2091
2097
                                  name=name)
2092
2098
        return result
2093
2099
 
2094
 
    def initialize(self, a_bzrdir, name=None):
 
2100
    def initialize(self, a_bzrdir, name=None, repository=None):
2095
2101
        # 1) get the network name to use.
2096
2102
        if self._custom_format:
2097
2103
            network_name = self._custom_format.network_name()
2125
2131
        # Turn the response into a RemoteRepository object.
2126
2132
        format = RemoteBranchFormat(network_name=response[1])
2127
2133
        repo_format = response_tuple_to_repo_format(response[3:])
2128
 
        if response[2] == '':
2129
 
            repo_bzrdir = a_bzrdir
 
2134
        repo_path = response[2]
 
2135
        if repository is not None:
 
2136
            remote_repo_url = urlutils.join(medium.base, repo_path)
 
2137
            url_diff = urlutils.relative_url(repository.user_url,
 
2138
                    remote_repo_url)
 
2139
            if url_diff != '.':
 
2140
                raise AssertionError(
 
2141
                    'repository.user_url %r does not match URL from server '
 
2142
                    'response (%r + %r)'
 
2143
                    % (repository.user_url, medium.base, repo_path))
 
2144
            remote_repo = repository
2130
2145
        else:
2131
 
            repo_bzrdir = RemoteBzrDir(
2132
 
                a_bzrdir.root_transport.clone(response[2]), a_bzrdir._format,
2133
 
                a_bzrdir._client)
2134
 
        remote_repo = RemoteRepository(repo_bzrdir, repo_format)
 
2146
            if repo_path == '':
 
2147
                repo_bzrdir = a_bzrdir
 
2148
            else:
 
2149
                repo_bzrdir = RemoteBzrDir(
 
2150
                    a_bzrdir.root_transport.clone(repo_path), a_bzrdir._format,
 
2151
                    a_bzrdir._client)
 
2152
            remote_repo = RemoteRepository(repo_bzrdir, repo_format)
2135
2153
        remote_branch = RemoteBranch(a_bzrdir, remote_repo,
2136
2154
            format=format, setup_stacking=False, name=name)
2137
2155
        # XXX: We know this is a new branch, so it must have revno 0, revid
2367
2385
        self._ensure_real()
2368
2386
        return self._real_branch._get_tags_bytes()
2369
2387
 
 
2388
    @needs_read_lock
2370
2389
    def _get_tags_bytes(self):
 
2390
        if self._tags_bytes is None:
 
2391
            self._tags_bytes = self._get_tags_bytes_via_hpss()
 
2392
        return self._tags_bytes
 
2393
 
 
2394
    def _get_tags_bytes_via_hpss(self):
2371
2395
        medium = self._client._medium
2372
2396
        if medium._is_remote_before((1, 13)):
2373
2397
            return self._vfs_get_tags_bytes()
2383
2407
        return self._real_branch._set_tags_bytes(bytes)
2384
2408
 
2385
2409
    def _set_tags_bytes(self, bytes):
 
2410
        if self.is_locked():
 
2411
            self._tags_bytes = bytes
2386
2412
        medium = self._client._medium
2387
2413
        if medium._is_remote_before((1, 18)):
2388
2414
            self._vfs_set_tags_bytes(bytes)