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
=== modified file 'tests/test_util.py'
--- tests/test_util.py 2011-07-20 19:14:43 +0000
+++ tests/test_util.py 2011-07-25 00:17:27 +0000
@@ -73,6 +73,7 @@
73 strip_changelog_message,73 strip_changelog_message,
74 suite_to_distribution,74 suite_to_distribution,
75 tarball_name,75 tarball_name,
76 tree_contains_upstream_source,
76 write_if_different,77 write_if_different,
77 )78 )
7879
@@ -950,3 +951,44 @@
950 def test_invalid_character(self):951 def test_invalid_character(self):
951 self.assertRaises(ValueError,952 self.assertRaises(ValueError,
952 component_from_orig_tarball, "foo_0.1.orig;.tar.gz", "foo", "0.1")953 component_from_orig_tarball, "foo_0.1.orig;.tar.gz", "foo", "0.1")
954
955
956class TreeContainsUpstreamSourceTests(TestCaseWithTransport):
957
958 def test_empty(self):
959 tree = self.make_branch_and_tree('.')
960 tree.lock_read()
961 self.addCleanup(tree.unlock)
962 self.assertIs(None, tree_contains_upstream_source(tree))
963
964 def test_debian_dir_only(self):
965 tree = self.make_branch_and_tree('.')
966 self.build_tree(['debian/'])
967 tree.add(['debian'])
968 tree.lock_read()
969 self.addCleanup(tree.unlock)
970 self.assertFalse(tree_contains_upstream_source(tree))
971
972 def test_debian_dir_and_bzr_builddeb(self):
973 tree = self.make_branch_and_tree('.')
974 self.build_tree(['debian/', '.bzr-builddeb/'])
975 tree.add(['debian', '.bzr-builddeb'])
976 tree.lock_read()
977 self.addCleanup(tree.unlock)
978 self.assertFalse(tree_contains_upstream_source(tree))
979
980 def test_with_upstream_source(self):
981 tree = self.make_branch_and_tree('.')
982 self.build_tree(['debian/', 'src/'])
983 tree.add(['debian', 'src'])
984 tree.lock_read()
985 self.addCleanup(tree.unlock)
986 self.assertTrue(tree_contains_upstream_source(tree))
987
988 def test_with_unversioned_extra_data(self):
989 tree = self.make_branch_and_tree('.')
990 self.build_tree(['debian/', 'x'])
991 tree.add(['debian'])
992 tree.lock_read()
993 self.addCleanup(tree.unlock)
994 self.assertFalse(tree_contains_upstream_source(tree))
953995
=== modified file 'util.py'
--- util.py 2011-07-20 19:23:07 +0000
+++ util.py 2011-07-25 00:17:27 +0000
@@ -625,7 +625,9 @@
625 :return: Boolean indicating whether or not the tree contains the upstream625 :return: Boolean indicating whether or not the tree contains the upstream
626 source. None if the tree is empty626 source. None if the tree is empty
627 """627 """
628 present_files = set([f[0] for f in tree.list_files(recursive=False)])628 present_files = set(
629 [f[0] for f in tree.list_files(recursive=False)
630 if f[1] == 'V'])
629 if len(present_files) == 0:631 if len(present_files) == 0:
630 return None632 return None
631 packaging_files = frozenset(["debian", ".bzr-builddeb", ".bzrignore"])633 packaging_files = frozenset(["debian", ".bzr-builddeb", ".bzrignore"])

Subscribers

People subscribed via source and target branches