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

  • Committer: Robert Collins
  • Date: 2006-05-23 00:03:45 UTC
  • mto: (1724.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1725.
  • Revision ID: robertc@robertcollins.net-20060523000345-b54523c712b3b696
Review feedback.

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
    from bzrlib.errors import BadFileKindError, ForbiddenFileError
106
106
    assert isinstance(recurse, bool)
107
107
    
108
 
    orig_list = file_list
109
 
    file_list = _prepare_file_list(file_list)
110
 
    mutter("smart add of %r, originally %r", file_list, orig_list)
 
108
    prepared_list = _prepare_file_list(file_list)
 
109
    mutter("smart add of %r, originally %r", prepared_list, file_list)
111
110
    inv = tree.read_working_inventory()
112
111
    added = []
113
112
    ignored = {}
114
 
    user_files = list(file_list)
115
 
    file_list = []
 
113
    user_files = set()
 
114
    files_to_add = []
116
115
 
117
116
    # validate user file paths and convert all paths to tree 
118
117
    # relative : its cheaper to make a tree relative path an abspath
119
118
    # than to convert an abspath to tree relative.
120
 
    for filepath in user_files:
 
119
    for filepath in prepared_list:
121
120
        rf = tree.relpath(filepath)
122
 
        file_list.append((rf, None))
 
121
        user_files.add(rf)
 
122
        files_to_add.append((rf, None))
123
123
        # validate user parameters. Our recursive code avoids adding new files
124
124
        # that need such validation 
125
125
        if tree.is_control_filename(rf):
126
126
            raise ForbiddenFileError('cannot add control file %s' % filepath)
127
127
 
128
 
    user_files = set([path for path, parent_ie in file_list])
129
 
        
130
 
    for filepath, parent_ie in file_list:
 
128
    for filepath, parent_ie in files_to_add:
131
129
        # filepath is tree-relative
132
130
        abspath = tree.abspath(filepath)
133
131
 
221
219
                        ignored[ignore_glob].append(subp)
222
220
                    else:
223
221
                        #mutter("queue to add sub-file %r", subp)
224
 
                        file_list.append((subp, this_ie))
 
222
                        files_to_add.append((subp, this_ie))
225
223
 
226
224
    if len(added) > 0:
227
225
        tree._write_inventory(inv)
229
227
 
230
228
 
231
229
def __add_one(tree, inv, parent_ie, path, kind, action):
232
 
    """Add a file or directory, automatically add unversioned parents."""
 
230
    """Add a new entry to the inventory and automatically add unversioned parents.
 
231
 
 
232
    Actual adding of the entry is delegated to the action callback.
 
233
 
 
234
    :param inv: Inventory which will receive the new entry.
 
235
    :param parent_ie: Parent inventory entry if known, or None.  If
 
236
    None, the parent is looked up by name and used if present, otherwise
 
237
    it is recursively added.
 
238
    :param kind: Kind of new entry (file, directory, etc)
 
239
    :param action: callback(inv, parent_ie, path, kind); return ignored.
 
240
    :returns: A list of paths which have been added.
 
241
    """
233
242
 
234
243
    # Nothing to do if path is already versioned.
235
244
    # This is safe from infinite recursion because the tree root is