/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/remote.py

  • Committer: Jelmer Vernooij
  • Date: 2010-03-02 22:25:58 UTC
  • mto: This revision was merged to the branch mainline in revision 5085.
  • Revision ID: jelmer@samba.org-20100302222558-n7dr3fccme9an18t
Pass colocated branch name around in more places.

Show diffs side-by-side

added added

removed removed

Lines of Context:
243
243
        self._real_bzrdir.destroy_repository()
244
244
 
245
245
    def create_branch(self, name=None):
246
 
        if name is not None:
247
 
            raise errors.NoColocatedBranchSupport(self)
248
246
        # as per meta1 formats - just delegate to the format object which may
249
247
        # be parameterised.
250
 
        real_branch = self._format.get_branch_format().initialize(self)
 
248
        real_branch = self._format.get_branch_format().initialize(self,
 
249
            name=name)
251
250
        if not isinstance(real_branch, RemoteBranch):
252
 
            result = RemoteBranch(self, self.find_repository(), real_branch)
 
251
            result = RemoteBranch(self, self.find_repository(), real_branch,
 
252
                                  name=name)
253
253
        else:
254
254
            result = real_branch
255
255
        # BzrDir.clone_on_transport() uses the result of create_branch but does
324
324
                    ignore_fallbacks=False):
325
325
        if unsupported:
326
326
            raise NotImplementedError('unsupported flag support not implemented yet.')
327
 
        if name is not None:
328
 
            raise errors.NoColocatedBranchSupport(self)
329
327
        if self._next_open_branch_result is not None:
330
328
            # See create_branch for details.
331
329
            result = self._next_open_branch_result
335
333
        if response[0] == 'ref':
336
334
            # a branch reference, use the existing BranchReference logic.
337
335
            format = BranchReferenceFormat()
338
 
            return format.open(self, _found=True, location=response[1],
339
 
                ignore_fallbacks=ignore_fallbacks)
 
336
            return format.open(self, name=name, _found=True,
 
337
                location=response[1], ignore_fallbacks=ignore_fallbacks)
340
338
        branch_format_name = response[1]
341
339
        if not branch_format_name:
342
340
            branch_format_name = None
343
341
        format = RemoteBranchFormat(network_name=branch_format_name)
344
342
        return RemoteBranch(self, self.find_repository(), format=format,
345
 
            setup_stacking=not ignore_fallbacks)
 
343
            setup_stacking=not ignore_fallbacks, name=name)
346
344
 
347
345
    def _open_repo_v1(self, path):
348
346
        verb = 'BzrDir.find_repository'
425
423
        """Return the path to be used for this bzrdir in a remote call."""
426
424
        return client.remote_path_from_transport(self.root_transport)
427
425
 
428
 
    def get_branch_transport(self, branch_format):
 
426
    def get_branch_transport(self, branch_format, name=None):
429
427
        self._ensure_real()
430
 
        return self._real_bzrdir.get_branch_transport(branch_format)
 
428
        return self._real_bzrdir.get_branch_transport(branch_format, name=name)
431
429
 
432
430
    def get_repository_transport(self, repository_format):
433
431
        self._ensure_real()
2026
2024
    def network_name(self):
2027
2025
        return self._network_name
2028
2026
 
2029
 
    def open(self, a_bzrdir, ignore_fallbacks=False):
2030
 
        return a_bzrdir.open_branch(ignore_fallbacks=ignore_fallbacks)
 
2027
    def open(self, a_bzrdir, name=None, ignore_fallbacks=False):
 
2028
        return a_bzrdir.open_branch(name=name, 
 
2029
            ignore_fallbacks=ignore_fallbacks)
2031
2030
 
2032
 
    def _vfs_initialize(self, a_bzrdir):
 
2031
    def _vfs_initialize(self, a_bzrdir, name):
2033
2032
        # Initialisation when using a local bzrdir object, or a non-vfs init
2034
2033
        # method is not available on the server.
2035
2034
        # self._custom_format is always set - the start of initialize ensures
2036
2035
        # that.
2037
2036
        if isinstance(a_bzrdir, RemoteBzrDir):
2038
2037
            a_bzrdir._ensure_real()
2039
 
            result = self._custom_format.initialize(a_bzrdir._real_bzrdir)
 
2038
            result = self._custom_format.initialize(a_bzrdir._real_bzrdir,
 
2039
                name)
2040
2040
        else:
2041
2041
            # We assume the bzrdir is parameterised; it may not be.
2042
 
            result = self._custom_format.initialize(a_bzrdir)
 
