~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:
33
33
    revision as _mod_revision,
34
34
    static_tuple,
35
35
    symbol_versioning,
 
36
    urlutils,
36
37
)
37
38
from bzrlib.branch import BranchReferenceFormat, BranchWriteLockResult
38
39
from bzrlib.bzrdir import BzrDir, RemoteBzrDirFormat
246
247
        self._ensure_real()
247
248
        self._real_bzrdir.destroy_repository()
248
249
 
249
 
    def create_branch(self, name=None):
 
250
    def create_branch(self, name=None, repository=None):
250
251
        # as per meta1 formats - just delegate to the format object which may
251
252
        # be parameterised.
252
253
        real_branch = self._format.get_branch_format().initialize(self,
253
 
            name=name)
 
254
            name=name, repository=repository)
254
255
        if not isinstance(real_branch, RemoteBranch):
255
 
            result = RemoteBranch(self, self.find_repository(), real_branch,
256
 
                                  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)
257
261
        else:
258
262
            result = real_branch
259
263
        # BzrDir.clone_on_transport() uses the result of create_branch but does
271
275
        self._real_bzrdir.destroy_branch(name=name)
272
276
        self._next_open_branch_result = None
273
277
 
274
 
    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):
275
280
        raise errors.NotLocalUrl(self.transport.base)
276
281
 
277
282
    def find_branch_format(self, name=None):
2092
2097
                                  name=name)
2093
2098
        return result
2094
2099
 
2095
 
    def initialize(self, a_bzrdir, name=None):
 
2100
    def initialize(self, a_bzrdir, name=None, repository=None):
2096
2101
        # 1) get the network name to use.
2097
2102
        if self._custom_format:
2098
2103
            network_name = self._custom_format.network_name()
2126
2131
        # Turn the response into a RemoteRepository object.
2127
2132
        format = RemoteBranchFormat(network_name=response[1])
2128
2133
        repo_format = response_tuple_to_repo_format(response[3:])
2129
 
        if response[2] == '':
2130
 
            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
2131
2145
        else:
2132
 
            repo_bzrdir = RemoteBzrDir(
2133
 
                a_bzrdir.root_transport.clone(response[2]), a_bzrdir._format,
2134
 
                a_bzrdir._client)
2135
 
        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)
2136
2153
        remote_branch = RemoteBranch(a_bzrdir, remote_repo,
2137
2154
            format=format, setup_stacking=False, name=name)
2138
2155
        # XXX: We know this is a new branch, so it must have revno 0, revid
2368
2385
        self._ensure_real()
2369
2386
        return self._real_branch._get_tags_bytes()
2370
2387
 
 
2388
    @needs_read_lock
2371
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):
2372
2395
        medium = self._client._medium
2373
2396
        if medium._is_remote_before((1, 13)):
2374
2397
            return self._vfs_get_tags_bytes()
2384
2407
        return self._real_branch._set_tags_bytes(bytes)
2385
2408
 
2386
2409
    def _set_tags_bytes(self, bytes):
 
2410
        if self.is_locked():
 
2411
            self._tags_bytes = bytes
2387
2412
        medium = self._client._medium
2388
2413
        if medium._is_remote_before((1, 18)):
2389
2414
            self._vfs_set_tags_bytes(bytes)