~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Martin Pool
  • Date: 2010-08-13 07:56:06 UTC
  • mfrom: (5050.17.4 2.2)
  • mto: (5050.17.6 2.2)
  • mto: This revision was merged to the branch mainline in revision 5379.
  • Revision ID: mbp@sourcefrog.net-20100813075606-8zgmov3ezwans2zo
merge bzr 2.2

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):]
2291
2291
    for num, _unused in enumerate(wt.all_file_ids()):
2292
2292
        if num > 0:  # more than just a root
2293
2293
            raise errors.WorkingTreeAlreadyPopulated(base=wt.basedir)
2294
 
    existing_files = set()
2295
 
    for dir, files in wt.walkdirs():
2296
 
        existing_files.update(f[0] for f in files)
2297
2294
    file_trans_id = {}
2298
2295
    top_pb = bzrlib.ui.ui_factory.nested_progress_bar()
2299
2296
    pp = ProgressPhase("Build phase", 2, top_pb)
2323
2320
                precomputed_delta = []
2324
2321
            else:
2325
2322
                precomputed_delta = None
 
2323
            # Check if tree inventory has content. If so, we populate
 
2324
            # existing_files with the directory content. If there are no
 
2325
            # entries we skip populating existing_files as its not used.
 
2326
            # This improves performance and unncessary work on large
 
2327
            # directory trees. (#501307)
 
2328
            if total > 0:
 
2329
                existing_files = set()
 
2330
                for dir, files in wt.walkdirs():
 
2331
                    existing_files.update(f[0] for f in files)
2326
2332
            for num, (tree_path, entry) in \
2327
2333
                enumerate(tree.inventory.iter_entries_by_dir()):
2328
2334
                pb.update("Building tree", num - len(deferred_contents), total)
2929
2935
    def rename(self, from_, to):
2930
2936
        """Rename a file from one path to another."""
2931
2937
        try:
2932
 
            osutils.rename(from_, to)
2933
 
        except (IOError, OSError), e:
 
2938
            os.rename(from_, to)
 
2939
        except OSError, e:
2934
2940
            if e.errno in (errno.EEXIST, errno.ENOTEMPTY):
2935
2941
                raise errors.FileExists(to, str(e))
2936
2942
            # normal OSError doesn't include filenames so it's hard to see where
2952
2958
        """Reverse all renames that have been performed"""
2953
2959
        for from_, to in reversed(self.past_renames):
2954
2960
            try:
2955
 
                osutils.rename(to, from_)
2956
 
            except (OSError, IOError), e:
 
2961
                os.rename(to, from_)
 
2962
            except OSError, e:
2957
2963
                raise errors.TransformRenameFailed(to, from_, str(e), e.errno)                
2958
2964
        # after rollback, don't reuse _FileMover
2959
2965
        past_renames = None