def test_apply_next(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 + "test2" 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_top_patch() self.assertEquals(patch1, pop.db.top_patch()) self.assertTrue(f1.exists()) self.assertFalse(f2.exists()) pop.unapply_top_patch() self.assertEquals(None, pop.db.top_patch()) self.assertFalse(f1.exists()) self.assertFalse(f2.exists())
def test_apply_next(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 + "test2" 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_top_patch() self.assertEqual(patch1, pop.db.top_patch()) self.assertTrue(f1.exists()) self.assertFalse(f2.exists()) pop.unapply_top_patch() self.assertEqual(None, pop.db.top_patch()) self.assertFalse(f1.exists()) self.assertFalse(f2.exists())
def pop(self): """ Revert last patch """ 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_top_patch() except NoAppliedPatch, e: print e
def test_unrefreshed(self): with TmpDirectory() as dir: db = Db(dir.get_name()) db.add_patch(Patch("unrefreshed.patch")) db.save() make_file(b"", db.dirname, "unrefreshed.patch~refresh") cmd = Pop(dir.get_name(), db.dirname) with six.assertRaisesRegex(self, QuiltError, r"needs to be refreshed"): cmd.unapply_top_patch()
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 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])