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

  • Committer: Aaron Bentley
  • Date: 2009-03-23 21:01:42 UTC
  • mto: This revision was merged to the branch mainline in revision 4196.
  • Revision ID: aaron@aaronbentley.com-20090323210142-fe3pdusp7u8twipr
Use apply_inventory_delta to rename files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
241
241
 
242
242
    def _update_tree(self, required_parents, matches):
243
243
        self.tree.add(required_parents)
244
 
        reversed = dict((v, k) for k, v in matches.iteritems())
245
 
        child_to_parent = sorted(
246
 
            matches.values(), key=lambda x: reversed[x], reverse=True)
247
 
        self.tree.unversion(child_to_parent)
248
 
        paths_forward = sorted(matches.keys())
249
 
        file_ids_forward = [matches[p] for p in paths_forward]
250
 
        self.tree.add(paths_forward, file_ids_forward)
 
244
        delta = []
 
245
        file_id_matches = dict((f, p) for p, f in matches.items())
 
246
        for old_path, entry in self.tree.iter_entries_by_dir(matches.values()):
 
247
            new_path = file_id_matches[entry.file_id]
 
248
            parent_path = osutils.dirname(new_path)
 
249
            parent_id = matches.get(parent_path)
 
250
            if parent_id is None:
 
251
                parent_id = self.tree.path2id(parent_path)
 
252
            new_entry = entry.copy()
 
253
            new_entry.parent_id = parent_id
 
254
            new_entry.name = osutils.basename(new_path)
 
255
            delta.append((old_path, new_path, new_entry.file_id, new_entry))
 
256
        self.tree.apply_inventory_delta(delta)