/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: Robert J. Tanner
  • Date: 2009-04-29 05:53:21 UTC
  • mfrom: (4311 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4312.
  • Revision ID: tanner@real-time.com-20090429055321-v2s5l1mgki9f6cgn
[merge] 1.14 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
 
80
80
 
81
81
def tree_files_for_add(file_list):
82
 
    """Add handles files a bit differently so it a custom implementation."""
 
82
    """
 
83
    Return a tree and list of absolute paths from a file list.
 
84
 
 
85
    Similar to tree_files, but add handles files a bit differently, so it a
 
86
    custom implementation.  In particular, MutableTreeTree.smart_add expects
 
87
    absolute paths, which it immediately converts to relative paths.
 
88
    """
 
89
    # FIXME Would be nice to just return the relative paths like
 
90
    # internal_tree_files does, but there are a large number of unit tests
 
91
    # that assume the current interface to mutabletree.smart_add
83
92
    if file_list:
84
 
        tree = WorkingTree.open_containing(file_list[0])[0]
 
93
        tree, relpath = WorkingTree.open_containing(file_list[0])
85
94
        if tree.supports_views():
86
95
            view_files = tree.views.lookup_view()
87
96
            if view_files:
88
97
                for filename in file_list:
89
98
                    if not osutils.is_inside_any(view_files, filename):
90
99
                        raise errors.FileOutsideView(filename, view_files)
 
100
        file_list = file_list[:]
 
101
        file_list[0] = tree.abspath(relpath)
91
102
    else:
92
103
        tree = WorkingTree.open_containing(u'.')[0]
93
104
        if tree.supports_views():
1017
1028
        if revision is not None:
1018
1029
            revision_id = revision.in_history(br_from).rev_id
1019
1030
        else:
1020
 
            revision_id = br_from.last_revision()
 
1031
            revision_id = None
1021
1032
 
1022
1033
        # Get the stacked_on branch, if any
1023
1034
        if stacked_on is not None:
1575
1586
                    "\nYou may supply --create-prefix to create all"
1576
1587
                    " leading parent directories."
1577
1588
                    % location)
1578
 
            _create_prefix(to_transport)
 
1589
            to_transport.create_prefix()
1579
1590
 
1580
1591
        try:
1581
1592
            a_bzrdir = bzrdir.BzrDir.open_from_transport(to_transport)
3256
3267
 
3257
3268
        if cache_dir is not None:
3258
3269
            tree_creator.TreeCreator.CACHE_ROOT = osutils.abspath(cache_dir)
3259
 
        if not list_only:
3260
 
            print 'testing: %s' % (osutils.realpath(sys.argv[0]),)
3261
 
            print '   %s (%s python%s)' % (
3262
 
                    bzrlib.__path__[0],
3263
 
                    bzrlib.version_string,
3264
 
                    bzrlib._format_version_tuple(sys.version_info),
3265
 
                    )
3266
 
            print
3267
3270
        if testspecs_list is not None:
3268
3271
            pattern = '|'.join(testspecs_list)
3269
3272
        else:
3309
3312
        finally:
3310
3313
            if benchfile is not None:
3311
3314
                benchfile.close()
3312
 
        if not list_only:
3313
 
            if result:
3314
 
                note('tests passed')
3315
 
            else:
3316
 
                note('tests failed')
3317
3315
        return int(not result)
3318
3316
 
3319
3317
 
5596
5594
                   dry_run=dry_run, no_prompt=force)
5597
5595
 
5598
5596
 
5599
 
def _create_prefix(cur_transport):
5600
 
    needed = [cur_transport]
5601
 
    # Recurse upwards until we can create a directory successfully
5602
 
    while True:
5603
 
        new_transport = cur_transport.clone('..')
5604
 
        if new_transport.base == cur_transport.base:
5605
 
            raise errors.BzrCommandError(
5606
 
                "Failed to create path prefix for %s."
5607
 
                % cur_transport.base)
5608
 
        try:
5609
 
            new_transport.mkdir('.')
5610
 
        except errors.NoSuchFile:
5611
 
            needed.append(new_transport)
5612
 
            cur_transport = new_transport
5613
 
        else:
5614
 
            break
5615
 
    # Now we only need to create child directories
5616
 
    while needed:
5617
 
        cur_transport = needed.pop()
5618
 
        cur_transport.ensure_base()
5619
 
 
5620
 
 
5621
5597
# these get imported and then picked up by the scan for cmd_*
5622
5598
# TODO: Some more consistent way to split command definitions across files;
5623
5599
# we do need to load at least some information about them to know of
5628
5604
from bzrlib.bundle.commands import (
5629
5605
    cmd_bundle_info,
5630
5606
    )
 
5607
from bzrlib.foreign import cmd_dpush
5631
5608
from bzrlib.sign_my_commits import cmd_sign_my_commits
5632
5609
from bzrlib.weave_commands import cmd_versionedfile_list, \
5633
5610
        cmd_weave_plan_merge, cmd_weave_merge_text