def test_unapply_all(self): patch1 = Patch("p1.patch") patch2 = Patch("p2.patch") test_dir = self.data_dir + "test1" with TmpDirectory(dir=self.data_dir.get_name()) as tmp_dir: tmp_test_dir = tmp_dir + "test1" test_dir.copy(tmp_test_dir) pc_dir = tmp_test_dir + "pc" patches_dir = tmp_test_dir + "patches" f1 = tmp_test_dir + File("f1") self.assertTrue(f1.exists()) f2 = tmp_test_dir + File("f2") self.assertTrue(f2.exists()) pop = Pop(tmp_test_dir.get_name(), pc_dir.get_name()) self.assertEquals(patch2, pop.db.top_patch()) pop.unapply_all() self.assertEquals(None, pop.db.top_patch()) self.assertFalse(f1.exists()) self.assertFalse(f2.exists())
def _pop(force=False): pop = Pop(os.getcwd(), pc_dir) try: pop.unapply_all(force) except QuiltError, e: print t.red('KO: Error applying patch:' + str(e)) return -1
def unapply(self): """ Revert all patches""" from quilt.pop import Pop from quilt.error import NoAppliedPatch pop = Pop(self.work_dir, os.path.join(self.work_dir, ".pc")) try: pop.unapply_all() except NoAppliedPatch, e: print e
def run(self, args): pop = Pop(os.getcwd(), self.get_pc_dir()) pop.unapplying.connect(self.unapplying) pop.unapplied.connect(self.unapplied) pop.empty_patch.connect(self.empty_patch) if args.all: pop.unapply_all() elif args.patch: pop.unapply_patch(args.patch) else: pop.unapply_top_patch()
def _pop(force=False): pop = Pop(os.getcwd(), pc_dir) try: pop.unapply_all(force) except QuiltError as e: print(t.red('KO: Error applying patch:' + str(e))) return -1 except UnknownPatch as e: print(t.red('KO: Error applying patch:' + str(e))) return -1 print(t.green('OK: All Patches removed')) return 0
def run(self, options, args): pop = Pop(os.getcwd(), self.get_pc_dir()) pop.unapplying.connect(self.unapplying) pop.unapplied.connect(self.unapplied) pop.empty_patch.connect(self.empty_patch) if options.all: pop.unapply_all() elif not args: pop.unapply_top_patch() else: pop.unapply_patch(args[0])
def test_unapply_all(self): patch2 = Patch("p2.patch") test_dir = self.data_dir + "test1" with TmpDirectory(dir=self.data_dir.get_name()) as tmp_dir: tmp_test_dir = tmp_dir + "test1" test_dir.copy(tmp_test_dir) pc_dir = tmp_test_dir + "pc" f1 = tmp_test_dir + File("f1") self.assertTrue(f1.exists()) f2 = tmp_test_dir + File("f2") self.assertTrue(f2.exists()) pop = Pop(tmp_test_dir.get_name(), pc_dir.get_name()) self.assertEqual(patch2, pop.db.top_patch()) pop.unapply_all() self.assertEqual(None, pop.db.top_patch()) self.assertFalse(f1.exists()) self.assertFalse(f2.exists())