~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Aaron Bentley
  • Date: 2007-08-21 15:26:59 UTC
  • mto: This revision was merged to the branch mainline in revision 2765.
  • Revision ID: abentley@panoramicfeedback.com-20070821152659-bs4ko8872xdigr11
Update docstrings

Show diffs side-by-side

added added

removed removed

Lines of Context:
803
803
 
804
804
        :param no_conflicts: if True, the caller guarantees there are no
805
805
            conflicts, so no check is made.
 
806
        :param _mover: Supply an alternate FileMover, for testing
806
807
        """
807
808
        if not no_conflicts:
808
809
            conflicts = self.find_conflicts()
1782
1783
 
1783
1784
 
1784
1785
class _FileMover(object):
 
1786
    """Moves and deletes files for TreeTransform, tracking operations"""
1785
1787
 
1786
1788
    def __init__(self):
1787
1789
        self.past_renames = []
1788
1790
        self.pending_deletions = []
1789
1791
 
1790
1792
    def rename(self, from_, to):
 
1793
        """Rename a file from one path to another.  Functions like os.rename"""
1791
1794
        os.rename(from_, to)
1792
1795
        self.past_renames.append((from_, to))
1793
1796
 
1794
1797
    def pre_delete(self, from_, to):
 
1798
        """Rename a file out of the way and mark it for deletion.
 
1799
 
 
1800
        Unlike os.unlink, this works equally well for files and directories.
 
1801
        :param from_: The current file path
 
1802
        :param to: A temporary path for the file
 
1803
        """
1795
1804
        self.rename(from_, to)
1796
1805
        self.pending_deletions.append(to)
1797
1806
 
1798
1807
    def rollback(self):
 
1808
        """Reverse all renames that have been performed"""
1799
1809
        for from_, to in reversed(self.past_renames):
1800
1810
            os.rename(to, from_)
1801
1811
 
1802
1812
    def apply_deletions(self):
 
1813
        """Apply all marked deletions"""
1803
1814
        for path in self.pending_deletions:
1804
1815
            delete_any(path)