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

  • Committer: Aaron Bentley
  • Date: 2007-06-14 04:36:50 UTC
  • mfrom: (2527 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2528.
  • Revision ID: aaron.bentley@utoronto.ca-20070614043650-q2yb3mo03kcr8l2p
Merge bzr.dev

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
852
832
 
853
833
    If the TO_LOCATION is omitted, the last component of the FROM_LOCATION will
854
834
    be used.  In other words, "branch ../foo/bar" will attempt to create ./bar.
 
835
    If the FROM_LOCATION has no / or path separator embedded, the TO_LOCATION
 
836
    is derived from the FROM_LOCATION by stripping a leading scheme or drive
 
837
    identifier, if any. For example, "branch lp:foo-bar" will attempt to
 
838
    create ./foo-bar.
855
839
 
856
840
    To retrieve the branch as of a particular revision, supply the --revision
857
841
    parameter, as in "branch foo/bar -r 5".
881
865
                # RBC 20060209
882
866
                revision_id = br_from.last_revision()
883
867
            if to_location is None:
884
 
                to_location = os.path.basename(from_location.rstrip("/\\"))
 
868
                to_location = urlutils.derive_to_location(from_location)
885
869
                name = None
886
870
            else:
887
871
                name = os.path.basename(to_location) + '\n'
921
905
    
922
906
    If the TO_LOCATION is omitted, the last component of the BRANCH_LOCATION will
923
907
    be used.  In other words, "checkout ../foo/bar" will attempt to create ./bar.
 
908
    If the BRANCH_LOCATION has no / or path separator embedded, the TO_LOCATION
 
909
    is derived from the BRANCH_LOCATION by stripping a leading scheme or drive
 
910
    identifier, if any. For example, "checkout lp:foo-bar" will attempt to
 
911
    create ./foo-bar.
924
912
 
925
913
    To retrieve the branch as of a particular revision, supply the --revision
926
914
    parameter, as in "checkout foo/bar -r 5". Note that this will be immediately
957
945
        else:
958
946
            revision_id = None
959
947
        if to_location is None:
960
 
            to_location = os.path.basename(branch_location.rstrip("/\\"))
 
948
            to_location = urlutils.derive_to_location(branch_location)
961
949
        # if the source and to_location are the same, 
962
950
        # and there is no working tree,
963
951
        # then reconstitute a branch
1262
1250
    _see_also = ['init-repo', 'branch', 'checkout']
1263
1251
    takes_args = ['location?']
1264
1252
    takes_options = [
 
1253
        Option('create-prefix',
 
1254
               help='Create the path leading up to the branch '
 
1255
                    'if it does not already exist'),
1265
1256
         RegistryOption('format',
1266
1257
                help='Specify a format for this branch. '
1267
1258
                'See "help formats".',
1274
1265
                help='Never change revnos or the existing log.'
1275
1266
                '  Append revisions to it only.')
1276
1267
         ]
1277
 
    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):
1278
1270
        if format is None:
1279
1271
            format = bzrdir.format_registry.make_bzrdir('default')
1280
1272
        if location is None:
1287
1279
        # Just using os.mkdir, since I don't
1288
1280
        # believe that we want to create a bunch of
1289
1281
        # locations if the user supplies an extended path
1290
 
        # TODO: create-prefix
1291
 
        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)
1292
1292
 
1293
1293
        try:
1294
1294
            existing_bzrdir = bzrdir.BzrDir.open(location)
3766
3766
    return conflicts
3767
3767
 
3768
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
 
3769
3791
# Compatibility
3770
3792
merge = _merge_helper
3771
3793