20
20
"""Tests for the merge_quilt code."""
24
from bzrlib.plugins.builddeb.quilt import quilt_push_all
25
from bzrlib.plugins.builddeb.merge_quilt import tree_unapply_patches
27
from bzrlib.tests import TestCaseWithTransport
29
TRIVIAL_PATCH = """--- /dev/null 2012-01-02 01:09:10.986490031 +0100
30
+++ base/a 2012-01-02 20:03:59.710666215 +0100
35
class TestTreeUnapplyPatches(TestCaseWithTransport):
37
def test_no_patches(self):
38
tree = self.make_branch_and_tree('.')
39
new_tree, target_dir = tree_unapply_patches(tree)
40
self.assertIs(tree, new_tree)
41
self.assertIs(None, target_dir)
43
def test_unapply(self):
44
orig_tree = self.make_branch_and_tree('source')
45
self.build_tree(["source/debian/", "source/debian/patches/"])
46
self.build_tree_contents([
47
("source/debian/patches/series", "patch1.diff\n"),
48
("source/debian/patches/patch1.diff", TRIVIAL_PATCH)])
49
quilt_push_all(orig_tree.basedir)
50
orig_tree.smart_add([orig_tree.basedir])
51
tree, target_dir = tree_unapply_patches(orig_tree)
52
self.addCleanup(shutil.rmtree, target_dir)
53
self.assertPathExists("source/a")
54
self.assertNotEqual(tree.basedir, orig_tree.basedir)
55
self.assertPathDoesNotExist(tree.abspath("a"))
56
self.assertPathExists(tree.abspath("debian/patches/series"))