2042
            result = self._custom_format.initialize(a_bzrdir, name)
2043
2043
        if (isinstance(a_bzrdir, RemoteBzrDir) and
2044
2044
            not isinstance(result, RemoteBranch)):
2045
 
            result = RemoteBranch(a_bzrdir, a_bzrdir.find_repository(), result)
 
2045
            result = RemoteBranch(a_bzrdir, a_bzrdir.find_repository(), result,
 
2046
                                  name=name)
2046
2047
        return result
2047
2048
 
2048
 
    def initialize(self, a_bzrdir):
 
2049
    def initialize(self, a_bzrdir, name=None):
2049
2050
        # 1) get the network name to use.
2050
2051
        if self._custom_format:
2051
2052
            network_name = self._custom_format.network_name()
2057
2058
            network_name = reference_format.network_name()
2058
2059
        # Being asked to create on a non RemoteBzrDir:
2059
2060
        if not isinstance(a_bzrdir, RemoteBzrDir):
2060
 
            return self._vfs_initialize(a_bzrdir)
 
2061
            return self._vfs_initialize(a_bzrdir, name=name)
2061
2062
        medium = a_bzrdir._client._medium
2062
2063
        if medium._is_remote_before((1, 13)):
2063
 
            return self._vfs_initialize(a_bzrdir)
 
2064
            return self._vfs_initialize(a_bzrdir, name=name)
2064
2065
        # Creating on a remote bzr dir.
2065
2066
        # 2) try direct creation via RPC
2066
2067
        path = a_bzrdir._path_for_remote_call(a_bzrdir._client)
 
2068
        if name is not None:
 
2069
            raise errors.NoColocatedBranchSupport(self)
2067
2070
        verb = 'BzrDir.create_branch'
2068
2071
        try:
2069
2072
            response = a_bzrdir._call(verb, path, network_name)
2070
2073
        except errors.UnknownSmartMethod:
2071
2074
            # Fallback - use vfs methods
2072
2075
            medium._remember_remote_is_before((1, 13))
2073
 
            return self._vfs_initialize(a_bzrdir)
 
2076
            return self._vfs_initialize(a_bzrdir, name=name)
2074
2077
        if response[0] != 'ok':
2075
2078
            raise errors.UnexpectedSmartServerResponse(response)
2076
2079
        # Turn the response into a RemoteRepository object.
2084
2087
                a_bzrdir._client)
2085
2088
        remote_repo = RemoteRepository(repo_bzrdir, repo_format)
2086
2089
        remote_branch = RemoteBranch(a_bzrdir, remote_repo,
2087
 
            format=format, setup_stacking=False)
 
2090
            format=format, setup_stacking=False, name=name)
2088
2091
        # XXX: We know this is a new branch, so it must have revno 0, revid
2089
2092
        # NULL_REVISION. Creating the branch locked would make this be unable
2090
2093
        # to be wrong; here its simply very unlikely to be wrong. RBC 20090225
2117
2120
    """
2118
2121
 
2119
2122
    def __init__(self, remote_bzrdir, remote_repository, real_branch=None,
2120
 
        _client=None, format=None, setup_stacking=True):
 
2123
        _client=None, format=None, setup_stacking=True, name=None):
2121
2124
        """Create a RemoteBranch instance.
2122
2125
 
2123
2126
        :param real_branch: An optional local implementation of the branch
2129
2132
        :param setup_stacking: If True make an RPC call to determine the
2130
2133
            stacked (or not) status of the branch. If False assume the branch
2131
2134
            is not stacked.
 
2135
        :param name: Colocated branch name
2132
2136
        """
2133
2137
        # We intentionally don't call the parent class's __init__, because it
2134
2138
        # will try to assign to self.tags, which is a property in this subclass.
2154
2158
        # Fill out expected attributes of branch for bzrlib API users.
2155
2159
        self._clear_cached_state()
2156
2160
        self.base = self.bzrdir.root_transport.base
 
2161
        self._name = name
2157
2162
        self._control_files = None
2158
2163
        self._lock_mode = None
2159
2164
        self._lock_token = None
2224
2229
                    'to use vfs implementation')
2225
2230
            self.bzrdir._ensure_real()
2226
2231
            self._real_branch = self.bzrdir._real_bzrdir.open_branch(
2227
 
                ignore_fallbacks=self._real_ignore_fallbacks)
 
2232
                ignore_fallbacks=self._real_ignore_fallbacks, name=self._name)
2228
2233
            if self.repository._real_repository is None:
2229
2234
                # Give the remote repository the matching real repo.
2230
2235
                real_repo = self._real_branch.repository