~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Aaron Bentley
  • Date: 2009-04-23 20:14:18 UTC
  • mfrom: (4301.1.1 bzr.dev.orig)
  • mto: This revision was merged to the branch mainline in revision 4306.
  • Revision ID: aaron@aaronbentley.com-20090423201418-aluo26hrvq26k2n3
Merge updates for tree_files_for_add

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
                                     (e.path, file_list[0]))
79
79
 
80
80
 
 
81
"""
 
82
Add handles files a bit differently so it a custom implementation.
 
83
In particular smart_add expects absolute paths, which it immediately converts
 
84
to relative paths. Would be nice to just return the relative paths like internal_tree_files
 
85
does but there are a large number of unit tests that assume the current interface to 
 
86
mutabletree.smart_add
 
87
"""
81
88
def tree_files_for_add(file_list):
82
 
    """Add handles files a bit differently so it a custom implementation."""
83
89
    if file_list:
84
 
        tree = WorkingTree.open_containing(file_list[0])[0]
 
90
        tree, relpath = WorkingTree.open_containing(file_list[0])
 
91
        relfile_list = [relpath] + osutils.canonical_relpaths(tree.basedir, file_list[1:])
85
92
        if tree.supports_views():
86
93
            view_files = tree.views.lookup_view()
87
94
            if view_files:
88
95
                for filename in file_list:
89
96
                    if not osutils.is_inside_any(view_files, filename):
90
97
                        raise errors.FileOutsideView(filename, view_files)
 
98
        return tree, map(tree.abspath, relfile_list)
91
99
    else:
92
100
        tree = WorkingTree.open_containing(u'.')[0]
93
101
        if tree.supports_views():
96
104
                file_list = view_files
97
105
                view_str = views.view_display_str(view_files)
98
106
                note("Ignoring files outside view. View is %s" % view_str)
99
 
    return tree, file_list
 
107
        return tree, file_list
100
108
 
101
109
 
102
110
def _get_one_revision(command_name, revisions):