Merge lp:~jelmer/bzr-builddeb/get-orig-source-options into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Approved by: James Westby
Approved revision: 651
Merged at revision: 652
Proposed branch: lp:~jelmer/bzr-builddeb/get-orig-source-options
Merge into: lp:bzr-builddeb
Diff against target: 97 lines (+38/-12)
2 files modified
cmds.py (+13/-3)
tests/blackbox/test_get_tar.py (+25/-9)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/get-orig-source-options
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+83975@code.launchpad.net

Description of the change

Support -d argument to get-orig-source, and add an optional version argument.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmds.py'
2--- cmds.py 2011-11-26 15:01:25 +0000
3+++ cmds.py 2011-11-30 16:45:28 +0000
4@@ -466,8 +466,15 @@
5 class cmd_get_orig_source(Command):
6 """Gets the upstream tar file for the packaging branch."""
7
8- def run(self):
9- tree = WorkingTree.open_containing('.')[0]
10+ directory_opt = Option('directory',
11+ help='Directory from which to retrieve the packaging data',
12+ short_name='d', type=unicode)
13+
14+ takes_options = [directory_opt]
15+ takes_args = ["version?"]
16+
17+ def run(self, directory='.', version=None):
18+ tree = WorkingTree.open_containing(directory)[0]
19 config = debuild_config(tree, tree)
20
21 (changelog, larstiq) = find_changelog(tree, True)
22@@ -475,8 +482,11 @@
23 if orig_dir is None:
24 orig_dir = default_orig_dir
25
26+ if version is None:
27+ version = changelog.version.upstream_version
28+
29 upstream_provider = UpstreamProvider(changelog.package,
30- changelog.version.upstream_version, orig_dir,
31+ str(version), orig_dir,
32 [PristineTarSource(tree, tree.branch),
33 AptSource(),
34 GetOrigSourceSource(tree, larstiq),
35
36=== modified file 'tests/blackbox/test_get_tar.py'
37--- tests/blackbox/test_get_tar.py 2011-10-03 10:49:13 +0000
38+++ tests/blackbox/test_get_tar.py 2011-11-30 16:45:28 +0000
39@@ -19,7 +19,6 @@
40 #
41
42 import os
43-import tarfile
44
45 try:
46 from debian.changelog import (Changelog,
47@@ -67,21 +66,19 @@
48 tree.add(source_files)
49 return tree
50
51- def make_source_with_upstream(self):
52+ def make_source_with_upstream(self, path="."):
53 """Create a source tree in a branch with an upstream tag."""
54- tree = self.make_branch_and_tree('.')
55+ tree = self.make_branch_and_tree(path)
56 source_files = ['README']
57- self.build_tree(source_files)
58+ self.build_tree([os.path.join(path, f) for f in source_files])
59 tree.add(source_files)
60 tree.commit("one", rev_id='revid1')
61 tree.branch.tags.set_tag("upstream-0.1", tree.branch.last_revision())
62
63- cl_file = 'debian/changelog'
64- source_files = ['debian/'] + [cl_file]
65- self.build_tree(source_files)
66+ os.mkdir(os.path.join(path, 'debian'))
67 c = self.make_changelog()
68- self.write_changelog(c, cl_file)
69- tree.add(source_files)
70+ self.write_changelog(c, os.path.join(path, 'debian/changelog'))
71+ tree.add(['debian', 'debian/changelog'])
72 tree.commit("two", rev_id='revid2')
73 return tree
74
75@@ -104,3 +101,22 @@
76 tree = self.make_source_with_upstream()
77 self.run_bzr(['get-orig-source'])
78 self.assertPathExists('../test_0.1.orig.tar.gz')
79+
80+ def test_get_orig_source_directory(self):
81+ tree = self.make_source_with_upstream("somedir")
82+ self.run_bzr(['get-orig-source', '-d', 'somedir'])
83+ self.assertPathExists('../test_0.1.orig.tar.gz')
84+
85+ def test_get_orig_source_explicit_version(self):
86+ tree = self.make_source_with_upstream()
87+ c = self.make_changelog("0.3-1")
88+ self.write_changelog(c, 'debian/changelog')
89+ tree.commit("package 0.3")
90+ self.run_bzr(['get-orig-source', '0.1'])
91+ self.assertPathExists('../test_0.1.orig.tar.gz')
92+
93+ def test_get_orig_source_explicit_version_not_found(self):
94+ tree = self.make_source_with_upstream()
95+ self.run_bzr_error([
96+ 'bzr: ERROR: Unable to find the needed upstream tarball for package test, version 0.3.'],
97+ 'get-orig-source 0.3')

Subscribers

People subscribed via source and target branches