~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Patch Queue Manager
  • Date: 2011-10-13 14:09:11 UTC
  • mfrom: (6207.2.1 colo-fixes)
  • Revision ID: pqm@pqm.ubuntu.com-20111013140911-c2zv6a9pux62xnr9
(jelmer) Add support for cloning into a colocated branch. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1317
1317
                    'already exists.') % to_location)
1318
1318
            else:
1319
1319
                try:
1320
 
                    bzrdir.BzrDir.open_from_transport(to_transport)
 
1320
                    to_dir = bzrdir.BzrDir.open_from_transport(to_transport)
1321
1321
                except errors.NotBranchError:
1322
 
                    pass
 
1322
                    to_dir = None
1323
1323
                else:
1324
 
                    raise errors.AlreadyBranchError(to_location)
 
1324
                    try:
 
1325
                        to_dir.open_branch()
 
1326
                    except errors.NotBranchError:
 
1327
                        pass
 
1328
                    else:
 
1329
                        raise errors.AlreadyBranchError(to_location)
1325
1330
        except errors.NoSuchFile:
1326
1331
            raise errors.BzrCommandError(gettext('Parent of "%s" does not exist.')
1327
1332
                                         % to_location)
1328
 
        try:
1329
 
            # preserve whatever source format we have.
1330
 
            dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
1331
 
                                        possible_transports=[to_transport],
1332
 
                                        accelerator_tree=accelerator_tree,
1333
 
                                        hardlink=hardlink, stacked=stacked,
1334
 
                                        force_new_repo=standalone,
1335
 
                                        create_tree_if_local=not no_tree,
1336
 
                                        source_branch=br_from)
1337
 
            branch = dir.open_branch()
1338
 
        except errors.NoSuchRevision:
1339
 
            to_transport.delete_tree('.')
1340
 
            msg = gettext("The branch {0} has no revision {1}.").format(
1341
 
                from_location, revision)
1342
 
            raise errors.BzrCommandError(msg)
 
1333
        else:
 
1334
            to_dir = None
 
1335
        if to_dir is None:
 
1336
            try:
 
1337
                # preserve whatever source format we have.
 
1338
                to_dir = br_from.bzrdir.sprout(to_transport.base, revision_id,
 
1339
                                            possible_transports=[to_transport],
 
1340
                                            accelerator_tree=accelerator_tree,
 
1341
                                            hardlink=hardlink, stacked=stacked,
 
1342
                                            force_new_repo=standalone,
 
1343
                                            create_tree_if_local=not no_tree,
 
1344
                                            source_branch=br_from)
 
1345
                branch = to_dir.open_branch()
 
1346
            except errors.NoSuchRevision:
 
1347
                to_transport.delete_tree('.')
 
1348
                msg = gettext("The branch {0} has no revision {1}.").format(
 
1349
                    from_location, revision)
 
1350
                raise errors.BzrCommandError(msg)
 
1351
        else:
 
1352
            branch = br_from.sprout(to_dir, revision_id=revision_id)
1343
1353
        _merge_tags_if_possible(br_from, branch)
1344
1354
        # If the source branch is stacked, the new branch may
1345
1355
        # be stacked whether we asked for that explicitly or not.