~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Robert Collins
  • Date: 2010-06-25 06:23:08 UTC
  • mto: This revision was merged to the branch mainline in revision 5324.
  • Revision ID: robertc@robertcollins.net-20100625062308-qx287gzfrehs1d21
Restore the original ui_factory when existing BzrLibraryState.

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
 
            os.rename(old_path, new_path)
 
1185
            osutils.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
 
2532
2548
def create_from_tree(tt, trans_id, tree, file_id, bytes=None,
2533
2549
    filter_tree_path=None):
2534
2550
    """Create new file contents according to tree contents.
2919
2935
    def rename(self, from_, to):
2920
2936
        """Rename a file from one path to another."""
2921
2937
        try:
2922
 
            os.rename(from_, to)
2923
 
        except OSError, e:
 
2938
            osutils.rename(from_, to)
 
2939
        except (IOError, OSError), e:
2924
2940
            if e.errno in (errno.EEXIST, errno.ENOTEMPTY):
2925
2941
                raise errors.FileExists(to, str(e))
2926
2942
            # normal OSError doesn't include filenames so it's hard to see where
2942
2958
        """Reverse all renames that have been performed"""
2943
2959
        for from_, to in reversed(self.past_renames):
2944
2960
            try:
2945
 
                os.rename(to, from_)
2946
 
            except OSError, e:
 
2961
                osutils.rename(to, from_)
 
2962
            except (OSError, IOError), e:
2947
2963
                raise errors.TransformRenameFailed(to, from_, str(e), e.errno)                
2948
2964
        # after rollback, don't reuse _FileMover
2949
2965
        past_renames = None