~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/remote.py

  • Committer: John Arbash Meinel
  • Date: 2010-09-29 20:56:18 UTC
  • mto: This revision was merged to the branch mainline in revision 5452.
  • Revision ID: john@arbash-meinel.com-20100929205618-qlldxw4ykwt5511n
Move the new NEWS entry to the appropriate section.

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