def backup_dir(self, src_dir, dest_dir, copy_empty=False): for file_name in src_dir.files(): file = File(file_name) file_dir = file.get_directory() if file_dir: dest = dest_dir + file_dir else: dest = dest_dir self.backup_file(file, dest, copy_empty)
def backup_dir(self, src_dir, dest_dir, copy_empty=False): for file_name in src.files(): file = File(file_name) file_dir = file.get_directory() if file_dir: dest = dest_dir + file_dir else: dest = dest_dir self.backup_file(file, dest, copy_empty)
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)