quilt/revert.py
def revert_file(self, filename, patch_name=None):
        """ Revert not added changes of filename.
        If patch_name is None or empty the topmost patch will be used.
        """
        file = File(filename)

        if patch_name:
            patch = Patch(patch_name)
        else:
            patch = self.db.top_patch()

            if not patch:
                raise QuiltError("No patch available. Nothing to revert.")

        self._file_in_patch(filename, patch)
        self._file_in_next_patches(filename, patch)
        pc_dir = self.quilt_pc + patch.get_name()
        pc_file = pc_dir + file

        if not file.exists() and pc_file.is_empty():
            # new and empty file will be reverted
            pc_file.delete()
            self.file_reverted(file, patch)
            return

        with TmpDirectory(prefix="pquilt-") as tmpdir:
            # apply current patch in temporary directory to revert changes of
            # file that aren't committed in the patch
            tmp_file = self._apply_patch_temporary(tmpdir, pc_file, patch)
            if tmp_file and tmp_file.exists() and not tmp_file.is_empty():

                diff = Diff(file, tmp_file)
                if diff.equal(self.cwd):
                    self.file_unchanged(file, patch)
                    return

                dir = file.get_directory()
                if not dir:
                    dir = Directory(os.getcwd())
                else:
                    dir.create()
                tmp_file.copy(dir)
                self.file_reverted(file, patch)
            else:
                self.file_unchanged(file, patch)
def revert_file(self, filename, patch_name=None):
        file = File(filename)

        if patch_name:
            patch = Patch(patch_name)
        else:
            patch = self.db.top_patch()

            if not patch:
                raise QuiltError("No patch available. Nothing to revert.")

        self._file_in_patch(filename, patch)
        self._file_in_next_patches(filename, patch)
        pc_dir = self.quilt_pc + patch.get_name()
        pc_file = pc_dir + file

        if not file.exists() and pc_file.is_empty():
            # new and empty file will be reverted
            pc_file.delete()
            self.file_reverted(file, patch)
            return

        with TmpDirectory(prefix="pquilt-") as tmpdir:
            # apply current patch in temporary directory to revert changes of
            # file that aren't committed in the patch
            tmp_file = self._apply_patch_temporary(tmpdir, pc_file, patch)
            if tmp_file and tmp_file.exists() and not tmp_file.is_empty():

                diff = Diff(file, tmp_file)
                if diff.equal(self.cwd):
                    self.file_unchanged(file, patch)
                    return

                dir = file.get_directory()
                if not dir:
                    dir = Directory(os.getcwd())
                else:
                    dir.create()
                tmp_file.copy(dir)
                self.file_reverted(file, patch)
            else:
                self.file_unchanged(file, patch)
def revert_file ( self , filename , patch_name = None ) : file = File ( filename ) if patch_name : patch = Patch ( patch_name ) else : patch = self . db . top_patch ( ) if not patch : raise QuiltError ( "No patch available. Nothing to revert." ) self . _file_in_patch ( filename , patch ) self . _file_in_next_patches ( filename , patch ) pc_dir = self . quilt_pc + patch . get_name ( ) pc_file = pc_dir + file if not file . exists ( ) and pc_file . is_empty ( ) : # new and empty file will be reverted pc_file . delete ( ) self . file_reverted ( file , patch ) return with TmpDirectory ( prefix = "pquilt-" ) as tmpdir : # apply current patch in temporary directory to revert changes of # file that aren't committed in the patch tmp_file = self . _apply_patch_temporary ( tmpdir , pc_file , patch ) if tmp_file and tmp_file . exists ( ) and not tmp_file . is_empty ( ) : diff = Diff ( file , tmp_file ) if diff . equal ( self . cwd ) : self . file_unchanged ( file , patch ) return dir = file . get_directory ( ) if not dir : dir = Directory ( os . getcwd ( ) ) else : dir . create ( ) tmp_file . copy ( dir ) self . file_reverted ( file , patch ) else : self . file_unchanged ( file , patch )
Revert not added changes of filename.
        If patch_name is None or empty the topmost patch will be used.
Revert not added changes of filename . If patch_name is None or empty the topmost patch will be used .