def run(self, args): series = Series(self.get_patches_dir()) if not series.exists(): self.exit_error("No series file found.") db = Db(self.get_pc_dir()) top = None if args.patch: patch_name = args.patch top = Patch(patch_name) else: if db.exists(): top = db.top_patch() if not top: top = series.first_patch() if not top: self.exit_error("No patch in series.") else: print(top) else: patch = series.patch_after(top) if not patch: self.exit_error("No patch available after %s." % top) else: print(patch)
def run(self, args): series = Series(self.get_patches_dir()) db = Db(self.get_pc_dir()) top = None if args.patch: top = Patch(args.patch) else: if db.exists(): top = db.top_patch() if not top: self.exit_error("No patches applied.") else: patch = series.patch_before(top) if not patch: self.exit_error("No patch available before %s." % top) else: print(patch)
def run(self, options, args): series = Series(self.get_patches_dir()) db = Db(self.get_pc_dir()) top = None if len(args) > 0: top = Patch(args[0]) else: if db.exists(): top = db.top_patch() if not top: top = series.first_patch() if not top: self.exit_error("No patch in series.") else: print top else: patch = series.patch_before(top) if not patch: self.exit_error("No patch available after %s." % patch) else: print patch
class Pop(Command): unapplying = Signal() unapplied = Signal() unapplied_patch = Signal() empty_patch = Signal() def __init__(self, cwd, quilt_pc): super(Pop, self).__init__(cwd) self.quilt_pc = Directory(quilt_pc) self.db = Db(quilt_pc) def _check(self, force=False): if not self.db.exists() or not self.db.patches(): raise NoAppliedPatch(self.db) if not force: patch = self.db.top_patch() pc_dir = self.quilt_pc + patch.get_name() refresh = File(pc_dir.get_name() + "~refresh") if refresh.exists(): raise QuiltError("Patch %s needs to be refreshed first." % patch.get_name()) def _unapply_patch(self, patch): self.unapplying(patch) patch_name = patch.get_name() pc_dir = self.quilt_pc + patch_name timestamp = pc_dir + File(".timestamp") timestamp.delete_if_exists() if pc_dir.is_empty(): pc_dir.delete() self.empty_patch(patch) else: unpatch = RollbackPatch(self.cwd, pc_dir) unpatch.rollback() unpatch.delete_backup() self.db.remove_patch(patch) refresh = File(pc_dir.get_name() + "~refresh") refresh.delete_if_exists() self.unapplied_patch(patch) def unapply_patch(self, patch_name, force=False): """ Unapply patches up to patch_name. patch_name will end up as top patch """ self._check(force) patches = self.db.patches_after(Patch(patch_name)) for patch in reversed(patches): self._unapply_patch(patch) self.db.save() self.unapplied(self.db.top_patch()) def unapply_top_patch(self, force=False): """ Unapply top patch """ self._check(force) patch = self.db.top_patch() self._unapply_patch(patch) self.db.save() self.unapplied(self.db.top_patch()) def unapply_all(self, force=False): """ Unapply all patches """ self._check(force) for patch in reversed(self.db.applied_patches()): self._unapply_patch(patch) self.db.save() self.unapplied(self.db.top_patch())