~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: John Arbash Meinel
  • Date: 2009-04-30 01:54:04 UTC
  • mfrom: (4312 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4314.
  • Revision ID: john@arbash-meinel.com-20090430015404-iwf322ortskqb1pr
Merge bzr.dev 4312

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)
5583
5594
                   dry_run=dry_run, no_prompt=force)
5584
5595
 
5585
5596
 
5586
 
def _create_prefix(cur_transport):
5587
 
    needed = [cur_transport]
5588
 
    # Recurse upwards until we can create a directory successfully
5589
 
    while True:
5590
 
        new_transport = cur_transport.clone('..')
5591
 
        if new_transport.base == cur_transport.base:
5592
 
            raise errors.BzrCommandError(
5593
 
                "Failed to create path prefix for %s."
5594
 
                % cur_transport.base)
5595
 
        try:
5596
 
            new_transport.mkdir('.')
5597
 
        except errors.NoSuchFile:
5598
 
            needed.append(new_transport)
5599
 
            cur_transport = new_transport
5600
 
        else:
5601
 
            break
5602
 
    # Now we only need to create child directories
5603
 
    while needed:
5604
 
        cur_transport = needed.pop()
5605
 
        cur_transport.ensure_base()
5606
 
 
5607
 
 
5608
5597
# these get imported and then picked up by the scan for cmd_*
5609
5598
# TODO: Some more consistent way to split command definitions across files;
5610
5599
# we do need to load at least some information about them to know of