~bzr-builddeb-hackers/bzr-builddeb/trunk

« back to all changes in this revision

Viewing changes to tests/test_merge_quilt.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-04 23:28:23 UTC
  • mfrom: (678.1.3 quilt)
  • Revision ID: jelmer@samba.org-20120104232823-jwtn925z8awhsn9n
Merge support for running quilt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#
19
19
 
20
20
"""Tests for the merge_quilt code."""
 
21
 
 
22
import shutil
 
23
 
 
24
from bzrlib.plugins.builddeb.quilt import quilt_push_all
 
25
from bzrlib.plugins.builddeb.merge_quilt import tree_unapply_patches
 
26
 
 
27
from bzrlib.tests import TestCaseWithTransport
 
28
 
 
29
TRIVIAL_PATCH = """--- /dev/null        2012-01-02 01:09:10.986490031 +0100
 
30
+++ base/a      2012-01-02 20:03:59.710666215 +0100
 
31
@@ -0,0 +1 @@
 
32
+a
 
33
"""
 
34
 
 
35
class TestTreeUnapplyPatches(TestCaseWithTransport):
 
36
 
 
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)
 
42
 
 
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"))