예제 #1
0
 def test_unreverted(self):
     """ Test when the patch modifies unreverted files """
     with tmp_series() as [dir, series]:
         old_dir = os.getcwd()
         try:
             os.chdir(dir)
             db = Db(dir)
             db.add_patch(Patch("patch"))
             db.save()
             originals = os.path.join(db.dirname, "patch")
             os.mkdir(originals)
             make_file(b"unreverted original\n", originals, "unreverted")
             make_file(b"reverted original\n", originals, "reverted")
             make_file(b"unreverted patched\n", dir, "unreverted")
             make_file(b"reverted patched\n", dir, "reverted")
             Refresh(dir, db.dirname, series.dirname).refresh()
             make_file(b"unreverted change\n", dir, "unreverted")
             make_file(b"reverted change\n", dir, "reverted")
             cmd = quilt.revert.Revert(dir, db.dirname, series.dirname)
             cmd.revert_file("reverted")
             with open(os.path.join(dir, "reverted"), "rb") as file:
                 self.assertEqual(file.read(), b"reverted patched\n")
             with open(os.path.join(dir, "unreverted"), "rb") as file:
                 self.assertEqual(file.read(), b"unreverted change\n")
         finally:
             os.chdir(old_dir)
예제 #2
0
 def test_bad_args(self):
     with tmp_series() as [dir, series]:
         make_file(b"patch -X\n", series.series_file)
         with tmp_mapping(vars(sys)) as tmp_sys:
             tmp_sys.set("stderr", cStringIO())
             series.read()
             self.assertIn("-X", sys.stderr.getvalue())
예제 #3
0
 def test_bad_args(self):
     with tmp_series() as [dir, series]:
         make_file(b"patch -X\n", series.series_file)
         with tmp_mapping(vars(sys)) as tmp_sys:
             tmp_sys.set("stderr", cStringIO())
             series.read()
             self.assertIn("-X", sys.stderr.getvalue())
예제 #4
0
 def test_unreverted(self):
     """ Test when the patch modifies unreverted files """
     with tmp_series() as [dir, series]:
         old_dir = os.getcwd()
         try:
             os.chdir(dir)
             db = Db(dir)
             db.add_patch(Patch("patch"))
             db.save()
             originals = os.path.join(db.dirname, "patch")
             os.mkdir(originals)
             make_file(b"unreverted original\n", originals, "unreverted")
             make_file(b"reverted original\n", originals, "reverted")
             make_file(b"unreverted patched\n", dir, "unreverted")
             make_file(b"reverted patched\n", dir, "reverted")
             Refresh(dir, db.dirname, series.dirname).refresh()
             make_file(b"unreverted change\n", dir, "unreverted")
             make_file(b"reverted change\n", dir, "reverted")
             cmd = quilt.revert.Revert(dir, db.dirname, series.dirname)
             cmd.revert_file("reverted")
             with open(os.path.join(dir, "reverted"), "rb") as file:
                 self.assertEqual(file.read(), b"reverted patched\n")
             with open(os.path.join(dir, "unreverted"), "rb") as file:
                 self.assertEqual(file.read(), b"unreverted change\n")
         finally:
             os.chdir(old_dir)
예제 #5
0
 def test_next_first(self):
     """ Delete the next patch with only unapplied patches """
     with tmp_series() as [dir, patches]:
         patches.add_patch(Patch("patch"))
         patches.save()
         cmd = Delete(dir, quilt_pc=dir, quilt_patches=patches.dirname)
         cmd.delete_next()
         patches.read()
         self.assertTrue(patches.is_empty())
예제 #6
0
 def test_patch_args(self):
     with tmp_series() as [dir, series]:
         make_file(b"patch1 -p0 --reverse\n"
                   b"patch2 --strip=0 -R\n", series.series_file)
         series.read()
         [patch1, patch2] = series.patches()
         self.assertEqual(patch1.strip, "0")
         self.assertIs(patch1.reverse, True)
         self.assertEqual(patch2.strip, "0")
         self.assertIs(patch2.reverse, True)
