Merge lp:~jelmer/bzr-builddeb/contains-upstream-source into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 597
Proposed branch: lp:~jelmer/bzr-builddeb/contains-upstream-source
Merge into: lp:bzr-builddeb
Diff against target: 71 lines (+45/-1)
2 files modified
tests/test_util.py (+42/-0)
util.py (+3/-1)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/contains-upstream-source
Reviewer Review Type Date Requested Status
Andrew Bennetts (community) Approve
Bzr-builddeb-hackers Pending
Review via email: mp+69017@code.launchpad.net

Description of the change

Add some tests for tree_contains_upstream_source.

Don't consider unversioned files when determining if the tree contains the upstream source.

To post a comment you must log in.
Revision history for this message
Andrew Bennetts (spiv) wrote :

Makes sense to me. Perhaps add a changelog entry? :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_util.py'
2--- tests/test_util.py 2011-07-20 19:14:43 +0000
3+++ tests/test_util.py 2011-07-25 00:17:27 +0000
4@@ -73,6 +73,7 @@
5 strip_changelog_message,
6 suite_to_distribution,
7 tarball_name,
8+ tree_contains_upstream_source,
9 write_if_different,
10 )
11
12@@ -950,3 +951,44 @@
13 def test_invalid_character(self):
14 self.assertRaises(ValueError,
15 component_from_orig_tarball, "foo_0.1.orig;.tar.gz", "foo", "0.1")
16+
17+
18+class TreeContainsUpstreamSourceTests(TestCaseWithTransport):
19+
20+ def test_empty(self):
21+ tree = self.make_branch_and_tree('.')
22+ tree.lock_read()
23+ self.addCleanup(tree.unlock)
24+ self.assertIs(None, tree_contains_upstream_source(tree))
25+
26+ def test_debian_dir_only(self):
27+ tree = self.make_branch_and_tree('.')
28+ self.build_tree(['debian/'])
29+ tree.add(['debian'])
30+ tree.lock_read()
31+ self.addCleanup(tree.unlock)
32+ self.assertFalse(tree_contains_upstream_source(tree))
33+
34+ def test_debian_dir_and_bzr_builddeb(self):
35+ tree = self.make_branch_and_tree('.')
36+ self.build_tree(['debian/', '.bzr-builddeb/'])
37+ tree.add(['debian', '.bzr-builddeb'])
38+ tree.lock_read()
39+ self.addCleanup(tree.unlock)
40+ self.assertFalse(tree_contains_upstream_source(tree))
41+
42+ def test_with_upstream_source(self):
43+ tree = self.make_branch_and_tree('.')
44+ self.build_tree(['debian/', 'src/'])
45+ tree.add(['debian', 'src'])
46+ tree.lock_read()
47+ self.addCleanup(tree.unlock)
48+ self.assertTrue(tree_contains_upstream_source(tree))
49+
50+ def test_with_unversioned_extra_data(self):
51+ tree = self.make_branch_and_tree('.')
52+ self.build_tree(['debian/', 'x'])
53+ tree.add(['debian'])
54+ tree.lock_read()
55+ self.addCleanup(tree.unlock)
56+ self.assertFalse(tree_contains_upstream_source(tree))
57
58=== modified file 'util.py'
59--- util.py 2011-07-20 19:23:07 +0000
60+++ util.py 2011-07-25 00:17:27 +0000
61@@ -625,7 +625,9 @@
62 :return: Boolean indicating whether or not the tree contains the upstream
63 source. None if the tree is empty
64 """
65- present_files = set([f[0] for f in tree.list_files(recursive=False)])
66+ present_files = set(
67+ [f[0] for f in tree.list_files(recursive=False)
68+ if f[1] == 'V'])
69 if len(present_files) == 0:
70 return None
71 packaging_files = frozenset(["debian", ".bzr-builddeb", ".bzrignore"])

Subscribers

People subscribed via source and target branches