~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/rename_map.py

  • Committer: John Arbash Meinel
  • Date: 2009-03-27 22:29:55 UTC
  • mto: (3735.39.2 clean)
  • mto: This revision was merged to the branch mainline in revision 4280.
  • Revision ID: john@arbash-meinel.com-20090327222955-utifmfm888zerixt
Implement apply_delta_to_source which doesn't have to malloc another string.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from bzrlib import (
21
21
    osutils,
22
22
    progress,
23
 
    trace,
24
23
)
25
24
from bzrlib.ui import ui_factory
26
25
 
203
202
        return missing_files, missing_parents, candidate_files
204
203
 
205
204
    @classmethod
206
 
    def guess_renames(klass, tree, dry_run=False):
 
205
    def guess_renames(klass, tree):
207
206
        """Guess which files to rename, and perform the rename.
208
207
 
209
208
        We assume that unversioned files and missing files indicate that
236
235
                                                   missing_parents)
237
236
                matches.update(parents_matches)
238
237
            pp.next_phase()
239
 
            delta = rn._make_inventory_delta(matches)
240
 
            for old, new, file_id, entry in delta:
241
 
                trace.note("%s => %s", old, new)
242
 
            if not dry_run:
243
 
                tree.add(required_parents)
244
 
                tree.apply_inventory_delta(delta)
 
238
            rn._update_tree(required_parents, matches)
245
239
        finally:
246
240
            task.finished()
247
241
 
248
 
    def _make_inventory_delta(self, matches):
 
242
    def _update_tree(self, required_parents, matches):
 
243
        self.tree.add(required_parents)
249
244
        delta = []
250
245
        file_id_matches = dict((f, p) for p, f in matches.items())
251
246
        for old_path, entry in self.tree.iter_entries_by_dir(matches.values()):
254
249
            parent_id = matches.get(parent_path)
255
250
            if parent_id is None:
256
251
                parent_id = self.tree.path2id(parent_path)
257
 
            if entry.name == new_name and entry.parent_id == parent_id:
258
 
                continue
259
252
            new_entry = entry.copy()
260
253
            new_entry.parent_id = parent_id
261
254
            new_entry.name = new_name
262
255
            delta.append((old_path, new_path, new_entry.file_id, new_entry))
263
 
        return delta
 
256
        self.tree.apply_inventory_delta(delta)