예제 #7
0
 def test_patch_args(self):
     with tmp_series() as [dir, series]:
         make_file(
             b"patch1 -p0 --reverse\n"
             b"patch2 --strip=0 -R\n", series.series_file)
         series.read()
         [patch1, patch2] = series.patches()
         self.assertEqual(patch1.strip, "0")
         self.assertIs(patch1.reverse, True)
         self.assertEqual(patch2.strip, "0")
         self.assertIs(patch2.reverse, True)
예제 #8
0
 def test_force(self):
     with tmp_series() as [dir, series]:
         self._make_conflict(dir, series)
         series.save()
         cmd = Push(dir, quilt_pc=dir, quilt_patches=series.dirname)
         with six.assertRaisesRegex(
                     self, QuiltError, r"does not apply"), \
                 self._suppress_output():
             cmd.apply_next_patch(quiet=True)
         with six.assertRaisesRegex(self, QuiltError,
                     r"Applied patch.*needs refresh"), \
                 self._suppress_output():
             cmd.apply_next_patch(quiet=True, force=True)
예제 #9
0
 def test_no_backup_named(self):
     """ Remove a specified patch without leaving a backup """
     with tmp_series() as [dir, patches]:
         patches.add_patch(Patch("patch"))
         patches.save()
         patch = os.path.join(patches.dirname, "patch")
         make_file(b"", patch)
         run_cli(DeleteCommand,
                 dict(patch="patch", next=False, remove=True, backup=False),
                 patches.dirname,
                 applied=dir)
         self.assertFalse(os.path.exists(patch))
         self.assertFalse(os.path.exists(patch + "~"))
예제 #10
0
 def test_next_after(self):
     """ Delete the successor to the topmost patch """
     with tmp_series() as [dir, series]:
         series.add_patch(Patch("topmost"))
         series.add_patch(Patch("unapplied"))
         series.save()
         db = Db(dir)
         db.add_patch(Patch("topmost"))
         db.save()
         cmd = Delete(dir, db.dirname, series.dirname)
         cmd.delete_next()
         series.read()
         [patch] = series.patches()
         self.assertEqual(patch, Patch("topmost"))
예제 #11
0
 def test_series_v(self):
     with tmp_series() as [dir, series]:
         applied = Db(dir)
         applied.add_patch(Patch("applied.patch"))
         applied.add_patch(Patch("topmost.patch"))
         applied.save()
         series.add_patches(applied.applied_patches())
         series.add_patch(Patch("unapplied.patch"))
         series.save()
         output = run_cli(SeriesCommand, dict(v=True),
             series.dirname, applied.dirname)
     self.assertMultiLineEqual(output,
         "+ applied.patch\n"
         "= topmost.patch\n"
         "  unapplied.patch\n")
예제 #12
0
 def test_fail_after_success(self):
     """ Test where the first patch applies but a later patch fails """
     with tmp_series() as [dir, series]:
         make_file(
             b"--- /dev/null\n"
             b"+++ dir/new-file\n"
             b"@@ -0,0 +1,1 @@\n"
             b"+new file\n", series.dirname, "good.patch")
         series.add_patch(Patch("good.patch"))
         
         self._make_conflict(dir, series)
         series.save()
         cmd = Push(dir, quilt_pc=dir, quilt_patches=series.dirname)
         with six.assertRaisesRegex(self, QuiltError,
                     r"conflict\.patch does not apply"), \
                 self._suppress_output():
             cmd.apply_all()
         [applied] = Db(dir).patches()
         self.assertEqual(applied.get_name(), "good.patch")
         with open(os.path.join(dir, "new-file"), "rb") as file:
             self.assertEqual(file.read(), b"new file\n")
         with open(os.path.join(dir, "file"), "rb") as file:
             self.assertEqual(file.read(), b"conflict\n")
예제 #13
0
 def test_save(self):
     with tmp_series() as [dir, series]:
         series.add_patch(Patch("test.patch"))
         series.save()
         with open(series.series_file, "rb") as file:
             self.assertEqual(file.read(), b"test.patch\n")
예제 #14
0
 def test_save(self):
     with tmp_series() as [dir, series]:
         series.add_patch(Patch("test.patch"))
         series.save()
         with open(series.series_file, "rb") as file:
             self.assertEqual(file.read(), b"test.patch\n")