Merge lp:~jelmer/bzr-builddeb/multiple-upstream-tarballs-pt4 into lp:bzr-builddeb
- multiple-upstream-tarballs-pt4
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | James Westby |
Approved revision: | 595 |
Merged at revision: | 576 |
Proposed branch: | lp:~jelmer/bzr-builddeb/multiple-upstream-tarballs-pt4 |
Merge into: | lp:bzr-builddeb |
Diff against target: |
905 lines (+255/-142) 12 files modified
__init__.py (+0/-1) cmds.py (+16/-7) dh_make.py (+4/-3) import_dsc.py (+42/-63) source_distiller.py (+5/-5) tests/blackbox/test_merge_upstream.py (+3/-1) tests/test_import_dsc.py (+41/-39) tests/test_upstream.py (+5/-1) tests/test_util.py (+38/-9) upstream/__init__.py (+5/-2) upstream/pristinetar.py (+47/-1) util.py (+49/-10) |
To merge this branch: | bzr merge lp:~jelmer/bzr-builddeb/multiple-upstream-tarballs-pt4 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby | Approve | ||
Review via email:
|
Commit message
Description of the change
Part 4 on the way to support multiple upstream tarballs.
* Move the main code for importing a single upstream tarballs to PristineTarSource.
* Make various methods that call import_
Next is actually supporting non-base tarball imports in PristineTarSour
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jelmer Vernooij (jelmer) wrote : | # |
On 06/24/2011 02:17 AM, James Westby wrote:
> Review: Approve
> Hi,
>
> This looks fine.
Appreciated, as always :)
>
> What's your plan for representing the multiple upstream tarballs in
> the tree and revision history?
Basically importing each upstream component tarball as a separate
revision with its own history and tagging them appropriately:
* "upstream-1.0" for bar_1.0.
* "upstream-1.0/bla" for bar_1.0.
... and then having the package branch take these revisions as parents,
making the components look like by-value nested trees. If an upstream
component tarball hasn't changed between upstream releases we just retag
it.
Does that sounds reasonable?
I'm also wondering if we should add a "deb-components" revision property
so that we don't accidentally forget to export component tarballs if the
appropriate tags are missing. What do you think?
Cheers,
Jelmer
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
James Westby (james-w) wrote : | # |
On Fri, 24 Jun 2011 02:39:45 +0200, Jelmer Vernooij <email address hidden> wrote:
> Basically importing each upstream component tarball as a separate
> revision with its own history and tagging them appropriately:
>
> * "upstream-1.0" for bar_1.0.
> * "upstream-1.0/bla" for bar_1.0.
>
> ... and then having the package branch take these revisions as parents,
> making the components look like by-value nested trees. If an upstream
> component tarball hasn't changed between upstream releases we just retag
> it.
That sounds pretty good to me.
I wonder what the merge-upstream command line will look like to do all
this :-)
> I'm also wondering if we should add a "deb-components" revision property
> so that we don't accidentally forget to export component tarballs if the
> appropriate tags are missing. What do you think?
That sounds like a good idea, but I don't know if we'll be able to set
it in all circumstances. I think if it can be set then we should and
should use it.
Thanks,
James
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jelmer Vernooij (jelmer) wrote : | # |
On 24/06/11 03:12, James Westby wrote:
> On Fri, 24 Jun 2011 02:39:45 +0200, Jelmer Vernooij<email address hidden> wrote:
>> Basically importing each upstream component tarball as a separate
>> revision with its own history and tagging them appropriately:
>>
>> * "upstream-1.0" for bar_1.0.
>> * "upstream-1.0/bla" for bar_1.0.
>>
>> ... and then having the package branch take these revisions as parents,
>> making the components look like by-value nested trees. If an upstream
>> component tarball hasn't changed between upstream releases we just retag
>> it.
> That sounds pretty good to me.
>
> I wonder what the merge-upstream command line will look like to do all
> this :-)
Yeah, that will be nasty. :-( Doing it as part of import-dsc (and udd)
is a lot easier as we can just read everything from the .dsc file.
Like the merge-upstream command-line, we'll have to update the
configuration file to support multiple upstream branches and multiple
upstream tag schemes.
>> I'm also wondering if we should add a "deb-components" revision property
>> so that we don't accidentally forget to export component tarballs if the
>> appropriate tags are missing. What do you think?
> That sounds like a good idea, but I don't know if we'll be able to set
> it in all circumstances. I think if it can be set then we should and
> should use it.
Cool, I'll add it.
Cheers,
Jelmer
Preview Diff
1 | === modified file '__init__.py' | |||
2 | --- __init__.py 2011-06-03 14:42:26 +0000 | |||
3 | +++ __init__.py 2011-06-23 21:47:20 +0000 | |||
4 | @@ -24,7 +24,6 @@ | |||
5 | 24 | """bzr-builddeb - manage packages in a Bazaar branch.""" | 24 | """bzr-builddeb - manage packages in a Bazaar branch.""" |
6 | 25 | 25 | ||
7 | 26 | import os | 26 | import os |
8 | 27 | import re | ||
9 | 28 | 27 | ||
10 | 29 | import bzrlib | 28 | import bzrlib |
11 | 30 | from bzrlib.commands import plugin_cmds | 29 | from bzrlib.commands import plugin_cmds |
12 | 31 | 30 | ||
13 | === modified file 'cmds.py' | |||
14 | --- cmds.py 2011-06-21 20:55:13 +0000 | |||
15 | +++ cmds.py 2011-06-23 21:47:20 +0000 | |||
16 | @@ -108,6 +108,7 @@ | |||
17 | 108 | from bzrlib.plugins.builddeb.util import ( | 108 | from bzrlib.plugins.builddeb.util import ( |
18 | 109 | FORMAT_3_0_QUILT, | 109 | FORMAT_3_0_QUILT, |
19 | 110 | FORMAT_3_0_NATIVE, | 110 | FORMAT_3_0_NATIVE, |
20 | 111 | component_from_orig_tarball, | ||
21 | 111 | debuild_config, | 112 | debuild_config, |
22 | 112 | dget_changes, | 113 | dget_changes, |
23 | 113 | find_changelog, | 114 | find_changelog, |
24 | @@ -560,7 +561,9 @@ | |||
25 | 560 | db = DistributionBranch(tree.branch, tree.branch, tree=tree) | 561 | db = DistributionBranch(tree.branch, tree.branch, tree=tree) |
26 | 561 | dbs = DistributionBranchSet() | 562 | dbs = DistributionBranchSet() |
27 | 562 | dbs.add_branch(db) | 563 | dbs.add_branch(db) |
29 | 563 | conflicts = db.merge_upstream(tarball_filenames, package, version, | 564 | tarballs = [(p, component_from_orig_tarball(p, package, version)) for p |
30 | 565 | in tarball_filenames] | ||
31 | 566 | conflicts = db.merge_upstream(tarballs, package, version, | ||
32 | 564 | current_version, upstream_branch=upstream_branch, | 567 | current_version, upstream_branch=upstream_branch, |
33 | 565 | upstream_revision=upstream_revision, | 568 | upstream_revision=upstream_revision, |
34 | 566 | merge_type=merge_type, force=force) | 569 | merge_type=merge_type, force=force) |
35 | @@ -588,7 +591,7 @@ | |||
36 | 588 | ret.append(tarball_filename) | 591 | ret.append(tarball_filename) |
37 | 589 | return ret | 592 | return ret |
38 | 590 | 593 | ||
40 | 591 | def _get_tarball(self, config, tree, package, version, upstream_branch, | 594 | def _get_tarballs(self, config, tree, package, version, upstream_branch, |
41 | 592 | upstream_revision, v3, locations): | 595 | upstream_revision, v3, locations): |
42 | 593 | orig_dir = config.orig_dir or default_orig_dir | 596 | orig_dir = config.orig_dir or default_orig_dir |
43 | 594 | orig_dir = os.path.join(tree.basedir, orig_dir) | 597 | orig_dir = os.path.join(tree.basedir, orig_dir) |
44 | @@ -747,7 +750,7 @@ | |||
45 | 747 | source_format = get_source_format(tree) | 750 | source_format = get_source_format(tree) |
46 | 748 | v3 = (source_format in [ | 751 | v3 = (source_format in [ |
47 | 749 | FORMAT_3_0_QUILT, FORMAT_3_0_NATIVE]) | 752 | FORMAT_3_0_QUILT, FORMAT_3_0_NATIVE]) |
49 | 750 | tarball_filenames = self._get_tarball(config, tree, package, | 753 | tarball_filenames = self._get_tarballs(config, tree, package, |
50 | 751 | version, upstream_branch, upstream_revision, v3, | 754 | version, upstream_branch, upstream_revision, v3, |
51 | 752 | locations) | 755 | locations) |
52 | 753 | conflicts = self._do_merge(tree, tarball_filenames, package, | 756 | conflicts = self._do_merge(tree, tarball_filenames, package, |
53 | @@ -977,10 +980,16 @@ | |||
54 | 977 | else: | 980 | else: |
55 | 978 | raise BzrCommandError('bzr import-upstream --revision takes exactly' | 981 | raise BzrCommandError('bzr import-upstream --revision takes exactly' |
56 | 979 | ' one revision specifier.') | 982 | ' one revision specifier.') |
61 | 980 | tarballs = [(location, md5sum_filename(location))] | 983 | tarballs = [(location, None, md5sum_filename(location))] |
62 | 981 | tag_name, _ = db.import_upstream_tarballs(tarballs, version, parents, | 984 | for (component, tag_name, revid) in db.import_upstream_tarballs( |
63 | 982 | upstream_branch=upstream, upstream_revision=upstream_revid) | 985 | tarballs, None, version, parents, upstream_branch=upstream, |
64 | 983 | self.outf.write('Imported %s as tag:%s.\n' % (location, tag_name)) | 986 | upstream_revision=upstream_revid): |
65 | 987 | if component is None: | ||
66 | 988 | self.outf.write('Imported %s as tag:%s.\n' % ( | ||
67 | 989 | location, tag_name)) | ||
68 | 990 | else: | ||
69 | 991 | self.outf.write('Imported %s (%s) as tag:%s.\n' % ( | ||
70 | 992 | location, component, tag_name)) | ||
71 | 984 | 993 | ||
72 | 985 | 994 | ||
73 | 986 | class cmd_bd_do(Command): | 995 | class cmd_bd_do(Command): |
74 | 987 | 996 | ||
75 | === modified file 'dh_make.py' | |||
76 | --- dh_make.py 2011-06-15 16:35:46 +0000 | |||
77 | +++ dh_make.py 2011-06-23 21:47:20 +0000 | |||
78 | @@ -70,8 +70,8 @@ | |||
79 | 70 | orig_dir, []) | 70 | orig_dir, []) |
80 | 71 | orig_files = provider.provide(os.path.join(tree.basedir, "..")) | 71 | orig_files = provider.provide(os.path.join(tree.basedir, "..")) |
81 | 72 | ret = [] | 72 | ret = [] |
84 | 73 | for filename in orig_files: | 73 | for filename, component in orig_files: |
85 | 74 | ret.append((filename, util.md5sum_filename(filename))) | 74 | ret.append((filename, component, util.md5sum_filename(filename))) |
86 | 75 | return ret | 75 | return ret |
87 | 76 | 76 | ||
88 | 77 | 77 | ||
89 | @@ -87,7 +87,8 @@ | |||
90 | 87 | pristine_upstream_tree=tree) | 87 | pristine_upstream_tree=tree) |
91 | 88 | dbs = import_dsc.DistributionBranchSet() | 88 | dbs = import_dsc.DistributionBranchSet() |
92 | 89 | dbs.add_branch(db) | 89 | dbs.add_branch(db) |
94 | 90 | db.import_upstream_tarballs(tarball_filenames, version, parents) | 90 | db.import_upstream_tarballs(tarball_filenames, package_name, version, |
95 | 91 | parents) | ||
96 | 91 | return tree | 92 | return tree |
97 | 92 | 93 | ||
98 | 93 | 94 | ||
99 | 94 | 95 | ||
100 | === modified file 'import_dsc.py' | |||
101 | --- import_dsc.py 2011-06-15 16:35:46 +0000 | |||
102 | +++ import_dsc.py 2011-06-23 21:47:20 +0000 | |||
103 | @@ -49,7 +49,6 @@ | |||
104 | 49 | AlreadyBranchError, | 49 | AlreadyBranchError, |
105 | 50 | BzrCommandError, | 50 | BzrCommandError, |
106 | 51 | NotBranchError, | 51 | NotBranchError, |
107 | 52 | NoSuchRevision, | ||
108 | 53 | NoWorkingTree, | 52 | NoWorkingTree, |
109 | 54 | UnrelatedBranches, | 53 | UnrelatedBranches, |
110 | 55 | ) | 54 | ) |
111 | @@ -61,7 +60,6 @@ | |||
112 | 61 | 60 | ||
113 | 62 | from bzrlib.plugins.builddeb.bzrtools_import import import_dir | 61 | from bzrlib.plugins.builddeb.bzrtools_import import import_dir |
114 | 63 | from bzrlib.plugins.builddeb.errors import ( | 62 | from bzrlib.plugins.builddeb.errors import ( |
115 | 64 | MultipleUpstreamTarballsNotSupported, | ||
116 | 65 | UpstreamAlreadyImported, | 63 | UpstreamAlreadyImported, |
117 | 66 | UpstreamBranchAlreadyMerged, | 64 | UpstreamBranchAlreadyMerged, |
118 | 67 | ) | 65 | ) |
119 | @@ -69,6 +67,7 @@ | |||
120 | 69 | FORMAT_1_0, | 67 | FORMAT_1_0, |
121 | 70 | FORMAT_3_0_QUILT, | 68 | FORMAT_3_0_QUILT, |
122 | 71 | FORMAT_3_0_NATIVE, | 69 | FORMAT_3_0_NATIVE, |
123 | 70 | component_from_orig_tarball, | ||
124 | 72 | extract_orig_tarballs, | 71 | extract_orig_tarballs, |
125 | 73 | get_commit_info_from_changelog, | 72 | get_commit_info_from_changelog, |
126 | 74 | md5sum_filename, | 73 | md5sum_filename, |
127 | @@ -77,9 +76,6 @@ | |||
128 | 77 | safe_decode, | 76 | safe_decode, |
129 | 78 | subprocess_setup, | 77 | subprocess_setup, |
130 | 79 | ) | 78 | ) |
131 | 80 | from bzrlib.plugins.builddeb.upstream.branch import ( | ||
132 | 81 | UpstreamBranchSource, | ||
133 | 82 | ) | ||
134 | 83 | from bzrlib.plugins.builddeb.upstream.pristinetar import ( | 79 | from bzrlib.plugins.builddeb.upstream.pristinetar import ( |
135 | 84 | PristineTarSource, | 80 | PristineTarSource, |
136 | 85 | ) | 81 | ) |
137 | @@ -475,13 +471,8 @@ | |||
138 | 475 | tag_name = self.pristine_upstream_source.tag_name(version) | 471 | tag_name = self.pristine_upstream_source.tag_name(version) |
139 | 476 | if revid is None: | 472 | if revid is None: |
140 | 477 | revid = self.pristine_upstream_branch.last_revision() | 473 | revid = self.pristine_upstream_branch.last_revision() |
148 | 478 | self.pristine_upstream_branch.tags.set_tag(tag_name, revid) | 474 | self.pristine_upstream_source.tag_version(version, revid) |
149 | 479 | try: | 475 | self.branch.fetch(self.pristine_upstream_branch) |
143 | 480 | self.branch.repository.fetch(self.pristine_upstream_branch.repository, | ||
144 | 481 | revision_id=revid) | ||
145 | 482 | except NoSuchRevision: | ||
146 | 483 | # See bug lp:574223 | ||
147 | 484 | pass | ||
150 | 485 | self.branch.tags.set_tag(tag_name, revid) | 476 | self.branch.tags.set_tag(tag_name, revid) |
151 | 486 | return tag_name, revid | 477 | return tag_name, revid |
152 | 487 | 478 | ||
153 | @@ -724,7 +715,7 @@ | |||
154 | 724 | "Can't pull upstream with no tree" | 715 | "Can't pull upstream with no tree" |
155 | 725 | self.pristine_upstream_tree.pull(up_pull_branch, | 716 | self.pristine_upstream_tree.pull(up_pull_branch, |
156 | 726 | stop_revision=pull_revision) | 717 | stop_revision=pull_revision) |
158 | 727 | self.tag_upstream_version(version, revid=pull_revision) | 718 | self.pristine_upstream_source.tag_version(version, pull_revision) |
159 | 728 | self.branch.fetch(self.pristine_upstream_branch, last_revision=pull_revision) | 719 | self.branch.fetch(self.pristine_upstream_branch, last_revision=pull_revision) |
160 | 729 | self.pristine_upstream_branch.tags.merge_to(self.branch.tags) | 720 | self.pristine_upstream_branch.tags.merge_to(self.branch.tags) |
161 | 730 | 721 | ||
162 | @@ -828,8 +819,8 @@ | |||
163 | 828 | self.branch.fetch(self.pristine_upstream_branch, last_revision=revid) | 819 | self.branch.fetch(self.pristine_upstream_branch, last_revision=revid) |
164 | 829 | self.pristine_upstream_branch.tags.merge_to(self.branch.tags) | 820 | self.pristine_upstream_branch.tags.merge_to(self.branch.tags) |
165 | 830 | 821 | ||
168 | 831 | def import_upstream(self, upstream_part, version, upstream_parents, | 822 | def import_upstream(self, upstream_part, package, version, upstream_parents, |
169 | 832 | upstream_tarballs=None, upstream_branch=None, | 823 | upstream_tarballs, upstream_branch=None, |
170 | 833 | upstream_revision=None, timestamp=None, author=None, | 824 | upstream_revision=None, timestamp=None, author=None, |
171 | 834 | file_ids_from=None): | 825 | file_ids_from=None): |
172 | 835 | """Import an upstream part on to the upstream branch. | 826 | """Import an upstream part on to the upstream branch. |
173 | @@ -843,7 +834,7 @@ | |||
174 | 843 | :param upstream_parents: the parents to give the upstream revision | 834 | :param upstream_parents: the parents to give the upstream revision |
175 | 844 | :param timestamp: a tuple of (timestamp, timezone) to use for | 835 | :param timestamp: a tuple of (timestamp, timezone) to use for |
176 | 845 | the commit, or None to use the current time. | 836 | the commit, or None to use the current time. |
178 | 846 | :return: (tag_name, revision_id) of the imported tarball. | 837 | :return: list with (component, tag, revid) tuples |
179 | 847 | """ | 838 | """ |
180 | 848 | # Should we just dump the upstream part on whatever is currently | 839 | # Should we just dump the upstream part on whatever is currently |
181 | 849 | # there, or try and pull all of the other upstream versions | 840 | # there, or try and pull all of the other upstream versions |
182 | @@ -859,12 +850,10 @@ | |||
183 | 859 | parent_revid = upstream_parents[0] | 850 | parent_revid = upstream_parents[0] |
184 | 860 | else: | 851 | else: |
185 | 861 | parent_revid = NULL_REVISION | 852 | parent_revid = NULL_REVISION |
188 | 862 | self.pristine_upstream_tree.pull(self.pristine_upstream_tree.branch, overwrite=True, | 853 | self.pristine_upstream_tree.pull(self.pristine_upstream_tree.branch, |
189 | 863 | stop_revision=parent_revid) | 854 | overwrite=True, stop_revision=parent_revid) |
190 | 864 | other_branches = self.get_other_branches() | 855 | other_branches = self.get_other_branches() |
194 | 865 | def get_last_revision_tree(br): | 856 | upstream_trees = [o.pristine_upstream_branch.basis_tree() |
192 | 866 | return br.repository.revision_tree(br.last_revision()) | ||
193 | 867 | upstream_trees = [get_last_revision_tree(o.pristine_upstream_branch) | ||
195 | 868 | for o in other_branches] | 857 | for o in other_branches] |
196 | 869 | target_tree = None | 858 | target_tree = None |
197 | 870 | if upstream_branch is not None: | 859 | if upstream_branch is not None: |
198 | @@ -890,33 +879,23 @@ | |||
199 | 890 | target_tree=target_tree) | 879 | target_tree=target_tree) |
200 | 891 | finally: | 880 | finally: |
201 | 892 | self_tree.unlock() | 881 | self_tree.unlock() |
202 | 893 | self.pristine_upstream_tree.set_parent_ids(upstream_parents) | ||
203 | 894 | revprops = {} | 882 | revprops = {} |
223 | 895 | if upstream_tarballs is not None: | 883 | ret = [] |
224 | 896 | if len(upstream_tarballs) != 1: | 884 | for (tarball, component, md5) in upstream_tarballs: |
225 | 897 | raise MultipleUpstreamTarballsNotSupported() | 885 | (tag, revid) = self.pristine_upstream_source.import_component_tarball( |
226 | 898 | (upstream_tarball, md5) = upstream_tarballs[0] | 886 | package, version, self.pristine_upstream_tree, component, |
227 | 899 | revprops["deb-md5"] = md5 | 887 | md5, tarball, author=author, timestamp=timestamp, |
228 | 900 | delta_revprops = self.pristine_upstream_source.create_delta_revprops( | 888 | parent_ids=upstream_parents) |
229 | 901 | self.pristine_upstream_tree, upstream_tarball) | 889 | ret.append((component, tag, revid)) |
230 | 902 | revprops.update(delta_revprops) | 890 | self.branch.fetch(self.pristine_upstream_branch) |
231 | 903 | if author is not None: | 891 | self.branch.tags.set_tag(tag, revid) |
232 | 904 | revprops['authors'] = author | 892 | return ret |
214 | 905 | timezone = None | ||
215 | 906 | if timestamp is not None: | ||
216 | 907 | timezone = timestamp[1] | ||
217 | 908 | timestamp = timestamp[0] | ||
218 | 909 | revid = self.pristine_upstream_tree.commit("Import upstream version %s" \ | ||
219 | 910 | % (version,), | ||
220 | 911 | revprops=revprops, timestamp=timestamp, timezone=timezone) | ||
221 | 912 | tag_name, _ = self.tag_upstream_version(version, revid=revid) | ||
222 | 913 | return tag_name, revid | ||
233 | 914 | 893 | ||
235 | 915 | def import_upstream_tarballs(self, tarballs, version, parents, | 894 | def import_upstream_tarballs(self, tarballs, package, version, parents, |
236 | 916 | upstream_branch=None, upstream_revision=None): | 895 | upstream_branch=None, upstream_revision=None): |
237 | 917 | """Import an upstream part to the upstream branch. | 896 | """Import an upstream part to the upstream branch. |
238 | 918 | 897 | ||
240 | 919 | :param tarball_filename: The tarball to import. | 898 | :param tarballs: List of tarballs / components to extract |
241 | 920 | :param version: The upstream version to import. | 899 | :param version: The upstream version to import. |
242 | 921 | :param parents: The tarball-branch parents to use for the import. | 900 | :param parents: The tarball-branch parents to use for the import. |
243 | 922 | If an upstream branch is supplied, its automatically added to | 901 | If an upstream branch is supplied, its automatically added to |
244 | @@ -925,11 +904,11 @@ | |||
245 | 925 | tarball. | 904 | tarball. |
246 | 926 | :param upstream_revision: Upstream revision id | 905 | :param upstream_revision: Upstream revision id |
247 | 927 | :param md5sum: hex digest of the md5sum of the tarball, if known. | 906 | :param md5sum: hex digest of the md5sum of the tarball, if known. |
249 | 928 | :return: (tag_name, revision_id) of the imported tarball. | 907 | :return: list with (component, tag, revid) tuples |
250 | 929 | """ | 908 | """ |
251 | 930 | tarball_dir = self._extract_tarballs_to_tempdir(tarballs) | 909 | tarball_dir = self._extract_tarballs_to_tempdir(tarballs) |
252 | 931 | try: | 910 | try: |
254 | 932 | return self.import_upstream(tarball_dir, version, parents, | 911 | return self.import_upstream(tarball_dir, package, version, parents, |
255 | 933 | tarballs, | 912 | tarballs, |
256 | 934 | upstream_branch=upstream_branch, | 913 | upstream_branch=upstream_branch, |
257 | 935 | upstream_revision=upstream_revision) | 914 | upstream_revision=upstream_revision) |
258 | @@ -944,8 +923,7 @@ | |||
259 | 944 | poss_native_tree = self.get_branch_tip_revtree() | 923 | poss_native_tree = self.get_branch_tip_revtree() |
260 | 945 | current_native = self._is_tree_native(poss_native_tree) | 924 | current_native = self._is_tree_native(poss_native_tree) |
261 | 946 | current_config = self._default_config_for_tree(poss_native_tree) | 925 | current_config = self._default_config_for_tree(poss_native_tree) |
264 | 947 | dirname = os.path.join(self.tree.basedir, | 926 | dirname = os.path.join(self.tree.basedir, '.bzr-builddeb') |
263 | 948 | '.bzr-builddeb') | ||
265 | 949 | if current_config is not None: | 927 | if current_config is not None: |
266 | 950 | # Add that back to the current tree | 928 | # Add that back to the current tree |
267 | 951 | if not os.path.exists(dirname): | 929 | if not os.path.exists(dirname): |
268 | @@ -1022,10 +1000,7 @@ | |||
269 | 1022 | "as the single parent") | 1000 | "as the single parent") |
270 | 1023 | parents = [self.branch.last_revision()] | 1001 | parents = [self.branch.last_revision()] |
271 | 1024 | other_branches = self.get_other_branches() | 1002 | other_branches = self.get_other_branches() |
276 | 1025 | def get_last_revision_tree(br): | 1003 | debian_trees = [o.branch.basis_tree() for o in other_branches] |
273 | 1026 | return br.repository.revision_tree(br.last_revision()) | ||
274 | 1027 | debian_trees = [get_last_revision_tree(o.branch) | ||
275 | 1028 | for o in other_branches] | ||
277 | 1029 | parent_trees = [] | 1004 | parent_trees = [] |
278 | 1030 | if file_ids_from is not None: | 1005 | if file_ids_from is not None: |
279 | 1031 | parent_trees = file_ids_from[:] | 1006 | parent_trees = file_ids_from[:] |
280 | @@ -1169,13 +1144,13 @@ | |||
281 | 1169 | # from another branch: | 1144 | # from another branch: |
282 | 1170 | upstream_parents = self.upstream_parents(package, versions, | 1145 | upstream_parents = self.upstream_parents(package, versions, |
283 | 1171 | version.upstream_version) | 1146 | version.upstream_version) |
286 | 1172 | _, new_revid = self.import_upstream(upstream_part, | 1147 | for (component, tag, revid) in self.import_upstream(upstream_part, |
287 | 1173 | version.upstream_version, | 1148 | package, version.upstream_version, |
288 | 1174 | upstream_parents, | 1149 | upstream_parents, |
289 | 1175 | upstream_tarballs=upstream_tarballs, | 1150 | upstream_tarballs=upstream_tarballs, |
290 | 1176 | timestamp=timestamp, author=author, | 1151 | timestamp=timestamp, author=author, |
293 | 1177 | file_ids_from=file_ids_from) | 1152 | file_ids_from=file_ids_from): |
294 | 1178 | self._fetch_upstream_to_branch(new_revid) | 1153 | self._fetch_upstream_to_branch(revid) |
295 | 1179 | else: | 1154 | else: |
296 | 1180 | mutter("We already have the needed upstream part") | 1155 | mutter("We already have the needed upstream part") |
297 | 1181 | parents = self.get_parents_with_upstream(package, version, versions, | 1156 | parents = self.get_parents_with_upstream(package, version, versions, |
298 | @@ -1356,8 +1331,9 @@ | |||
299 | 1356 | def _extract_tarballs_to_tempdir(self, tarballs): | 1331 | def _extract_tarballs_to_tempdir(self, tarballs): |
300 | 1357 | tempdir = tempfile.mkdtemp() | 1332 | tempdir = tempfile.mkdtemp() |
301 | 1358 | try: | 1333 | try: |
304 | 1359 | extract_orig_tarballs([fn for (fn, md5) in tarballs], tempdir, | 1334 | extract_orig_tarballs( |
305 | 1360 | strip_components=1) | 1335 | [(fn, component) for (fn, component, md5) in tarballs], |
306 | 1336 | tempdir, strip_components=1) | ||
307 | 1361 | return tempdir | 1337 | return tempdir |
308 | 1362 | except: | 1338 | except: |
309 | 1363 | shutil.rmtree(tempdir) | 1339 | shutil.rmtree(tempdir) |
310 | @@ -1405,7 +1381,8 @@ | |||
311 | 1405 | self.branch.last_revision()): | 1381 | self.branch.last_revision()): |
312 | 1406 | raise UpstreamBranchAlreadyMerged | 1382 | raise UpstreamBranchAlreadyMerged |
313 | 1407 | upstream_tarballs = [ | 1383 | upstream_tarballs = [ |
315 | 1408 | (os.path.abspath(fn), md5sum_filename(fn)) for fn in | 1384 | (os.path.abspath(fn), component, md5sum_filename(fn)) for |
316 | 1385 | (fn, component) in | ||
317 | 1409 | tarball_filenames] | 1386 | tarball_filenames] |
318 | 1410 | tarball_dir = self._extract_tarballs_to_tempdir(upstream_tarballs) | 1387 | tarball_dir = self._extract_tarballs_to_tempdir(upstream_tarballs) |
319 | 1411 | try: | 1388 | try: |
320 | @@ -1413,11 +1390,11 @@ | |||
321 | 1413 | parents = [] | 1390 | parents = [] |
322 | 1414 | if self.pristine_upstream_branch.last_revision() != NULL_REVISION: | 1391 | if self.pristine_upstream_branch.last_revision() != NULL_REVISION: |
323 | 1415 | parents = [self.pristine_upstream_branch.last_revision()] | 1392 | parents = [self.pristine_upstream_branch.last_revision()] |
326 | 1416 | _, new_revid = self.import_upstream(tarball_dir, | 1393 | for (component, tag, revid) in self.import_upstream(tarball_dir, |
327 | 1417 | version, parents, upstream_tarballs=upstream_tarballs, | 1394 | package, version, parents, upstream_tarballs=upstream_tarballs, |
328 | 1418 | upstream_branch=upstream_branch, | 1395 | upstream_branch=upstream_branch, |
331 | 1419 | upstream_revision=upstream_revision) | 1396 | upstream_revision=upstream_revision): |
332 | 1420 | self._fetch_upstream_to_branch(new_revid) | 1397 | self._fetch_upstream_to_branch(revid) |
333 | 1421 | finally: | 1398 | finally: |
334 | 1422 | shutil.rmtree(tarball_dir) | 1399 | shutil.rmtree(tarball_dir) |
335 | 1423 | if self.branch.last_revision() != NULL_REVISION: | 1400 | if self.branch.last_revision() != NULL_REVISION: |
336 | @@ -1502,7 +1479,9 @@ | |||
337 | 1502 | if part['name'].endswith(".orig.tar.gz"): | 1479 | if part['name'].endswith(".orig.tar.gz"): |
338 | 1503 | self.upstream_tarballs.append((os.path.abspath( | 1480 | self.upstream_tarballs.append((os.path.abspath( |
339 | 1504 | os.path.join(osutils.dirname(self.dsc_path), | 1481 | os.path.join(osutils.dirname(self.dsc_path), |
341 | 1505 | part['name'])), part['md5sum'])) | 1482 | part['name'])), |
342 | 1483 | component_from_orig_tarball(part['name'], name, str(version.upstream_version)), | ||
343 | 1484 | part['md5sum'])) | ||
344 | 1506 | elif part['name'].endswith(".diff.gz"): | 1485 | elif part['name'].endswith(".diff.gz"): |
345 | 1507 | self.unextracted_debian_md5 = part['md5sum'] | 1486 | self.unextracted_debian_md5 = part['md5sum'] |
346 | 1508 | 1487 | ||
347 | 1509 | 1488 | ||
348 | === modified file 'source_distiller.py' | |||
349 | --- source_distiller.py 2011-06-15 01:28:19 +0000 | |||
350 | +++ source_distiller.py 2011-06-23 21:47:20 +0000 | |||
351 | @@ -25,11 +25,11 @@ | |||
352 | 25 | from bzrlib import errors as bzr_errors | 25 | from bzrlib import errors as bzr_errors |
353 | 26 | 26 | ||
354 | 27 | from bzrlib.plugins.builddeb.util import ( | 27 | from bzrlib.plugins.builddeb.util import ( |
360 | 28 | export, | 28 | export, |
361 | 29 | extract_orig_tarballs, | 29 | extract_orig_tarballs, |
362 | 30 | get_parent_dir, | 30 | get_parent_dir, |
363 | 31 | recursive_copy, | 31 | recursive_copy, |
364 | 32 | ) | 32 | ) |
365 | 33 | 33 | ||
366 | 34 | 34 | ||
367 | 35 | class SourceDistiller(object): | 35 | class SourceDistiller(object): |
368 | 36 | 36 | ||
369 | === modified file 'tests/blackbox/test_merge_upstream.py' | |||
370 | --- tests/blackbox/test_merge_upstream.py 2011-06-15 16:35:46 +0000 | |||
371 | +++ tests/blackbox/test_merge_upstream.py 2011-06-23 21:47:20 +0000 | |||
372 | @@ -95,7 +95,9 @@ | |||
373 | 95 | dbs = DistributionBranchSet() | 95 | dbs = DistributionBranchSet() |
374 | 96 | dbs.add_branch(db) | 96 | dbs.add_branch(db) |
375 | 97 | db.import_upstream_tarballs( | 97 | db.import_upstream_tarballs( |
377 | 98 | [(self.tar.tarball, md5sum_filename(self.tar.tarball))], str(self.tar.version), | 98 | [(self.tar.tarball, None, md5sum_filename(self.tar.tarball))], |
378 | 99 | "foo", | ||
379 | 100 | str(self.tar.version), | ||
380 | 99 | [tree.branch.last_revision()]) | 101 | [tree.branch.last_revision()]) |
381 | 100 | package_builder = SourcePackageBuilder("foo", | 102 | package_builder = SourcePackageBuilder("foo", |
382 | 101 | str(self.tar.version)+"-1") | 103 | str(self.tar.version)+"-1") |
383 | 102 | 104 | ||
384 | === modified file 'tests/test_import_dsc.py' | |||
385 | --- tests/test_import_dsc.py 2011-06-15 16:35:46 +0000 | |||
386 | +++ tests/test_import_dsc.py 2011-06-23 21:47:20 +0000 | |||
387 | @@ -173,26 +173,26 @@ | |||
388 | 173 | version = "0.1" | 173 | version = "0.1" |
389 | 174 | self.assertFalse(db.has_upstream_version("package", version)) | 174 | self.assertFalse(db.has_upstream_version("package", version)) |
390 | 175 | self.assertFalse(db.has_upstream_version("package", version, | 175 | self.assertFalse(db.has_upstream_version("package", version, |
392 | 176 | [("foo.tar.gz", self.fake_md5_1)])) | 176 | [("foo.tar.gz", None, self.fake_md5_1)])) |
393 | 177 | self.do_commit_with_md5(self.up_tree1, "one", self.fake_md5_1) | 177 | self.do_commit_with_md5(self.up_tree1, "one", self.fake_md5_1) |
394 | 178 | db.tag_upstream_version(version) | 178 | db.tag_upstream_version(version) |
395 | 179 | self.assertTrue(db.has_upstream_version("package", version)) | 179 | self.assertTrue(db.has_upstream_version("package", version)) |
396 | 180 | self.assertTrue(db.has_upstream_version("package", | 180 | self.assertTrue(db.has_upstream_version("package", |
398 | 181 | version, [("foo.tar.gz", self.fake_md5_1)])) | 181 | version, [("foo.tar.gz", None, self.fake_md5_1)])) |
399 | 182 | self.assertFalse(db.has_upstream_version("package", version, | 182 | self.assertFalse(db.has_upstream_version("package", version, |
401 | 183 | [("foo.tar.gz", self.fake_md5_2)])) | 183 | [("foo.tar.gz", None, self.fake_md5_2)])) |
402 | 184 | version = "0.1" | 184 | version = "0.1" |
403 | 185 | self.assertTrue(db.has_upstream_version("package", version)) | 185 | self.assertTrue(db.has_upstream_version("package", version)) |
404 | 186 | self.assertTrue(db.has_upstream_version("package", version, | 186 | self.assertTrue(db.has_upstream_version("package", version, |
406 | 187 | [("foo.tar.gz", self.fake_md5_1)])) | 187 | [("foo.tar.gz", None, self.fake_md5_1)])) |
407 | 188 | self.assertFalse(db.has_upstream_version("package", version, | 188 | self.assertFalse(db.has_upstream_version("package", version, |
409 | 189 | [("foo.tar.gz", self.fake_md5_2)])) | 189 | [("foo.tar.gz", None, self.fake_md5_2)])) |
410 | 190 | version = "0.2" | 190 | version = "0.2" |
411 | 191 | self.assertFalse(db.has_upstream_version("package", version)) | 191 | self.assertFalse(db.has_upstream_version("package", version)) |
412 | 192 | self.assertFalse(db.has_upstream_version("package", version, | 192 | self.assertFalse(db.has_upstream_version("package", version, |
414 | 193 | [("foo.tar.gz", self.fake_md5_1)])) | 193 | [("foo.tar.gz", None, self.fake_md5_1)])) |
415 | 194 | self.assertFalse(db.has_upstream_version("package", version, | 194 | self.assertFalse(db.has_upstream_version("package", version, |
417 | 195 | [("foo.tar.gz", self.fake_md5_2)])) | 195 | [("foo.tar.gz", None, self.fake_md5_2)])) |
418 | 196 | 196 | ||
419 | 197 | def test_revid_of_version(self): | 197 | def test_revid_of_version(self): |
420 | 198 | db = self.db1 | 198 | db = self.db1 |
421 | @@ -640,48 +640,48 @@ | |||
422 | 640 | version2 = Version("0.2-1") | 640 | version2 = Version("0.2-1") |
423 | 641 | # With no versions tagged everything is None | 641 | # With no versions tagged everything is None |
424 | 642 | branch = self.db2.branch_to_pull_upstream_from("package", | 642 | branch = self.db2.branch_to_pull_upstream_from("package", |
426 | 643 | version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)]) | 643 | version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_1)]) |
427 | 644 | self.assertEqual(branch, None) | 644 | self.assertEqual(branch, None) |
428 | 645 | branch = self.db2.branch_to_pull_upstream_from("package", | 645 | branch = self.db2.branch_to_pull_upstream_from("package", |
430 | 646 | version1.upstream_version, [("foo.tar.gz", self.fake_md5_2)]) | 646 | version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_2)]) |
431 | 647 | self.assertEqual(branch, None) | 647 | self.assertEqual(branch, None) |
432 | 648 | branch = self.db1.branch_to_pull_upstream_from("package", | 648 | branch = self.db1.branch_to_pull_upstream_from("package", |
434 | 649 | version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)]) | 649 | version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_1)]) |
435 | 650 | self.assertEqual(branch, None) | 650 | self.assertEqual(branch, None) |
436 | 651 | self.do_commit_with_md5(self.up_tree1, "one", self.fake_md5_1) | 651 | self.do_commit_with_md5(self.up_tree1, "one", self.fake_md5_1) |
437 | 652 | self.db1.tag_upstream_version(version1.upstream_version) | 652 | self.db1.tag_upstream_version(version1.upstream_version) |
438 | 653 | # Version and md5 available, so we get the correct branch. | 653 | # Version and md5 available, so we get the correct branch. |
439 | 654 | branch = self.db2.branch_to_pull_upstream_from("package", | 654 | branch = self.db2.branch_to_pull_upstream_from("package", |
441 | 655 | version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)]) | 655 | version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_1)]) |
442 | 656 | self.assertEqual(branch, self.db1) | 656 | self.assertEqual(branch, self.db1) |
443 | 657 | # Otherwise (different version or md5) then we get None | 657 | # Otherwise (different version or md5) then we get None |
444 | 658 | branch = self.db2.branch_to_pull_upstream_from("package", | 658 | branch = self.db2.branch_to_pull_upstream_from("package", |
454 | 659 | version1.upstream_version, [("foo.tar.gz", self.fake_md5_2)]) | 659 | version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_2)]) |
455 | 660 | self.assertEqual(branch, None) | 660 | self.assertEqual(branch, None) |
456 | 661 | branch = self.db2.branch_to_pull_upstream_from("package", | 661 | branch = self.db2.branch_to_pull_upstream_from("package", |
457 | 662 | version2.upstream_version, | 662 | version2.upstream_version, |
458 | 663 | [("foo.tar.gz", self.fake_md5_1)]) | 663 | [("foo.tar.gz", None, self.fake_md5_1)]) |
459 | 664 | self.assertEqual(branch, None) | 664 | self.assertEqual(branch, None) |
460 | 665 | branch = self.db2.branch_to_pull_upstream_from("package", | 665 | branch = self.db2.branch_to_pull_upstream_from("package", |
461 | 666 | version2.upstream_version, | 666 | version2.upstream_version, |
462 | 667 | [("foo.tar.gz", self.fake_md5_2)]) | 667 | [("foo.tar.gz", None, self.fake_md5_2)]) |
463 | 668 | self.assertEqual(branch, None) | 668 | self.assertEqual(branch, None) |
464 | 669 | # And we don't get a branch for the one that already has | 669 | # And we don't get a branch for the one that already has |
465 | 670 | # the version | 670 | # the version |
466 | 671 | branch = self.db1.branch_to_pull_upstream_from("package", | 671 | branch = self.db1.branch_to_pull_upstream_from("package", |
468 | 672 | version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)]) | 672 | version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_1)]) |
469 | 673 | self.assertEqual(branch, None) | 673 | self.assertEqual(branch, None) |
470 | 674 | self.up_tree2.pull(self.up_tree1.branch) | 674 | self.up_tree2.pull(self.up_tree1.branch) |
471 | 675 | self.db2.tag_upstream_version(version1.upstream_version) | 675 | self.db2.tag_upstream_version(version1.upstream_version) |
472 | 676 | # And we get the greatest branch when two lesser branches | 676 | # And we get the greatest branch when two lesser branches |
473 | 677 | # have what we are looking for. | 677 | # have what we are looking for. |
474 | 678 | branch = self.db3.branch_to_pull_upstream_from("package", | 678 | branch = self.db3.branch_to_pull_upstream_from("package", |
476 | 679 | version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)]) | 679 | version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_1)]) |
477 | 680 | self.assertEqual(branch, self.db2) | 680 | self.assertEqual(branch, self.db2) |
478 | 681 | # If the branches have diverged then we don't get a branch. | 681 | # If the branches have diverged then we don't get a branch. |
479 | 682 | self.up_tree3.commit("three") | 682 | self.up_tree3.commit("three") |
480 | 683 | branch = self.db3.branch_to_pull_upstream_from("package", | 683 | branch = self.db3.branch_to_pull_upstream_from("package", |
482 | 684 | version1.upstream_version, [("foo.tar.gz", self.fake_md5_1)]) | 684 | version1.upstream_version, [("foo.tar.gz", None, self.fake_md5_1)]) |
483 | 685 | self.assertEqual(branch, None) | 685 | self.assertEqual(branch, None) |
484 | 686 | 686 | ||
485 | 687 | def test_pull_from_lesser_branch_no_upstream(self): | 687 | def test_pull_from_lesser_branch_no_upstream(self): |
486 | @@ -773,7 +773,8 @@ | |||
487 | 773 | contents = [(basedir + '/' + element[0],) + element[1:] for | 773 | contents = [(basedir + '/' + element[0],) + element[1:] for |
488 | 774 | element in contents] | 774 | element in contents] |
489 | 775 | self.build_tree_contents(contents) | 775 | self.build_tree_contents(contents) |
491 | 776 | self.db1.import_upstream(basedir, version.upstream_version, []) | 776 | self.db1.import_upstream(basedir, "package", version.upstream_version, |
492 | 777 | [], [(None, None, None)]) | ||
493 | 777 | return version | 778 | return version |
494 | 778 | 779 | ||
495 | 779 | def test_import_upstream(self): | 780 | def test_import_upstream(self): |
496 | @@ -807,14 +808,15 @@ | |||
497 | 807 | write_to_file(os.path.join(basedir, "README"), "Hi\n") | 808 | write_to_file(os.path.join(basedir, "README"), "Hi\n") |
498 | 808 | write_to_file(os.path.join(basedir, "BUGS"), "") | 809 | write_to_file(os.path.join(basedir, "BUGS"), "") |
499 | 809 | write_to_file(os.path.join(basedir, "COPYING"), "") | 810 | write_to_file(os.path.join(basedir, "COPYING"), "") |
501 | 810 | self.db1.import_upstream(basedir, version1.upstream_version, []) | 811 | self.db1.import_upstream(basedir, "package", version1.upstream_version, [], |
502 | 812 | [(None, None, None)]) | ||
503 | 811 | basedir = name + "-" + str(version2.upstream_version) | 813 | basedir = name + "-" + str(version2.upstream_version) |
504 | 812 | os.mkdir(basedir) | 814 | os.mkdir(basedir) |
505 | 813 | write_to_file(os.path.join(basedir, "README"), "Now even better\n") | 815 | write_to_file(os.path.join(basedir, "README"), "Now even better\n") |
506 | 814 | write_to_file(os.path.join(basedir, "BUGS"), "") | 816 | write_to_file(os.path.join(basedir, "BUGS"), "") |
507 | 815 | write_to_file(os.path.join(basedir, "NEWS"), "") | 817 | write_to_file(os.path.join(basedir, "NEWS"), "") |
510 | 816 | self.db1.import_upstream(basedir, version2.upstream_version, | 818 | self.db1.import_upstream(basedir, "package", version2.upstream_version, |
511 | 817 | [self.up_tree1.branch.last_revision()]) | 819 | [self.up_tree1.branch.last_revision()], [(None, None, None)]) |
512 | 818 | tree = self.up_tree1 | 820 | tree = self.up_tree1 |
513 | 819 | branch = tree.branch | 821 | branch = tree.branch |
514 | 820 | rh = branch.revision_history() | 822 | rh = branch.revision_history() |
515 | @@ -845,8 +847,8 @@ | |||
516 | 845 | tf.add(basedir) | 847 | tf.add(basedir) |
517 | 846 | finally: | 848 | finally: |
518 | 847 | tf.close() | 849 | tf.close() |
521 | 848 | self.db1.import_upstream(basedir, version.upstream_version, [], | 850 | self.db1.import_upstream(basedir, "package", version.upstream_version, [], |
522 | 849 | upstream_tarballs=[(os.path.abspath(tar_path), self.fake_md5_1)]) | 851 | upstream_tarballs=[(os.path.abspath(tar_path), None, self.fake_md5_1)]) |
523 | 850 | tree = self.up_tree1 | 852 | tree = self.up_tree1 |
524 | 851 | branch = tree.branch | 853 | branch = tree.branch |
525 | 852 | rh = branch.revision_history() | 854 | rh = branch.revision_history() |
526 | @@ -873,8 +875,8 @@ | |||
527 | 873 | tf.add(basedir) | 875 | tf.add(basedir) |
528 | 874 | finally: | 876 | finally: |
529 | 875 | tf.close() | 877 | tf.close() |
532 | 876 | self.db1.import_upstream(basedir, version.upstream_version, | 878 | self.db1.import_upstream(basedir, "package", version.upstream_version, |
533 | 877 | [], upstream_tarballs=[(os.path.abspath(tar_path), self.fake_md5_1)]) | 879 | [], upstream_tarballs=[(os.path.abspath(tar_path), None, self.fake_md5_1)]) |
534 | 878 | tree = self.up_tree1 | 880 | tree = self.up_tree1 |
535 | 879 | branch = tree.branch | 881 | branch = tree.branch |
536 | 880 | rh = branch.revision_history() | 882 | rh = branch.revision_history() |
537 | @@ -1503,7 +1505,7 @@ | |||
538 | 1503 | tf.add("a") | 1505 | tf.add("a") |
539 | 1504 | finally: | 1506 | finally: |
540 | 1505 | tf.close() | 1507 | tf.close() |
542 | 1506 | conflicts = db.merge_upstream([tarball_filename], "foo", "0.2", "0.1") | 1508 | conflicts = db.merge_upstream([(tarball_filename, None)], "foo", "0.2", "0.1") |
543 | 1507 | self.assertEqual(0, conflicts) | 1509 | self.assertEqual(0, conflicts) |
544 | 1508 | 1510 | ||
545 | 1509 | def test_merge_upstream_initial_with_branch(self): | 1511 | def test_merge_upstream_initial_with_branch(self): |
546 | @@ -1540,7 +1542,7 @@ | |||
547 | 1540 | tf.add("a") | 1542 | tf.add("a") |
548 | 1541 | finally: | 1543 | finally: |
549 | 1542 | tf.close() | 1544 | tf.close() |
551 | 1543 | conflicts = db.merge_upstream([tarball_filename], "foo", "0.2", "0.1", | 1545 | conflicts = db.merge_upstream([(tarball_filename, None)], "foo", "0.2", "0.1", |
552 | 1544 | upstream_branch=upstream_tree.branch, | 1546 | upstream_branch=upstream_tree.branch, |
553 | 1545 | upstream_revision=upstream_rev) | 1547 | upstream_revision=upstream_rev) |
554 | 1546 | self.assertEqual(0, conflicts) | 1548 | self.assertEqual(0, conflicts) |
555 | @@ -1580,7 +1582,7 @@ | |||
556 | 1580 | tf.add("a") | 1582 | tf.add("a") |
557 | 1581 | finally: | 1583 | finally: |
558 | 1582 | tf.close() | 1584 | tf.close() |
560 | 1583 | conflicts = db.merge_upstream([tarball_filename], "foo", "0.2", "0.1", | 1585 | conflicts = db.merge_upstream([(tarball_filename, None)], "foo", "0.2", "0.1", |
561 | 1584 | upstream_branch=upstream_tree.branch, | 1586 | upstream_branch=upstream_tree.branch, |
562 | 1585 | upstream_revision=upstream_rev) | 1587 | upstream_revision=upstream_rev) |
563 | 1586 | # ./debian conflicts. | 1588 | # ./debian conflicts. |
564 | @@ -1621,7 +1623,7 @@ | |||
565 | 1621 | dbs.add_branch(db) | 1623 | dbs.add_branch(db) |
566 | 1622 | tree.lock_write() | 1624 | tree.lock_write() |
567 | 1623 | self.addCleanup(tree.unlock) | 1625 | self.addCleanup(tree.unlock) |
569 | 1624 | db.merge_upstream([builder.tar_name()], "package", str(version2), | 1626 | db.merge_upstream([(builder.tar_name(), None)], "package", str(version2), |
570 | 1625 | version1.upstream_version, | 1627 | version1.upstream_version, |
571 | 1626 | upstream_branch=upstream_tree.branch, | 1628 | upstream_branch=upstream_tree.branch, |
572 | 1627 | upstream_revision=upstream_rev) | 1629 | upstream_revision=upstream_rev) |
573 | @@ -1660,7 +1662,7 @@ | |||
574 | 1660 | tf.add("a") | 1662 | tf.add("a") |
575 | 1661 | finally: | 1663 | finally: |
576 | 1662 | tf.close() | 1664 | tf.close() |
578 | 1663 | conflicts = db.merge_upstream([tarball_filename], "package", "0.2-1", | 1665 | conflicts = db.merge_upstream([(tarball_filename, None)], "package", "0.2-1", |
579 | 1664 | "0.1") | 1666 | "0.1") |
580 | 1665 | # Check that we tagged wiht the dash version | 1667 | # Check that we tagged wiht the dash version |
581 | 1666 | self.assertTrue(tree.branch.tags.has_tag('upstream-0.2-1')) | 1668 | self.assertTrue(tree.branch.tags.has_tag('upstream-0.2-1')) |
582 | @@ -1699,7 +1701,7 @@ | |||
583 | 1699 | # We don't add the new file upstream, as the new file id would | 1701 | # We don't add the new file upstream, as the new file id would |
584 | 1700 | # be picked up from there. | 1702 | # be picked up from there. |
585 | 1701 | upstream_rev2 = upstream_tree.commit("two") | 1703 | upstream_rev2 = upstream_tree.commit("two") |
587 | 1702 | db.merge_upstream([builder.tar_name()], "package", | 1704 | db.merge_upstream([(builder.tar_name(), None)], "package", |
588 | 1703 | version2.upstream_version, | 1705 | version2.upstream_version, |
589 | 1704 | version1.upstream_version, | 1706 | version1.upstream_version, |
590 | 1705 | upstream_branch=upstream_tree.branch, | 1707 | upstream_branch=upstream_tree.branch, |
591 | @@ -1736,7 +1738,7 @@ | |||
592 | 1736 | # We don't add the new file upstream, as the new file id would | 1738 | # We don't add the new file upstream, as the new file id would |
593 | 1737 | # be picked up from there. | 1739 | # be picked up from there. |
594 | 1738 | upstream_rev2 = upstream_tree.commit("two") | 1740 | upstream_rev2 = upstream_tree.commit("two") |
596 | 1739 | db.merge_upstream([builder.tar_name()], "package", | 1741 | db.merge_upstream([(builder.tar_name(), None)], "package", |
597 | 1740 | version2.upstream_version, | 1742 | version2.upstream_version, |
598 | 1741 | version1.upstream_version, | 1743 | version1.upstream_version, |
599 | 1742 | upstream_branch=upstream_tree.branch, | 1744 | upstream_branch=upstream_tree.branch, |
600 | @@ -1769,7 +1771,7 @@ | |||
601 | 1769 | builder.add_upstream_file("a", "New a") | 1771 | builder.add_upstream_file("a", "New a") |
602 | 1770 | builder.add_upstream_file("b", "Renamed a") | 1772 | builder.add_upstream_file("b", "Renamed a") |
603 | 1771 | builder.build() | 1773 | builder.build() |
605 | 1772 | db.merge_upstream([builder.tar_name()], "packaging", | 1774 | db.merge_upstream([(builder.tar_name(), None)], "packaging", |
606 | 1773 | version2.upstream_version, version1.upstream_version) | 1775 | version2.upstream_version, version1.upstream_version) |
607 | 1774 | self.assertEqual("a-id", packaging_tree.path2id("b")) | 1776 | self.assertEqual("a-id", packaging_tree.path2id("b")) |
608 | 1775 | self.assertEqual("other-a-id", packaging_tree.path2id("a")) | 1777 | self.assertEqual("other-a-id", packaging_tree.path2id("a")) |
609 | 1776 | 1778 | ||
610 | === modified file 'tests/test_upstream.py' | |||
611 | --- tests/test_upstream.py 2011-06-14 14:07:21 +0000 | |||
612 | +++ tests/test_upstream.py 2011-06-23 21:47:20 +0000 | |||
613 | @@ -57,6 +57,9 @@ | |||
614 | 57 | UScanSource, | 57 | UScanSource, |
615 | 58 | extract_tarball_version, | 58 | extract_tarball_version, |
616 | 59 | ) | 59 | ) |
617 | 60 | from bzrlib.plugins.builddeb.util import ( | ||
618 | 61 | component_from_orig_tarball, | ||
619 | 62 | ) | ||
620 | 60 | from bzrlib.plugins.builddeb.upstream.branch import ( | 63 | from bzrlib.plugins.builddeb.upstream.branch import ( |
621 | 61 | get_export_upstream_revision, | 64 | get_export_upstream_revision, |
622 | 62 | get_snapshot_revision, | 65 | get_snapshot_revision, |
623 | @@ -803,7 +806,8 @@ | |||
624 | 803 | paths = (self.already_exists_in_target(target_dir) | 806 | paths = (self.already_exists_in_target(target_dir) |
625 | 804 | or self.provide_from_store_dir(target_dir)) | 807 | or self.provide_from_store_dir(target_dir)) |
626 | 805 | if paths is not None: | 808 | if paths is not None: |
628 | 806 | return paths | 809 | return [(p, component_from_orig_tarball(p, self.package, |
629 | 810 | self.version)) for p in paths] | ||
630 | 807 | raise MissingUpstreamTarball(self.package, self.version) | 811 | raise MissingUpstreamTarball(self.package, self.version) |
631 | 808 | 812 | ||
632 | 809 | 813 | ||
633 | 810 | 814 | ||
634 | === modified file 'tests/test_util.py' | |||
635 | --- tests/test_util.py 2011-06-15 15:33:08 +0000 | |||
636 | +++ tests/test_util.py 2011-06-23 21:47:20 +0000 | |||
637 | @@ -38,10 +38,10 @@ | |||
638 | 38 | BUILD_TYPE_NATIVE, | 38 | BUILD_TYPE_NATIVE, |
639 | 39 | BUILD_TYPE_NORMAL, | 39 | BUILD_TYPE_NORMAL, |
640 | 40 | ) | 40 | ) |
642 | 41 | from bzrlib.plugins.builddeb.errors import (MissingChangelogError, | 41 | from bzrlib.plugins.builddeb.errors import ( |
643 | 42 | MissingChangelogError, | ||
644 | 42 | AddChangelogError, | 43 | AddChangelogError, |
645 | 43 | InconsistentSourceFormatError, | 44 | InconsistentSourceFormatError, |
646 | 44 | MultipleUpstreamTarballsNotSupported, | ||
647 | 45 | NoPreviousUpload, | 45 | NoPreviousUpload, |
648 | 46 | ) | 46 | ) |
649 | 47 | from bzrlib.plugins.builddeb.tests import ( | 47 | from bzrlib.plugins.builddeb.tests import ( |
650 | @@ -50,6 +50,7 @@ | |||
651 | 50 | TestCaseWithTransport, | 50 | TestCaseWithTransport, |
652 | 51 | ) | 51 | ) |
653 | 52 | from bzrlib.plugins.builddeb.util import ( | 52 | from bzrlib.plugins.builddeb.util import ( |
654 | 53 | component_from_orig_tarball, | ||
655 | 53 | dget, | 54 | dget, |
656 | 54 | dget_changes, | 55 | dget_changes, |
657 | 55 | extract_orig_tarballs, | 56 | extract_orig_tarballs, |
658 | @@ -853,8 +854,10 @@ | |||
659 | 853 | f.write("Hi\n") | 854 | f.write("Hi\n") |
660 | 854 | finally: | 855 | finally: |
661 | 855 | f.close() | 856 | f.close() |
664 | 856 | tar_path = os.path.abspath("%s_%s.orig.tar.%s" % (package, version, | 857 | prefix = "%s_%s.orig" % (package, version) |
665 | 857 | compression)) | 858 | if part is not None: |
666 | 859 | prefix += "-%s" % part | ||
667 | 860 | tar_path = os.path.abspath(prefix + ".tar." + compression) | ||
668 | 858 | tf = tarfile.open(tar_path, 'w:%s' % compression) | 861 | tf = tarfile.open(tar_path, 'w:%s' % compression) |
669 | 859 | try: | 862 | try: |
670 | 860 | tf.add(basedir) | 863 | tf.add(basedir) |
671 | @@ -867,19 +870,45 @@ | |||
672 | 867 | def test_single_orig_tar_gz(self): | 870 | def test_single_orig_tar_gz(self): |
673 | 868 | tar_path = self.create_tarball("package", "0.1", "gz") | 871 | tar_path = self.create_tarball("package", "0.1", "gz") |
674 | 869 | os.mkdir("target") | 872 | os.mkdir("target") |
676 | 870 | extract_orig_tarballs([tar_path], "target", strip_components=1) | 873 | extract_orig_tarballs([(tar_path, None)], "target", |
677 | 874 | strip_components=1) | ||
678 | 871 | self.assertEquals(os.listdir("target"), ["README"]) | 875 | self.assertEquals(os.listdir("target"), ["README"]) |
679 | 872 | 876 | ||
680 | 873 | def test_single_orig_tar_bz2(self): | 877 | def test_single_orig_tar_bz2(self): |
681 | 874 | tar_path = self.create_tarball("package", "0.1", "bz2") | 878 | tar_path = self.create_tarball("package", "0.1", "bz2") |
682 | 875 | os.mkdir("target") | 879 | os.mkdir("target") |
684 | 876 | extract_orig_tarballs([tar_path], "target", strip_components=1) | 880 | extract_orig_tarballs([(tar_path, None)], "target", |
685 | 881 | strip_components=1) | ||
686 | 877 | self.assertEquals(os.listdir("target"), ["README"]) | 882 | self.assertEquals(os.listdir("target"), ["README"]) |
687 | 878 | 883 | ||
688 | 879 | def test_multiple_tarballs(self): | 884 | def test_multiple_tarballs(self): |
689 | 880 | base_tar_path = self.create_tarball("package", "0.1", "bz2") | 885 | base_tar_path = self.create_tarball("package", "0.1", "bz2") |
690 | 881 | tar_path_extra = self.create_tarball("package", "0.1", "bz2", part="extra") | 886 | tar_path_extra = self.create_tarball("package", "0.1", "bz2", part="extra") |
691 | 882 | os.mkdir("target") | 887 | os.mkdir("target") |
695 | 883 | self.assertRaises(MultipleUpstreamTarballsNotSupported, | 888 | extract_orig_tarballs([(base_tar_path, None), (tar_path_extra, "extra")], "target", |
696 | 884 | extract_orig_tarballs, | 889 | strip_components=1) |
697 | 885 | [base_tar_path, tar_path_extra], "target") | 890 | self.assertEquals(sorted(os.listdir("target")), |
698 | 891 | sorted(["README", "extra"])) | ||
699 | 892 | |||
700 | 893 | |||
701 | 894 | class ComponentFromOrigTarballTests(TestCase): | ||
702 | 895 | |||
703 | 896 | def test_base_tarball(self): | ||
704 | 897 | self.assertIs(None, | ||
705 | 898 | component_from_orig_tarball("foo_0.1.orig.tar.gz", "foo", "0.1")) | ||
706 | 899 | self.assertRaises(ValueError, | ||
707 | 900 | component_from_orig_tarball, "foo_0.1.orig.tar.gz", "bar", "0.1") | ||
708 | 901 | |||
709 | 902 | def test_invalid_extension(self): | ||
710 | 903 | self.assertRaises(ValueError, | ||
711 | 904 | component_from_orig_tarball, "foo_0.1.orig.unknown", "foo", "0.1") | ||
712 | 905 | |||
713 | 906 | def test_component(self): | ||
714 | 907 | self.assertEquals("comp", | ||
715 | 908 | component_from_orig_tarball("foo_0.1.orig-comp.tar.gz", "foo", "0.1")) | ||
716 | 909 | self.assertEquals("comp-dash", | ||
717 | 910 | component_from_orig_tarball("foo_0.1.orig-comp-dash.tar.gz", "foo", "0.1")) | ||
718 | 911 | |||
719 | 912 | def test_invalid_character(self): | ||
720 | 913 | self.assertRaises(ValueError, | ||
721 | 914 | component_from_orig_tarball, "foo_0.1.orig;.tar.gz", "foo", "0.1") | ||
722 | 886 | 915 | ||
723 | === modified file 'upstream/__init__.py' | |||
724 | --- upstream/__init__.py 2011-06-16 21:02:32 +0000 | |||
725 | +++ upstream/__init__.py 2011-06-23 21:47:20 +0000 | |||
726 | @@ -44,6 +44,7 @@ | |||
727 | 44 | ) | 44 | ) |
728 | 45 | from bzrlib.plugins.builddeb.repack_tarball import repack_tarball | 45 | from bzrlib.plugins.builddeb.repack_tarball import repack_tarball |
729 | 46 | from bzrlib.plugins.builddeb.util import ( | 46 | from bzrlib.plugins.builddeb.util import ( |
730 | 47 | component_from_orig_tarball, | ||
731 | 47 | export, | 48 | export, |
732 | 48 | tarball_name, | 49 | tarball_name, |
733 | 49 | ) | 50 | ) |
734 | @@ -395,7 +396,8 @@ | |||
735 | 395 | if in_target is not None: | 396 | if in_target is not None: |
736 | 396 | note("Upstream tarball already exists in build directory, " | 397 | note("Upstream tarball already exists in build directory, " |
737 | 397 | "using that") | 398 | "using that") |
739 | 398 | return in_target | 399 | return [(p, component_from_orig_tarball(p, |
740 | 400 | self.package, self.version)) for p in in_target] | ||
741 | 399 | if self.already_exists_in_store() is None: | 401 | if self.already_exists_in_store() is None: |
742 | 400 | if not os.path.exists(self.store_dir): | 402 | if not os.path.exists(self.store_dir): |
743 | 401 | os.makedirs(self.store_dir) | 403 | os.makedirs(self.store_dir) |
744 | @@ -410,7 +412,8 @@ | |||
745 | 410 | self.store_dir) | 412 | self.store_dir) |
746 | 411 | paths = self.provide_from_store_dir(target_dir) | 413 | paths = self.provide_from_store_dir(target_dir) |
747 | 412 | assert paths is not None | 414 | assert paths is not None |
749 | 413 | return paths | 415 | return [(p, component_from_orig_tarball(p, self.package, self.version)) |
750 | 416 | for p in paths] | ||
751 | 414 | 417 | ||
752 | 415 | def _gather_orig_files(self, path): | 418 | def _gather_orig_files(self, path): |
753 | 416 | prefix = "%s_%s.orig" % (self.package, self.version) | 419 | prefix = "%s_%s.orig" % (self.package, self.version) |
754 | 417 | 420 | ||
755 | === modified file 'upstream/pristinetar.py' | |||
756 | --- upstream/pristinetar.py 2011-06-15 15:08:01 +0000 | |||
757 | +++ upstream/pristinetar.py 2011-06-23 21:47:20 +0000 | |||
758 | @@ -130,6 +130,52 @@ | |||
759 | 130 | return "upstream-" + version | 130 | return "upstream-" + version |
760 | 131 | return "upstream-%s-%s" % (distro, version) | 131 | return "upstream-%s-%s" % (distro, version) |
761 | 132 | 132 | ||
762 | 133 | def tag_version(self, version, revid): | ||
763 | 134 | """Tags the upstream branch's last revision with an upstream version. | ||
764 | 135 | |||
765 | 136 | Sets a tag on the last revision of the upstream branch and on the main | ||
766 | 137 | branch with a tag that refers to the upstream part of the version | ||
767 | 138 | provided. | ||
768 | 139 | |||
769 | 140 | :param version: the upstream part of the version number to derive the | ||
770 | 141 | tag name from. | ||
771 | 142 | :param revid: the revid to associate the tag with, or None for the | ||
772 | 143 | tip of self.pristine_upstream_branch. | ||
773 | 144 | :return The tag name, revid of the added tag. | ||
774 | 145 | """ | ||
775 | 146 | assert isinstance(version, str) | ||
776 | 147 | tag_name = self.tag_name(version) | ||
777 | 148 | self.branch.tags.set_tag(tag_name, revid) | ||
778 | 149 | return tag_name, revid | ||
779 | 150 | |||
780 | 151 | def import_component_tarball(self, package, version, tree, component=None, | ||
781 | 152 | md5=None, tarball=None, author=None, timestamp=None, | ||
782 | 153 | parent_ids=None): | ||
783 | 154 | """Import a tarball. | ||
784 | 155 | |||
785 | 156 | :param package: Package name | ||
786 | 157 | :param version: Upstream version | ||
787 | 158 | :param component: Component name (None for base) | ||
788 | 159 | """ | ||
789 | 160 | if component is not None: | ||
790 | 161 | raise BzrError("Importing non-base tarballs not yet supported") | ||
791 | 162 | tree.set_parent_ids(parent_ids) | ||
792 | 163 | revprops = {} | ||
793 | 164 | if md5 is not None: | ||
794 | 165 | revprops["deb-md5"] = md5 | ||
795 | 166 | delta_revprops = self.create_delta_revprops(tree, tarball) | ||
796 | 167 | revprops.update(delta_revprops) | ||
797 | 168 | if author is not None: | ||
798 | 169 | revprops['authors'] = author | ||
799 | 170 | timezone = None | ||
800 | 171 | if timestamp is not None: | ||
801 | 172 | timezone = timestamp[1] | ||
802 | 173 | timestamp = timestamp[0] | ||
803 | 174 | revid = tree.commit("Import upstream version %s" % (version,), | ||
804 | 175 | revprops=revprops, timestamp=timestamp, timezone=timezone) | ||
805 | 176 | tag_name, _ = self.tag_version(version, revid=revid) | ||
806 | 177 | return tag_name, revid | ||
807 | 178 | |||
808 | 133 | def fetch_tarball(self, package, version, target_dir): | 179 | def fetch_tarball(self, package, version, target_dir): |
809 | 134 | revid = self.version_as_revision(package, version) | 180 | revid = self.version_as_revision(package, version) |
810 | 135 | try: | 181 | try: |
811 | @@ -166,7 +212,7 @@ | |||
812 | 166 | return True | 212 | return True |
813 | 167 | if len(tarballs) != 1: | 213 | if len(tarballs) != 1: |
814 | 168 | raise MultipleUpstreamTarballsNotSupported() | 214 | raise MultipleUpstreamTarballsNotSupported() |
816 | 169 | (filename, md5) = tarballs[0] | 215 | (filename, component, md5) = tarballs[0] |
817 | 170 | rev = self.branch.repository.get_revision(revid) | 216 | rev = self.branch.repository.get_revision(revid) |
818 | 171 | try: | 217 | try: |
819 | 172 | return rev.properties['deb-md5'] == md5 | 218 | return rev.properties['deb-md5'] == md5 |
820 | 173 | 219 | ||
821 | === modified file 'util.py' | |||
822 | --- util.py 2011-06-15 01:28:19 +0000 | |||
823 | +++ util.py 2011-06-23 21:47:20 +0000 | |||
824 | @@ -66,7 +66,6 @@ | |||
825 | 66 | MissingChangelogError, | 66 | MissingChangelogError, |
826 | 67 | AddChangelogError, | 67 | AddChangelogError, |
827 | 68 | InconsistentSourceFormatError, | 68 | InconsistentSourceFormatError, |
828 | 69 | MultipleUpstreamTarballsNotSupported, | ||
829 | 70 | NoPreviousUpload, | 69 | NoPreviousUpload, |
830 | 71 | TarFailed, | 70 | TarFailed, |
831 | 72 | UnableToFindPreviousUpload, | 71 | UnableToFindPreviousUpload, |
832 | @@ -685,24 +684,64 @@ | |||
833 | 685 | return BUILD_TYPE_NORMAL | 684 | return BUILD_TYPE_NORMAL |
834 | 686 | 685 | ||
835 | 687 | 686 | ||
841 | 688 | def extract_orig_tarballs(tarballs, target, strip_components=None): | 687 | def component_from_orig_tarball(tarball_filename, package, version): |
842 | 689 | """Extract orig tarballs to a directory. | 688 | tarball_filename = os.path.basename(tarball_filename) |
843 | 690 | 689 | prefix = "%s_%s.orig" % (package, version) | |
844 | 691 | :param tarballs: List of tarball filenames | 690 | if not tarball_filename.startswith(prefix): |
845 | 692 | :param target: Target directory (must already exist) | 691 | raise ValueError( |
846 | 692 | "invalid orig tarball file %s does not have expected prefix %s" % ( | ||
847 | 693 | tarball_filename, prefix)) | ||
848 | 694 | base = tarball_filename[len(prefix):] | ||
849 | 695 | for ext in (".tar.gz", ".tar.bz2", ".tar.lzma", ".tar.xz"): | ||
850 | 696 | if tarball_filename.endswith(ext): | ||
851 | 697 | base = base[:-len(ext)] | ||
852 | 698 | break | ||
853 | 699 | else: | ||
854 | 700 | raise ValueError( | ||
855 | 701 | "orig tarball file %s has unknown extension" % tarball_filename) | ||
856 | 702 | if base == "": | ||
857 | 703 | return None | ||
858 | 704 | elif base[0] == "-": | ||
859 | 705 | # Extra component | ||
860 | 706 | return base[1:] | ||
861 | 707 | else: | ||
862 | 708 | raise ValueError("Invalid extra characters in tarball filename %s" % | ||
863 | 709 | tarball_filename) | ||
864 | 710 | |||
865 | 711 | |||
866 | 712 | def extract_orig_tarball(tarball_filename, component, target, strip_components=None): | ||
867 | 713 | """Extract an orig tarball. | ||
868 | 714 | |||
869 | 715 | :param tarball: Path to the tarball | ||
870 | 716 | :param component: Component name (or None for top-level) | ||
871 | 717 | :param target: Target path | ||
872 | 718 | :param strip_components: Optional number of components to strip | ||
873 | 693 | """ | 719 | """ |
874 | 694 | if len(tarballs) != 1: | ||
875 | 695 | raise MultipleUpstreamTarballsNotSupported() | ||
876 | 696 | tarball_filename = tarballs[0] | ||
877 | 697 | tar_args = ["tar"] | 720 | tar_args = ["tar"] |
878 | 698 | if tarball_filename.endswith(".tar.bz2"): | 721 | if tarball_filename.endswith(".tar.bz2"): |
879 | 699 | tar_args.append('xjf') | 722 | tar_args.append('xjf') |
880 | 700 | else: | 723 | else: |
881 | 701 | tar_args.append('xzf') | 724 | tar_args.append('xzf') |
883 | 702 | tar_args.extend([tarball_filename, "-C", target]) | 725 | if component is not None: |
884 | 726 | target_path = os.path.join(target, component) | ||
885 | 727 | os.mkdir(target_path) | ||
886 | 728 | else: | ||
887 | 729 | target_path = target | ||
888 | 730 | tar_args.extend([tarball_filename, "-C", target_path]) | ||
889 | 703 | if strip_components is not None: | 731 | if strip_components is not None: |
890 | 704 | tar_args.extend(["--strip-components", "1"]) | 732 | tar_args.extend(["--strip-components", "1"]) |
891 | 705 | proc = subprocess.Popen(tar_args, preexec_fn=subprocess_setup) | 733 | proc = subprocess.Popen(tar_args, preexec_fn=subprocess_setup) |
892 | 706 | proc.communicate() | 734 | proc.communicate() |
893 | 707 | if proc.returncode != 0: | 735 | if proc.returncode != 0: |
894 | 708 | raise TarFailed("extract", tarball_filename) | 736 | raise TarFailed("extract", tarball_filename) |
895 | 737 | |||
896 | 738 | |||
897 | 739 | def extract_orig_tarballs(tarballs, target, strip_components=None): | ||
898 | 740 | """Extract orig tarballs to a directory. | ||
899 | 741 | |||
900 | 742 | :param tarballs: List of tarball filenames | ||
901 | 743 | :param target: Target directory (must already exist) | ||
902 | 744 | """ | ||
903 | 745 | for tarball_filename, component in tarballs: | ||
904 | 746 | extract_orig_tarball(tarball_filename, component, target, | ||
905 | 747 | strip_components=strip_components) |
Hi,
This looks fine.
What's your plan for representing the multiple upstream tarballs in
the tree and revision history?
Thanks,
James