~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-06-12 17:28:39 UTC
  • mfrom: (1551.15.22 Aaron's mergeable stuff)
  • Revision ID: pqm@pqm.ubuntu.com-20070612172839-mr0bjmyfguskc0tg
Fix botched merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
755
755
                        " leading parent directories."
756
756
                        % location)
757
757
 
758
 
                cur_transport = to_transport
759
 
                needed = [cur_transport]
760
 
                # Recurse upwards until we can create a directory successfully
761
 
                while True:
762
 
                    new_transport = cur_transport.clone('..')
763
 
                    if new_transport.base == cur_transport.base:
764
 
                        raise errors.BzrCommandError("Failed to create path"
765
 
                                                     " prefix for %s."
766
 
                                                     % location)
767
 
                    try:
768
 
                        new_transport.mkdir('.')
769
 
                    except errors.NoSuchFile:
770
 
                        needed.append(new_transport)
771
 
                        cur_transport = new_transport
772
 
                    else:
773
 
                        break
774
 
 
775
 
                # Now we only need to create child directories
776
 
                while needed:
777
 
                    cur_transport = needed.pop()
778
 
                    cur_transport.ensure_base()
 
758
                _create_prefix(to_transport)
779
759
 
780
760
            # Now the target directory exists, but doesn't have a .bzr
781
761
            # directory. So we need to create it, along with any work to create
1270
1250
    _see_also = ['init-repo', 'branch', 'checkout']
1271
1251
    takes_args = ['location?']
1272
1252
    takes_options = [
 
1253
        Option('create-prefix',
 
1254
               help='Create the path leading up to the branch '
 
1255
                    'if it does not already exist'),
1273
1256
         RegistryOption('format',
1274
1257
                help='Specify a format for this branch. '
1275
1258
                'See "help formats".',
1282
1265
                help='Never change revnos or the existing log.'
1283
1266
                '  Append revisions to it only.')
1284
1267
         ]
1285
 
    def run(self, location=None, format=None, append_revisions_only=False):
 
1268
    def run(self, location=None, format=None, append_revisions_only=False,
 
1269
            create_prefix=False):
1286
1270
        if format is None:
1287
1271
            format = bzrdir.format_registry.make_bzrdir('default')
1288
1272
        if location is None:
1295
1279
        # Just using os.mkdir, since I don't
1296
1280
        # believe that we want to create a bunch of
1297
1281
        # locations if the user supplies an extended path
1298
 
        # TODO: create-prefix
1299
 
        to_transport.ensure_base()
 
1282
        try:
 
1283
            to_transport.ensure_base()
 
1284
        except errors.NoSuchFile:
 
1285
            if not create_prefix:
 
1286
                raise errors.BzrCommandError("Parent directory of %s"
 
1287
                    " does not exist."
 
1288
                    "\nYou may supply --create-prefix to create all"
 
1289
                    " leading parent directories."
 
1290
                    % location)
 
1291
            _create_prefix(to_transport)
1300
1292
 
1301
1293
        try:
1302
1294
            existing_bzrdir = bzrdir.BzrDir.open(location)
3774
3766
    return conflicts
3775
3767
 
3776
3768
 
 
3769
def _create_prefix(cur_transport):
 
3770
    needed = [cur_transport]
 
3771
    # Recurse upwards until we can create a directory successfully
 
3772
    while True:
 
3773
        new_transport = cur_transport.clone('..')
 
3774
        if new_transport.base == cur_transport.base:
 
3775
            raise errors.BzrCommandError("Failed to create path"
 
3776
                                         " prefix for %s."
 
3777
                                         % location)
 
3778
        try:
 
3779
            new_transport.mkdir('.')
 
3780
        except errors.NoSuchFile:
 
3781
            needed.append(new_transport)
 
3782
            cur_transport = new_transport
 
3783
        else:
 
3784
            break
 
3785
 
 
3786
    # Now we only need to create child directories
 
3787
    while needed:
 
3788
        cur_transport = needed.pop()
 
3789
        cur_transport.ensure_base()
 
3790
 
3777
3791
# Compatibility
3778
3792
merge = _merge_helper
3779
3793