~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1182
1182
            if trans_id not in self._new_contents:
1183
1183
                continue
1184
1184
            new_path = self._limbo_name(trans_id)
1185
 
            osutils.rename(old_path, new_path)
 
1185
            os.rename(old_path, new_path)
1186
1186
            for descendant in self._limbo_descendants(trans_id):
1187
1187
                desc_path = self._limbo_files[descendant]
1188
1188
                desc_path = new_path + desc_path[len(old_path):]
2529
2529
        raise errors.BadFileKindError(name, kind)
2530
2530
 
2531
2531
 
2532
 
@deprecated_function(deprecated_in((1, 9, 0)))
2533
 
def create_by_entry(tt, entry, tree, trans_id, lines=None, mode_id=None):
2534
 
    """Create new file contents according to an inventory entry.
2535
 
 
2536
 
    DEPRECATED.  Use create_from_tree instead.
2537
 
    """
2538
 
    if entry.kind == "file":
2539
 
        if lines is None:
2540
 
            lines = tree.get_file(entry.file_id).readlines()
2541
 
        tt.create_file(lines, trans_id, mode_id=mode_id)
2542
 
    elif entry.kind == "symlink":
2543
 
        tt.create_symlink(tree.get_symlink_target(entry.file_id), trans_id)
2544
 
    elif entry.kind == "directory":
2545
 
        tt.create_directory(trans_id)
2546
 
 
2547
 
 
2548
2532
def create_from_tree(tt, trans_id, tree, file_id, bytes=None,
2549
2533
    filter_tree_path=None):
2550
2534
    """Create new file contents according to tree contents.
2935
2919
    def rename(self, from_, to):
2936
2920
        """Rename a file from one path to another."""
2937
2921
        try:
2938
 
            osutils.rename(from_, to)
2939
 
        except (IOError, OSError), e:
 
2922
            os.rename(from_, to)
 
2923
        except OSError, e:
2940
2924
            if e.errno in (errno.EEXIST, errno.ENOTEMPTY):
2941
2925
                raise errors.FileExists(to, str(e))
2942
2926
            # normal OSError doesn't include filenames so it's hard to see where
2958
2942
        """Reverse all renames that have been performed"""
2959
2943
        for from_, to in reversed(self.past_renames):
2960
2944
            try:
2961
 
                osutils.rename(to, from_)
2962
 
            except (OSError, IOError), e:
 
2945
                os.rename(to, from_)
 
2946
            except OSError, e:
2963
2947
                raise errors.TransformRenameFailed(to, from_, str(e), e.errno)                
2964
2948
        # after rollback, don't reuse _FileMover
2965
2949
        past_renames = None