~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 15:51:57 UTC
  • mfrom: (1551.15.20 Aaron's mergeable stuff)
  • Revision ID: pqm@pqm.ubuntu.com-20070612155157-j1juioefu5w946ph
Skip intermittently failing test

Show diffs side-by-side

added added

removed removed

Lines of Context:
755
755
                        " leading parent directories."
756
756
                        % location)
757
757
 
758
 
                _create_prefix(to_transport)
 
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()
759
779
 
760
780
            # Now the target directory exists, but doesn't have a .bzr
761
781
            # directory. So we need to create it, along with any work to create
1250
1270
    _see_also = ['init-repo', 'branch', 'checkout']
1251
1271
    takes_args = ['location?']
1252
1272
    takes_options = [
1253
 
        Option('create-prefix',
1254
 
               help='Create the path leading up to the branch '
1255
 
                    'if it does not already exist'),
1256
1273
         RegistryOption('format',
1257
1274
                help='Specify a format for this branch. '
1258
1275
                'See "help formats".',
1265
1282
                help='Never change revnos or the existing log.'
1266
1283
                '  Append revisions to it only.')
1267
1284
         ]
1268
 
    def run(self, location=None, format=None, append_revisions_only=False,
1269
 
            create_prefix=False):
 
1285
    def run(self, location=None, format=None, append_revisions_only=False):
1270
1286
        if format is None:
1271
1287
            format = bzrdir.format_registry.make_bzrdir('default')
1272
1288
        if location is None:
1279
1295
        # Just using os.mkdir, since I don't
1280
1296
        # believe that we want to create a bunch of
1281
1297
        # locations if the user supplies an extended path
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)
 
1298
        # TODO: create-prefix
 
1299
        to_transport.ensure_base()
1292
1300
 
1293
1301
        try:
1294
1302
            existing_bzrdir = bzrdir.BzrDir.open(location)
3766
3774
    return conflicts
3767
3775
 
3768
3776
 
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
 
 
3791
3777
# Compatibility
3792
3778
merge = _merge_helper
3793
3779