~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-19 12:08:42 UTC
  • mfrom: (6437.3.8 2.5)
  • mto: (6437.3.14 2.5)
  • mto: This revision was merged to the branch mainline in revision 6444.
  • Revision ID: jelmer@samba.org-20120119120842-xlq5ru2cqfcurnk9
MergeĀ lp:bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2038
2038
        :param name: Name of colocated branch to create, if any
2039
2039
        :return: a branch in this format
2040
2040
        """
 
2041
        if name is None:
 
2042
            name = a_bzrdir._get_selected_branch()
2041
2043
        mutter('creating branch %r in %s', self, a_bzrdir.user_url)
2042
2044
        branch_transport = a_bzrdir.get_branch_transport(self, name=name)
2043
2045
        control_files = lockable_files.LockableFiles(branch_transport,
2060
2062
    def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False,
2061
2063
            found_repository=None, possible_transports=None):
2062
2064
        """See BranchFormat.open()."""
 
2065
        if name is None:
 
2066
            name = a_bzrdir._get_selected_branch()
2063
2067
        if not _found:
2064
2068
            format = BranchFormatMetadir.find_format(a_bzrdir, name=name)
2065
2069
            if format.__class__ != self.__class__:
2305
2309
        mutter('creating branch reference in %s', a_bzrdir.user_url)
2306
2310
        if a_bzrdir._format.fixed_components:
2307
2311
            raise errors.IncompatibleFormat(self, a_bzrdir._format)
 
2312
        if name is None:
 
2313
            name = a_bzrdir._get_selected_branch()
2308
2314
        branch_transport = a_bzrdir.get_branch_transport(self, name=name)
2309
2315
        branch_transport.put_bytes('location',
2310
2316
            target_branch.user_url)
2311
2317
        branch_transport.put_bytes('format', self.as_string())
2312
 
        branch = self.open(
2313
 
            a_bzrdir, name, _found=True,
 
2318
        branch = self.open(a_bzrdir, name, _found=True,
2314
2319
            possible_transports=[target_branch.bzrdir.root_transport])
2315
2320
        self._run_post_branch_init_hooks(a_bzrdir, name, branch)
2316
2321
        return branch
2342
2347
            a_bzrdir.
2343
2348
        :param possible_transports: An optional reusable transports list.
2344
2349
        """
 
2350
        if name is None:
 
2351
            name = a_bzrdir._get_selected_branch()
2345
2352
        if not _found:
2346
2353
            format = BranchFormatMetadir.find_format(a_bzrdir, name=name)
2347
2354
            if format.__class__ != self.__class__:
2351
2358
            location = self.get_reference(a_bzrdir, name)
2352
2359
        real_bzrdir = controldir.ControlDir.open(
2353
2360
            location, possible_transports=possible_transports)
2354
 
        result = real_bzrdir.open_branch(name=name, 
2355
 
            ignore_fallbacks=ignore_fallbacks,
 
2361
        result = real_bzrdir.open_branch(ignore_fallbacks=ignore_fallbacks,
2356
2362
            possible_transports=possible_transports)
2357
2363
        # this changes the behaviour of result.clone to create a new reference
2358
2364
        # rather than a copy of the content of the branch.
2445
2451
        """Create new branch object at a particular location."""
2446
2452
        if a_bzrdir is None:
2447
2453
            raise ValueError('a_bzrdir must be supplied')
2448
 
        else:
2449
 
            self.bzrdir = a_bzrdir
 
2454
        if name is None:
 
2455
            raise ValueError('name must be supplied')
 
2456
        self.bzrdir = a_bzrdir
2450
2457
        self._user_transport = self.bzrdir.transport.clone('..')
2451
 
        if name is not None:
 
2458
        if name != "":
2452
2459
            self._user_transport.set_segment_parameter(
2453
2460
                "branch", urlutils.escape(name))
2454
2461
        self._base = self._user_transport.base