Merge lp:~jelmer/bzr-builddeb/version-as-revisions into lp:bzr-builddeb
- version-as-revisions
- Merge into trunk
Proposed by
Jelmer Vernooij
Status: | Merged |
---|---|
Approved by: | James Westby |
Approved revision: | 620 |
Merged at revision: | 626 |
Proposed branch: | lp:~jelmer/bzr-builddeb/version-as-revisions |
Merge into: | lp:bzr-builddeb |
Diff against target: |
863 lines (+240/-119) 8 files modified
cmds.py (+15/-15) import_dsc.py (+60/-34) merge_package.py (+9/-4) tests/test_import_dsc.py (+41/-32) tests/test_upstream.py (+38/-7) upstream/__init__.py (+5/-4) upstream/branch.py (+12/-2) upstream/pristinetar.py (+60/-21) |
To merge this branch: | bzr merge lp:~jelmer/bzr-builddeb/version-as-revisions |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby | Approve | ||
Review via email: mp+77058@code.launchpad.net |
Commit message
Description of the change
Change the UpstreamSource API to support providing multiple upstream revisions - in case there are multiple components.
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-09-09 13:20:42 +0000 | |||
3 | +++ cmds.py 2011-09-26 22:30:28 +0000 | |||
4 | @@ -556,7 +556,7 @@ | |||
5 | 556 | 'entry yourself, review the merge, and then commit.') | 556 | 'entry yourself, review the merge, and then commit.') |
6 | 557 | 557 | ||
7 | 558 | def _do_merge(self, tree, tarball_filenames, package, version, | 558 | def _do_merge(self, tree, tarball_filenames, package, version, |
9 | 559 | current_version, upstream_branch, upstream_revision, merge_type, | 559 | current_version, upstream_branch, upstream_revisions, merge_type, |
10 | 560 | force): | 560 | force): |
11 | 561 | db = DistributionBranch(tree.branch, tree.branch, tree=tree) | 561 | db = DistributionBranch(tree.branch, tree.branch, tree=tree) |
12 | 562 | dbs = DistributionBranchSet() | 562 | dbs = DistributionBranchSet() |
13 | @@ -565,7 +565,7 @@ | |||
14 | 565 | in tarball_filenames] | 565 | in tarball_filenames] |
15 | 566 | conflicts = db.merge_upstream(tarballs, package, version, | 566 | conflicts = db.merge_upstream(tarballs, package, version, |
16 | 567 | current_version, upstream_branch=upstream_branch, | 567 | current_version, upstream_branch=upstream_branch, |
18 | 568 | upstream_revision=upstream_revision, | 568 | upstream_revisions=upstream_revisions, |
19 | 569 | merge_type=merge_type, force=force) | 569 | merge_type=merge_type, force=force) |
20 | 570 | return conflicts | 570 | return conflicts |
21 | 571 | 571 | ||
22 | @@ -712,15 +712,15 @@ | |||
23 | 712 | raise BzrCommandError("merge-upstream takes only a " | 712 | raise BzrCommandError("merge-upstream takes only a " |
24 | 713 | "single --revision") | 713 | "single --revision") |
25 | 714 | upstream_revspec = revision[0] | 714 | upstream_revspec = revision[0] |
28 | 715 | upstream_revision = upstream_revspec.as_revision_id( | 715 | upstream_revisions = { None: upstream_revspec.as_revision_id( |
29 | 716 | upstream_branch) | 716 | upstream_branch) } |
30 | 717 | else: | 717 | else: |
32 | 718 | upstream_revision = None | 718 | upstream_revisions = None |
33 | 719 | 719 | ||
35 | 720 | if version is None and upstream_revision is not None: | 720 | if version is None and upstream_revisions is not None: |
36 | 721 | # Look up the version from the upstream revision | 721 | # Look up the version from the upstream revision |
37 | 722 | version = upstream_branch_source.get_version(package, | 722 | version = upstream_branch_source.get_version(package, |
39 | 723 | current_version, upstream_revision) | 723 | current_version, upstream_revisions) |
40 | 724 | elif version is None and primary_upstream_source is not None: | 724 | elif version is None and primary_upstream_source is not None: |
41 | 725 | version = primary_upstream_source.get_latest_version( | 725 | version = primary_upstream_source.get_latest_version( |
42 | 726 | package, current_version) | 726 | package, current_version) |
43 | @@ -735,9 +735,9 @@ | |||
44 | 735 | assert isinstance(version, str) | 735 | assert isinstance(version, str) |
45 | 736 | note("Using version string %s." % (version)) | 736 | note("Using version string %s." % (version)) |
46 | 737 | # Look up the revision id from the version string | 737 | # Look up the revision id from the version string |
48 | 738 | if upstream_revision is None and upstream_branch_source is not None: | 738 | if upstream_revisions is None and upstream_branch_source is not None: |
49 | 739 | try: | 739 | try: |
51 | 740 | upstream_revision = upstream_branch_source.version_as_revision( | 740 | upstream_revisions = upstream_branch_source.version_as_revisions( |
52 | 741 | package, version) | 741 | package, version) |
53 | 742 | except PackageVersionNotPresent: | 742 | except PackageVersionNotPresent: |
54 | 743 | raise BzrCommandError( | 743 | raise BzrCommandError( |
55 | @@ -753,10 +753,10 @@ | |||
56 | 753 | v3 = (source_format in [ | 753 | v3 = (source_format in [ |
57 | 754 | FORMAT_3_0_QUILT, FORMAT_3_0_NATIVE]) | 754 | FORMAT_3_0_QUILT, FORMAT_3_0_NATIVE]) |
58 | 755 | tarball_filenames = self._get_tarballs(config, tree, package, | 755 | tarball_filenames = self._get_tarballs(config, tree, package, |
60 | 756 | version, upstream_branch, upstream_revision, v3, | 756 | version, upstream_branch, upstream_revisions, v3, |
61 | 757 | locations) | 757 | locations) |
62 | 758 | conflicts = self._do_merge(tree, tarball_filenames, package, | 758 | conflicts = self._do_merge(tree, tarball_filenames, package, |
64 | 759 | version, current_version, upstream_branch, upstream_revision, | 759 | version, current_version, upstream_branch, upstream_revisions, |
65 | 760 | merge_type, force) | 760 | merge_type, force) |
66 | 761 | if (current_version is not None and | 761 | if (current_version is not None and |
67 | 762 | Version(current_version) >= Version(version)): | 762 | Version(current_version) >= Version(version)): |
68 | @@ -886,9 +886,9 @@ | |||
69 | 886 | "sure it is tagged as %r." % (last_version, | 886 | "sure it is tagged as %r." % (last_version, |
70 | 887 | db.pristine_upstream_source.tag_name( | 887 | db.pristine_upstream_source.tag_name( |
71 | 888 | last_version.upstream_version))) | 888 | last_version.upstream_version))) |
73 | 889 | upstream_tip = db.pristine_upstream_source.version_as_revision( | 889 | upstream_tips = db.pristine_upstream_source.version_as_revisions( |
74 | 890 | changelog.package, last_version.upstream_version) | 890 | changelog.package, last_version.upstream_version) |
76 | 891 | db.extract_upstream_tree(upstream_tip, tempdir) | 891 | db.extract_upstream_tree(upstream_tips, tempdir) |
77 | 892 | else: | 892 | else: |
78 | 893 | db._create_empty_upstream_tree(tempdir) | 893 | db._create_empty_upstream_tree(tempdir) |
79 | 894 | self.import_many(db, files_list, orig_target) | 894 | self.import_many(db, files_list, orig_target) |
80 | @@ -966,7 +966,7 @@ | |||
81 | 966 | if upstream is not None: | 966 | if upstream is not None: |
82 | 967 | # See bug lp:309682 | 967 | # See bug lp:309682 |
83 | 968 | upstream.repository.fetch(branch.repository, parents[0]) | 968 | upstream.repository.fetch(branch.repository, parents[0]) |
85 | 969 | db.extract_upstream_tree(parents[0], tempdir) | 969 | db.extract_upstream_tree({ None: parents[0] }, tempdir) |
86 | 970 | else: | 970 | else: |
87 | 971 | db._create_empty_upstream_tree(tempdir) | 971 | db._create_empty_upstream_tree(tempdir) |
88 | 972 | tree = db.branch.basis_tree() | 972 | tree = db.branch.basis_tree() |
89 | @@ -983,7 +983,7 @@ | |||
90 | 983 | tarballs = [(location, None, md5sum_filename(location))] | 983 | tarballs = [(location, None, md5sum_filename(location))] |
91 | 984 | for (component, tag_name, revid) in db.import_upstream_tarballs( | 984 | for (component, tag_name, revid) in db.import_upstream_tarballs( |
92 | 985 | tarballs, None, version, parents, upstream_branch=upstream, | 985 | tarballs, None, version, parents, upstream_branch=upstream, |
94 | 986 | upstream_revision=upstream_revid): | 986 | upstream_revisions={ None: upstream_revid }): |
95 | 987 | if component is None: | 987 | if component is None: |
96 | 988 | self.outf.write('Imported %s as tag:%s.\n' % ( | 988 | self.outf.write('Imported %s as tag:%s.\n' % ( |
97 | 989 | location, tag_name)) | 989 | location, tag_name)) |
98 | 990 | 990 | ||
99 | === modified file 'import_dsc.py' | |||
100 | --- import_dsc.py 2011-09-09 13:20:42 +0000 | |||
101 | +++ import_dsc.py 2011-09-26 22:30:28 +0000 | |||
102 | @@ -60,6 +60,7 @@ | |||
103 | 60 | 60 | ||
104 | 61 | from bzrlib.plugins.builddeb.bzrtools_import import import_dir | 61 | from bzrlib.plugins.builddeb.bzrtools_import import import_dir |
105 | 62 | from bzrlib.plugins.builddeb.errors import ( | 62 | from bzrlib.plugins.builddeb.errors import ( |
106 | 63 | MultipleUpstreamTarballsNotSupported, | ||
107 | 63 | PackageVersionNotPresent, | 64 | PackageVersionNotPresent, |
108 | 64 | UpstreamAlreadyImported, | 65 | UpstreamAlreadyImported, |
109 | 65 | UpstreamBranchAlreadyMerged, | 66 | UpstreamBranchAlreadyMerged, |
110 | @@ -556,6 +557,7 @@ | |||
111 | 556 | tarballs=upstream_tarballs): | 557 | tarballs=upstream_tarballs): |
112 | 557 | return False | 558 | return False |
113 | 558 | 559 | ||
114 | 560 | |||
115 | 559 | up_branch = self.pristine_upstream_branch | 561 | up_branch = self.pristine_upstream_branch |
116 | 560 | up_branch.lock_read() | 562 | up_branch.lock_read() |
117 | 561 | try: | 563 | try: |
118 | @@ -563,10 +565,14 @@ | |||
119 | 563 | other_up_branch = branch.pristine_upstream_branch | 565 | other_up_branch = branch.pristine_upstream_branch |
120 | 564 | other_up_branch.lock_read() | 566 | other_up_branch.lock_read() |
121 | 565 | try: | 567 | try: |
122 | 568 | pristine_upstream_revids = branch.pristine_upstream_source.version_as_revisions(package, version) | ||
123 | 569 | if pristine_upstream_revids.keys() != [None]: | ||
124 | 570 | raise MultipleUpstreamTarballsNotSupported() | ||
125 | 571 | pristine_upstream_revid = pristine_upstream_revids[None] | ||
126 | 566 | graph = other_up_branch.repository.get_graph( | 572 | graph = other_up_branch.repository.get_graph( |
127 | 567 | up_branch.repository) | 573 | up_branch.repository) |
128 | 568 | return graph.is_ancestor(up_branch.last_revision(), | 574 | return graph.is_ancestor(up_branch.last_revision(), |
130 | 569 | branch.pristine_upstream_source.version_as_revision(package, version)) | 575 | pristine_upstream_revid) |
131 | 570 | finally: | 576 | finally: |
132 | 571 | other_up_branch.unlock() | 577 | other_up_branch.unlock() |
133 | 572 | finally: | 578 | finally: |
134 | @@ -680,7 +686,11 @@ | |||
135 | 680 | :param version: the upstream version string | 686 | :param version: the upstream version string |
136 | 681 | """ | 687 | """ |
137 | 682 | assert isinstance(version, str) | 688 | assert isinstance(version, str) |
139 | 683 | pull_revision = pull_branch.pristine_upstream_source.version_as_revision(package, version) | 689 | pull_revisions = pull_branch.pristine_upstream_source.version_as_revisions( |
140 | 690 | package, version) | ||
141 | 691 | if pull_revisions.keys() != [None]: | ||
142 | 692 | raise MultipleUpstreamTarballsNotSupported() | ||
143 | 693 | pull_revision = pull_revisions[None] | ||
144 | 684 | mutter("Pulling upstream part of %s from revision %s" % \ | 694 | mutter("Pulling upstream part of %s from revision %s" % \ |
145 | 685 | (version, pull_revision)) | 695 | (version, pull_revision)) |
146 | 686 | assert self.pristine_upstream_tree is not None, \ | 696 | assert self.pristine_upstream_tree is not None, \ |
147 | @@ -774,12 +784,17 @@ | |||
148 | 774 | break | 784 | break |
149 | 775 | real_parents = [p[2] for p in parents] | 785 | real_parents = [p[2] for p in parents] |
150 | 776 | if need_upstream_parent: | 786 | if need_upstream_parent: |
152 | 777 | parent_revid = self.pristine_upstream_source.version_as_revision(package, | 787 | upstream_revids = self.pristine_upstream_source.version_as_revisions(package, |
153 | 778 | version.upstream_version, tarballs) | 788 | version.upstream_version, tarballs) |
158 | 779 | if len(parents) > 0: | 789 | def key(a): |
159 | 780 | real_parents.insert(1, parent_revid) | 790 | if a is None: |
160 | 781 | else: | 791 | return None |
161 | 782 | real_parents = [parent_revid] | 792 | return a |
162 | 793 | for component in sorted(upstream_revids.keys(), key=key): | ||
163 | 794 | if len(real_parents) > 0: | ||
164 | 795 | real_parents.insert(1, upstream_revids[component]) | ||
165 | 796 | else: | ||
166 | 797 | real_parents = [upstream_revids[component]] | ||
167 | 783 | return real_parents | 798 | return real_parents |
168 | 784 | 799 | ||
169 | 785 | def _fetch_upstream_to_branch(self, revid): | 800 | def _fetch_upstream_to_branch(self, revid): |
170 | @@ -793,7 +808,7 @@ | |||
171 | 793 | 808 | ||
172 | 794 | def import_upstream(self, upstream_part, package, version, upstream_parents, | 809 | def import_upstream(self, upstream_part, package, version, upstream_parents, |
173 | 795 | upstream_tarballs, upstream_branch=None, | 810 | upstream_tarballs, upstream_branch=None, |
175 | 796 | upstream_revision=None, timestamp=None, author=None, | 811 | upstream_revisions=None, timestamp=None, author=None, |
176 | 797 | file_ids_from=None): | 812 | file_ids_from=None): |
177 | 798 | """Import an upstream part on to the upstream branch. | 813 | """Import an upstream part on to the upstream branch. |
178 | 799 | 814 | ||
179 | @@ -821,18 +836,23 @@ | |||
180 | 821 | other_branches = self.get_other_branches() | 836 | other_branches = self.get_other_branches() |
181 | 822 | ret = [] | 837 | ret = [] |
182 | 823 | for (tarball, component, md5) in upstream_tarballs: | 838 | for (tarball, component, md5) in upstream_tarballs: |
183 | 839 | if upstream_revisions is not None: | ||
184 | 840 | revid = upstream_revisions[component] | ||
185 | 841 | else: | ||
186 | 842 | revid = None | ||
187 | 824 | upstream_trees = [o.pristine_upstream_branch.basis_tree() | 843 | upstream_trees = [o.pristine_upstream_branch.basis_tree() |
188 | 825 | for o in other_branches] | 844 | for o in other_branches] |
189 | 826 | target_tree = None | 845 | target_tree = None |
190 | 827 | if upstream_branch is not None: | 846 | if upstream_branch is not None: |
193 | 828 | if upstream_revision is None: | 847 | if revid is None: |
194 | 829 | upstream_revision = upstream_branch.last_revision() | 848 | # FIXME: This is wrong for component tarballs |
195 | 849 | revid = upstream_branch.last_revision() | ||
196 | 830 | self.pristine_upstream_branch.fetch(upstream_branch, | 850 | self.pristine_upstream_branch.fetch(upstream_branch, |
198 | 831 | last_revision=upstream_revision) | 851 | last_revision=revid) |
199 | 832 | upstream_branch.tags.merge_to(self.pristine_upstream_branch.tags) | 852 | upstream_branch.tags.merge_to(self.pristine_upstream_branch.tags) |
201 | 833 | upstream_parents.append(upstream_revision) | 853 | upstream_parents.append(revid) |
202 | 834 | target_tree = self.pristine_upstream_branch.repository.revision_tree( | 854 | target_tree = self.pristine_upstream_branch.repository.revision_tree( |
204 | 835 | upstream_revision) | 855 | revid) |
205 | 836 | if file_ids_from is not None: | 856 | if file_ids_from is not None: |
206 | 837 | upstream_trees = file_ids_from + upstream_trees | 857 | upstream_trees = file_ids_from + upstream_trees |
207 | 838 | if self.tree: | 858 | if self.tree: |
208 | @@ -858,15 +878,16 @@ | |||
209 | 858 | finally: | 878 | finally: |
210 | 859 | self_tree.unlock() | 879 | self_tree.unlock() |
211 | 860 | (tag, revid) = self.pristine_upstream_source.import_component_tarball( | 880 | (tag, revid) = self.pristine_upstream_source.import_component_tarball( |
214 | 861 | package, version, self.pristine_upstream_tree, upstream_parents, component, | 881 | package, version, self.pristine_upstream_tree, upstream_parents, |
215 | 862 | md5, tarball, author=author, timestamp=timestamp) | 882 | component, md5, tarball, author=author, timestamp=timestamp) |
216 | 883 | self.pristine_upstream_branch.generate_revision_history(revid) | ||
217 | 863 | ret.append((component, tag, revid)) | 884 | ret.append((component, tag, revid)) |
218 | 864 | self.branch.fetch(self.pristine_upstream_branch) | 885 | self.branch.fetch(self.pristine_upstream_branch) |
219 | 865 | self.branch.tags.set_tag(tag, revid) | 886 | self.branch.tags.set_tag(tag, revid) |
220 | 866 | return ret | 887 | return ret |
221 | 867 | 888 | ||
222 | 868 | def import_upstream_tarballs(self, tarballs, package, version, parents, | 889 | def import_upstream_tarballs(self, tarballs, package, version, parents, |
224 | 869 | upstream_branch=None, upstream_revision=None): | 890 | upstream_branch=None, upstream_revisions=None): |
225 | 870 | """Import an upstream part to the upstream branch. | 891 | """Import an upstream part to the upstream branch. |
226 | 871 | 892 | ||
227 | 872 | :param tarballs: List of tarballs / components to extract | 893 | :param tarballs: List of tarballs / components to extract |
228 | @@ -876,7 +897,7 @@ | |||
229 | 876 | parents. | 897 | parents. |
230 | 877 | :param upstream_branch: An upstream branch to associate with the | 898 | :param upstream_branch: An upstream branch to associate with the |
231 | 878 | tarball. | 899 | tarball. |
233 | 879 | :param upstream_revision: Upstream revision id | 900 | :param upstream_revisions: Upstream revision ids dictionary |
234 | 880 | :param md5sum: hex digest of the md5sum of the tarball, if known. | 901 | :param md5sum: hex digest of the md5sum of the tarball, if known. |
235 | 881 | :return: list with (component, tag, revid) tuples | 902 | :return: list with (component, tag, revid) tuples |
236 | 882 | """ | 903 | """ |
237 | @@ -885,7 +906,7 @@ | |||
238 | 885 | return self.import_upstream(tarball_dir, package, version, parents, | 906 | return self.import_upstream(tarball_dir, package, version, parents, |
239 | 886 | tarballs, | 907 | tarballs, |
240 | 887 | upstream_branch=upstream_branch, | 908 | upstream_branch=upstream_branch, |
242 | 888 | upstream_revision=upstream_revision) | 909 | upstream_revisions=upstream_revisions) |
243 | 889 | finally: | 910 | finally: |
244 | 890 | shutil.rmtree(tarball_dir) | 911 | shutil.rmtree(tarball_dir) |
245 | 891 | 912 | ||
246 | @@ -1052,8 +1073,11 @@ | |||
247 | 1052 | pull_branch = pull_parents[1][0] | 1073 | pull_branch = pull_parents[1][0] |
248 | 1053 | pull_version = pull_parents[1][1] | 1074 | pull_version = pull_parents[1][1] |
249 | 1054 | if not pull_branch.is_version_native(pull_version): | 1075 | if not pull_branch.is_version_native(pull_version): |
251 | 1055 | pull_revid = pull_branch.pristine_upstream_source.version_as_revision( | 1076 | pull_revids = pull_branch.pristine_upstream_source.version_as_revisions( |
252 | 1056 | package, pull_version.upstream_version) | 1077 | package, pull_version.upstream_version) |
253 | 1078 | if pull_revids.keys() != [None]: | ||
254 | 1079 | raise MultipleUpstreamTarballsNotSupported() | ||
255 | 1080 | pull_revid = pull_revids[None] | ||
256 | 1057 | mutter("Initialising upstream from %s, version %s", | 1081 | mutter("Initialising upstream from %s, version %s", |
257 | 1058 | str(pull_branch), str(pull_version)) | 1082 | str(pull_branch), str(pull_version)) |
258 | 1059 | parents.append(pull_revid) | 1083 | parents.append(pull_revid) |
259 | @@ -1245,16 +1269,16 @@ | |||
260 | 1245 | finally: | 1269 | finally: |
261 | 1246 | extractor.cleanup() | 1270 | extractor.cleanup() |
262 | 1247 | 1271 | ||
264 | 1248 | def extract_upstream_tree(self, upstream_tip, basedir): | 1272 | def extract_upstream_tree(self, upstream_tips, basedir): |
265 | 1249 | """Extract upstream_tip to a tempdir as a working tree.""" | 1273 | """Extract upstream_tip to a tempdir as a working tree.""" |
266 | 1250 | # TODO: should stack rather than trying to use the repository, | 1274 | # TODO: should stack rather than trying to use the repository, |
267 | 1251 | # as that will be more efficient. | 1275 | # as that will be more efficient. |
268 | 1252 | # TODO: remove the _extract_upstream_tree alias below. | ||
269 | 1253 | to_location = os.path.join(basedir, "upstream") | 1276 | to_location = os.path.join(basedir, "upstream") |
270 | 1254 | # Use upstream_branch if it has been set, otherwise self.branch. | 1277 | # Use upstream_branch if it has been set, otherwise self.branch. |
271 | 1255 | source_branch = self.pristine_upstream_branch or self.branch | 1278 | source_branch = self.pristine_upstream_branch or self.branch |
272 | 1279 | assert upstream_tips.keys() == [None] | ||
273 | 1256 | dir_to = source_branch.bzrdir.sprout(to_location, | 1280 | dir_to = source_branch.bzrdir.sprout(to_location, |
275 | 1257 | revision_id=upstream_tip, | 1281 | revision_id=upstream_tips[None], |
276 | 1258 | accelerator_tree=self.tree) | 1282 | accelerator_tree=self.tree) |
277 | 1259 | try: | 1283 | try: |
278 | 1260 | self.pristine_upstream_tree = dir_to.open_workingtree() | 1284 | self.pristine_upstream_tree = dir_to.open_workingtree() |
279 | @@ -1263,8 +1287,6 @@ | |||
280 | 1263 | self.pristine_upstream_tree = dir_to.create_workingtree() | 1287 | self.pristine_upstream_tree = dir_to.create_workingtree() |
281 | 1264 | self.pristine_upstream_branch = self.pristine_upstream_tree.branch | 1288 | self.pristine_upstream_branch = self.pristine_upstream_tree.branch |
282 | 1265 | 1289 | ||
283 | 1266 | _extract_upstream_tree = extract_upstream_tree | ||
284 | 1267 | |||
285 | 1268 | def _create_empty_upstream_tree(self, basedir): | 1290 | def _create_empty_upstream_tree(self, basedir): |
286 | 1269 | to_location = os.path.join(basedir, "upstream") | 1291 | to_location = os.path.join(basedir, "upstream") |
287 | 1270 | to_transport = get_transport(to_location) | 1292 | to_transport = get_transport(to_location) |
288 | @@ -1314,7 +1336,7 @@ | |||
289 | 1314 | assert isinstance(previous_version, str), \ | 1336 | assert isinstance(previous_version, str), \ |
290 | 1315 | "Should pass upstream version as str, not Version." | 1337 | "Should pass upstream version as str, not Version." |
291 | 1316 | try: | 1338 | try: |
293 | 1317 | upstream_tip = self.pristine_upstream_source.version_as_revision( | 1339 | upstream_tips = self.pristine_upstream_source.version_as_revisions( |
294 | 1318 | package, previous_version) | 1340 | package, previous_version) |
295 | 1319 | except PackageVersionNotPresent: | 1341 | except PackageVersionNotPresent: |
296 | 1320 | raise BzrCommandError("Unable to find the tag for the " | 1342 | raise BzrCommandError("Unable to find the tag for the " |
297 | @@ -1322,10 +1344,16 @@ | |||
298 | 1322 | "%s" % ( | 1344 | "%s" % ( |
299 | 1323 | previous_version, | 1345 | previous_version, |
300 | 1324 | self.pristine_upstream_source.tag_name(previous_version))) | 1346 | self.pristine_upstream_source.tag_name(previous_version))) |
302 | 1325 | self.extract_upstream_tree(upstream_tip, tempdir) | 1347 | self.extract_upstream_tree(upstream_tips, tempdir) |
303 | 1348 | |||
304 | 1349 | def has_merged_upstream_revisions(self, this_revision, upstream_repository, upstream_revisions): | ||
305 | 1350 | graph = self.branch.repository.get_graph( | ||
306 | 1351 | other_repository=upstream_repository) | ||
307 | 1352 | return all(graph.is_ancestor(upstream_revision, this_revision) | ||
308 | 1353 | for upstream_revision in upstream_revisions.values()) | ||
309 | 1326 | 1354 | ||
310 | 1327 | def merge_upstream(self, tarball_filenames, package, version, previous_version, | 1355 | def merge_upstream(self, tarball_filenames, package, version, previous_version, |
312 | 1328 | upstream_branch=None, upstream_revision=None, merge_type=None, | 1356 | upstream_branch=None, upstream_revisions=None, merge_type=None, |
313 | 1329 | force=False): | 1357 | force=False): |
314 | 1330 | assert isinstance(version, str), \ | 1358 | assert isinstance(version, str), \ |
315 | 1331 | "Should pass version as str not %s" % str(type(version)) | 1359 | "Should pass version as str not %s" % str(type(version)) |
316 | @@ -1344,12 +1372,10 @@ | |||
317 | 1344 | upstream_branch.lock_read() | 1372 | upstream_branch.lock_read() |
318 | 1345 | try: | 1373 | try: |
319 | 1346 | if upstream_branch is not None: | 1374 | if upstream_branch is not None: |
326 | 1347 | if upstream_revision is None: | 1375 | if upstream_revisions is None: |
327 | 1348 | upstream_revision = upstream_branch.last_revision() | 1376 | upstream_revisions = { None: upstream_branch.last_revision() } |
328 | 1349 | graph = self.branch.repository.get_graph( | 1377 | if (not force and |
329 | 1350 | other_repository=upstream_branch.repository) | 1378 | self.has_merged_upstream_revisions(self.branch.last_revision(), upstream_branch.repository, upstream_revisions)): |
324 | 1351 | if not force and graph.is_ancestor(upstream_revision, | ||
325 | 1352 | self.branch.last_revision()): | ||
330 | 1353 | raise UpstreamBranchAlreadyMerged | 1379 | raise UpstreamBranchAlreadyMerged |
331 | 1354 | upstream_tarballs = [ | 1380 | upstream_tarballs = [ |
332 | 1355 | (os.path.abspath(fn), component, md5sum_filename(fn)) for | 1381 | (os.path.abspath(fn), component, md5sum_filename(fn)) for |
333 | @@ -1364,7 +1390,7 @@ | |||
334 | 1364 | for (component, tag, revid) in self.import_upstream(tarball_dir, | 1390 | for (component, tag, revid) in self.import_upstream(tarball_dir, |
335 | 1365 | package, version, parents, upstream_tarballs=upstream_tarballs, | 1391 | package, version, parents, upstream_tarballs=upstream_tarballs, |
336 | 1366 | upstream_branch=upstream_branch, | 1392 | upstream_branch=upstream_branch, |
338 | 1367 | upstream_revision=upstream_revision): | 1393 | upstream_revisions=upstream_revisions): |
339 | 1368 | self._fetch_upstream_to_branch(revid) | 1394 | self._fetch_upstream_to_branch(revid) |
340 | 1369 | finally: | 1395 | finally: |
341 | 1370 | shutil.rmtree(tarball_dir) | 1396 | shutil.rmtree(tarball_dir) |
342 | 1371 | 1397 | ||
343 | === modified file 'merge_package.py' | |||
344 | --- merge_package.py 2011-06-15 13:21:22 +0000 | |||
345 | +++ merge_package.py 2011-09-26 22:30:28 +0000 | |||
346 | @@ -31,7 +31,9 @@ | |||
347 | 31 | from debian_bundle.changelog import Version | 31 | from debian_bundle.changelog import Version |
348 | 32 | 32 | ||
349 | 33 | from bzrlib.plugins.builddeb.errors import ( | 33 | from bzrlib.plugins.builddeb.errors import ( |
351 | 34 | SharedUpstreamConflictsWithTargetPackaging) | 34 | MultipleUpstreamTarballsNotSupported, |
352 | 35 | SharedUpstreamConflictsWithTargetPackaging, | ||
353 | 36 | ) | ||
354 | 35 | from bzrlib.plugins.builddeb.import_dsc import DistributionBranch | 37 | from bzrlib.plugins.builddeb.import_dsc import DistributionBranch |
355 | 36 | from bzrlib.plugins.builddeb.util import find_changelog | 38 | from bzrlib.plugins.builddeb.util import find_changelog |
356 | 37 | 39 | ||
357 | @@ -59,8 +61,11 @@ | |||
358 | 59 | for branch in (source, target): | 61 | for branch in (source, target): |
359 | 60 | db = DistributionBranch(branch, branch) | 62 | db = DistributionBranch(branch, branch) |
360 | 61 | uver = _latest_version(branch).upstream_version | 63 | uver = _latest_version(branch).upstream_version |
363 | 62 | results.append((Version(uver), | 64 | upstream_revids = db.pristine_upstream_source.version_as_revisions(None, uver) |
364 | 63 | db.pristine_upstream_source.version_as_revision(None, uver))) | 65 | if upstream_revids.keys() != [None]: |
365 | 66 | raise MultipleUpstreamTarballsNotSupported() | ||
366 | 67 | upstream_revid = upstream_revids[None] | ||
367 | 68 | results.append((Version(uver), upstream_revid)) | ||
368 | 64 | 69 | ||
369 | 65 | return results | 70 | return results |
370 | 66 | 71 | ||
371 | @@ -136,7 +141,7 @@ | |||
372 | 136 | try: | 141 | try: |
373 | 137 | # Extract the merge target's upstream tree into a temporary | 142 | # Extract the merge target's upstream tree into a temporary |
374 | 138 | # directory. | 143 | # directory. |
376 | 139 | db.extract_upstream_tree(ut_revid, tempdir) | 144 | db.extract_upstream_tree({None: ut_revid}, tempdir) |
377 | 140 | tmp_target_utree = db.pristine_upstream_tree | 145 | tmp_target_utree = db.pristine_upstream_tree |
378 | 141 | 146 | ||
379 | 142 | # Merge upstream branch tips to obtain a shared upstream parent. | 147 | # Merge upstream branch tips to obtain a shared upstream parent. |
380 | 143 | 148 | ||
381 | === modified file 'tests/test_import_dsc.py' | |||
382 | --- tests/test_import_dsc.py 2011-09-09 13:20:42 +0000 | |||
383 | +++ tests/test_import_dsc.py 2011-09-26 22:30:28 +0000 | |||
384 | @@ -213,14 +213,15 @@ | |||
385 | 213 | db.tag_version(version) | 213 | db.tag_version(version) |
386 | 214 | self.assertEqual(db.revid_of_version(version), revid) | 214 | self.assertEqual(db.revid_of_version(version), revid) |
387 | 215 | 215 | ||
389 | 216 | def test_upstream_version_as_revid(self): | 216 | def test_upstream_versions_as_revid(self): |
390 | 217 | db = self.db1 | 217 | db = self.db1 |
391 | 218 | tree = self.up_tree1 | 218 | tree = self.up_tree1 |
392 | 219 | version = "0.1" | 219 | version = "0.1" |
393 | 220 | revid = tree.commit("one") | 220 | revid = tree.commit("one") |
394 | 221 | db.tag_upstream_version(version) | 221 | db.tag_upstream_version(version) |
395 | 222 | self.assertEqual( | 222 | self.assertEqual( |
397 | 223 | db.pristine_upstream_source.version_as_revision("package", version), revid) | 223 | db.pristine_upstream_source.version_as_revisions("package", version), |
398 | 224 | { None: revid }) | ||
399 | 224 | 225 | ||
400 | 225 | def test_contained_versions(self): | 226 | def test_contained_versions(self): |
401 | 226 | db = self.db1 | 227 | db = self.db1 |
402 | @@ -710,8 +711,8 @@ | |||
403 | 710 | self.assertEqual(self.tree2.branch.last_revision(), revid) | 711 | self.assertEqual(self.tree2.branch.last_revision(), revid) |
404 | 711 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) | 712 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) |
405 | 712 | self.assertEqual(self.db2.revid_of_version(version), revid) | 713 | self.assertEqual(self.db2.revid_of_version(version), revid) |
408 | 713 | self.assertEqual(self.db2.pristine_upstream_source.version_as_revision( | 714 | self.assertEqual(self.db2.pristine_upstream_source.version_as_revisions( |
409 | 714 | "package", version.upstream_version), up_revid) | 715 | "package", version.upstream_version), {None: up_revid}) |
410 | 715 | 716 | ||
411 | 716 | def test_pull_from_lesser_branch_with_upstream(self): | 717 | def test_pull_from_lesser_branch_with_upstream(self): |
412 | 717 | version = Version("0.1-1") | 718 | version = Version("0.1-1") |
413 | @@ -726,8 +727,8 @@ | |||
414 | 726 | self.assertEqual(self.tree2.branch.last_revision(), revid) | 727 | self.assertEqual(self.tree2.branch.last_revision(), revid) |
415 | 727 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) | 728 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) |
416 | 728 | self.assertEqual(self.db2.revid_of_version(version), revid) | 729 | self.assertEqual(self.db2.revid_of_version(version), revid) |
419 | 729 | self.assertEqual(self.db2.pristine_upstream_source.version_as_revision( | 730 | self.assertEqual(self.db2.pristine_upstream_source.version_as_revisions( |
420 | 730 | "package", version.upstream_version), up_revid) | 731 | "package", version.upstream_version), {None: up_revid}) |
421 | 731 | 732 | ||
422 | 732 | def test_pull_upstream_from_branch(self): | 733 | def test_pull_upstream_from_branch(self): |
423 | 733 | version = "0.1" | 734 | version = "0.1" |
424 | @@ -737,8 +738,9 @@ | |||
425 | 737 | self.assertNotEqual(self.up_tree2.branch.last_revision(), up_revid) | 738 | self.assertNotEqual(self.up_tree2.branch.last_revision(), up_revid) |
426 | 738 | self.db2.pull_upstream_from_branch(self.db1, "package", version) | 739 | self.db2.pull_upstream_from_branch(self.db1, "package", version) |
427 | 739 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) | 740 | self.assertEqual(self.up_tree2.branch.last_revision(), up_revid) |
430 | 740 | self.assertEqual(self.db2.pristine_upstream_source.version_as_revision("package", version), | 741 | self.assertEqual( |
431 | 741 | up_revid) | 742 | self.db2.pristine_upstream_source.version_as_revisions("package", version), |
432 | 743 | {None: up_revid}) | ||
433 | 742 | 744 | ||
434 | 743 | def check_changes(self, changes, added=[], removed=[], modified=[], | 745 | def check_changes(self, changes, added=[], removed=[], modified=[], |
435 | 744 | renamed=[]): | 746 | renamed=[]): |
436 | @@ -794,8 +796,8 @@ | |||
437 | 794 | branch = tree.branch | 796 | branch = tree.branch |
438 | 795 | rh = branch.revision_history() | 797 | rh = branch.revision_history() |
439 | 796 | self.assertEqual(len(rh), 1) | 798 | self.assertEqual(len(rh), 1) |
442 | 797 | self.assertEqual(self.db1.pristine_upstream_source.version_as_revision( | 799 | self.assertEqual(self.db1.pristine_upstream_source.version_as_revisions( |
443 | 798 | "package", version.upstream_version), rh[0]) | 800 | "package", version.upstream_version), {None: rh[0]}) |
444 | 799 | rev = branch.repository.get_revision(rh[0]) | 801 | rev = branch.repository.get_revision(rh[0]) |
445 | 800 | self.assertEqual(rev.message, | 802 | self.assertEqual(rev.message, |
446 | 801 | "Import upstream version %s" % str(version.upstream_version)) | 803 | "Import upstream version %s" % str(version.upstream_version)) |
447 | @@ -833,7 +835,9 @@ | |||
448 | 833 | rh = branch.revision_history() | 835 | rh = branch.revision_history() |
449 | 834 | self.assertEqual(len(rh), 2) | 836 | self.assertEqual(len(rh), 2) |
450 | 835 | self.assertEqual( | 837 | self.assertEqual( |
452 | 836 | self.db1.pristine_upstream_source.version_as_revision("package", version2.upstream_version), rh[1]) | 838 | self.db1.pristine_upstream_source.version_as_revisions( |
453 | 839 | "package", version2.upstream_version), | ||
454 | 840 | {None: rh[1]}) | ||
455 | 837 | rev = branch.repository.get_revision(rh[1]) | 841 | rev = branch.repository.get_revision(rh[1]) |
456 | 838 | self.assertEqual(rev.message, | 842 | self.assertEqual(rev.message, |
457 | 839 | "Import upstream version %s" % str(version2.upstream_version)) | 843 | "Import upstream version %s" % str(version2.upstream_version)) |
458 | @@ -864,8 +868,8 @@ | |||
459 | 864 | branch = tree.branch | 868 | branch = tree.branch |
460 | 865 | rh = branch.revision_history() | 869 | rh = branch.revision_history() |
461 | 866 | self.assertEqual(len(rh), 1) | 870 | self.assertEqual(len(rh), 1) |
464 | 867 | self.assertEqual(self.db1.pristine_upstream_source.version_as_revision( | 871 | self.assertEqual(self.db1.pristine_upstream_source.version_as_revisions( |
465 | 868 | "package", version.upstream_version), rh[0]) | 872 | "package", version.upstream_version), {None: rh[0]}) |
466 | 869 | rev = branch.repository.get_revision(rh[0]) | 873 | rev = branch.repository.get_revision(rh[0]) |
467 | 870 | self.assertEqual(rev.message, | 874 | self.assertEqual(rev.message, |
468 | 871 | "Import upstream version %s" % str(version.upstream_version)) | 875 | "Import upstream version %s" % str(version.upstream_version)) |
469 | @@ -892,8 +896,8 @@ | |||
470 | 892 | branch = tree.branch | 896 | branch = tree.branch |
471 | 893 | rh = branch.revision_history() | 897 | rh = branch.revision_history() |
472 | 894 | self.assertEqual(len(rh), 1) | 898 | self.assertEqual(len(rh), 1) |
475 | 895 | self.assertEqual(self.db1.pristine_upstream_source.version_as_revision( | 899 | self.assertEqual(self.db1.pristine_upstream_source.version_as_revisions( |
476 | 896 | "package", version.upstream_version), rh[0]) | 900 | "package", version.upstream_version), {None: rh[0]}) |
477 | 897 | rev = branch.repository.get_revision(rh[0]) | 901 | rev = branch.repository.get_revision(rh[0]) |
478 | 898 | self.assertEqual(rev.message, | 902 | self.assertEqual(rev.message, |
479 | 899 | "Import upstream version %s" % str(version.upstream_version)) | 903 | "Import upstream version %s" % str(version.upstream_version)) |
480 | @@ -941,8 +945,8 @@ | |||
481 | 941 | branch = tree.branch | 945 | branch = tree.branch |
482 | 942 | rh = branch.revision_history() | 946 | rh = branch.revision_history() |
483 | 943 | self.assertEqual(len(rh), 1) | 947 | self.assertEqual(len(rh), 1) |
486 | 944 | self.assertEqual(self.db1.pristine_upstream_source.version_as_revision( | 948 | self.assertEqual(self.db1.pristine_upstream_source.version_as_revisions( |
487 | 945 | "package", version.upstream_version), rh[0]) | 949 | "package", version.upstream_version), {None: rh[0]}) |
488 | 946 | rev = branch.repository.get_revision(rh[0]) | 950 | rev = branch.repository.get_revision(rh[0]) |
489 | 947 | self.assertEqual(rev.message, | 951 | self.assertEqual(rev.message, |
490 | 948 | "Import upstream version %s" % str(version.upstream_version)) | 952 | "Import upstream version %s" % str(version.upstream_version)) |
491 | @@ -1381,8 +1385,9 @@ | |||
492 | 1381 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) | 1385 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) |
493 | 1382 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) | 1386 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) |
494 | 1383 | self.assertEqual( | 1387 | self.assertEqual( |
497 | 1384 | self.db1.pristine_upstream_source.version_as_revision("package", version1.upstream_version), | 1388 | self.db1.pristine_upstream_source.version_as_revisions( |
498 | 1385 | up_rh1[0]) | 1389 | "package", version1.upstream_version), |
499 | 1390 | {None: up_rh1[0]}) | ||
500 | 1386 | self.tree1.lock_read() | 1391 | self.tree1.lock_read() |
501 | 1387 | self.addCleanup(self.tree1.unlock) | 1392 | self.addCleanup(self.tree1.unlock) |
502 | 1388 | self.assertFalse(self.db1.is_version_native(version1)) | 1393 | self.assertFalse(self.db1.is_version_native(version1)) |
503 | @@ -1434,11 +1439,13 @@ | |||
504 | 1434 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) | 1439 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) |
505 | 1435 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) | 1440 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) |
506 | 1436 | self.assertEqual( | 1441 | self.assertEqual( |
509 | 1437 | self.db1.pristine_upstream_source.version_as_revision("package", version1.upstream_version), | 1442 | self.db1.pristine_upstream_source.version_as_revisions("package", |
510 | 1438 | up_rh1[0]) | 1443 | version1.upstream_version), |
511 | 1444 | {None: up_rh1[0]}) | ||
512 | 1439 | self.assertEqual( | 1445 | self.assertEqual( |
515 | 1440 | self.db1.pristine_upstream_source.version_as_revision("package", version3.upstream_version), | 1446 | self.db1.pristine_upstream_source.version_as_revisions("package", |
516 | 1441 | up_rh1[1]) | 1447 | version3.upstream_version), |
517 | 1448 | {None: up_rh1[1]}) | ||
518 | 1442 | self.tree1.lock_read() | 1449 | self.tree1.lock_read() |
519 | 1443 | self.addCleanup(self.tree1.unlock) | 1450 | self.addCleanup(self.tree1.unlock) |
520 | 1444 | self.assertFalse(self.db1.is_version_native(version1)) | 1451 | self.assertFalse(self.db1.is_version_native(version1)) |
521 | @@ -1489,11 +1496,13 @@ | |||
522 | 1489 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) | 1496 | self.assertEqual(self.db1.revid_of_version(version2), rh1[2]) |
523 | 1490 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) | 1497 | self.assertEqual(self.db1.revid_of_version(version3), rh1[3]) |
524 | 1491 | self.assertEqual( | 1498 | self.assertEqual( |
527 | 1492 | self.db1.pristine_upstream_source.version_as_revision("package", version1.upstream_version), | 1499 | self.db1.pristine_upstream_source.version_as_revisions("package", |
528 | 1493 | up_rh1[0]) | 1500 | version1.upstream_version), |
529 | 1501 | { None: up_rh1[0] }) | ||
530 | 1494 | self.assertEqual( | 1502 | self.assertEqual( |
533 | 1495 | self.db1.pristine_upstream_source.version_as_revision("package", version3.upstream_version), | 1503 | self.db1.pristine_upstream_source.version_as_revisions("package", |
534 | 1496 | up_rh1[1]) | 1504 | version3.upstream_version), |
535 | 1505 | { None: up_rh1[1] }) | ||
536 | 1497 | self.tree1.lock_read() | 1506 | self.tree1.lock_read() |
537 | 1498 | self.addCleanup(self.tree1.unlock) | 1507 | self.addCleanup(self.tree1.unlock) |
538 | 1499 | self.assertFalse(self.db1.is_version_native(version1)) | 1508 | self.assertFalse(self.db1.is_version_native(version1)) |
539 | @@ -1604,7 +1613,7 @@ | |||
540 | 1604 | tf.close() | 1613 | tf.close() |
541 | 1605 | conflicts = db.merge_upstream([(tarball_filename, None)], "foo", "0.2", "0.1", | 1614 | conflicts = db.merge_upstream([(tarball_filename, None)], "foo", "0.2", "0.1", |
542 | 1606 | upstream_branch=upstream_tree.branch, | 1615 | upstream_branch=upstream_tree.branch, |
544 | 1607 | upstream_revision=upstream_rev) | 1616 | upstream_revisions={None: upstream_rev}) |
545 | 1608 | self.assertEqual(0, conflicts) | 1617 | self.assertEqual(0, conflicts) |
546 | 1609 | 1618 | ||
547 | 1610 | def test_merge_upstream_initial_with_removed_debian(self): | 1619 | def test_merge_upstream_initial_with_removed_debian(self): |
548 | @@ -1644,7 +1653,7 @@ | |||
549 | 1644 | tf.close() | 1653 | tf.close() |
550 | 1645 | conflicts = db.merge_upstream([(tarball_filename, None)], "foo", "0.2", "0.1", | 1654 | conflicts = db.merge_upstream([(tarball_filename, None)], "foo", "0.2", "0.1", |
551 | 1646 | upstream_branch=upstream_tree.branch, | 1655 | upstream_branch=upstream_tree.branch, |
553 | 1647 | upstream_revision=upstream_rev) | 1656 | upstream_revisions={None: upstream_rev}) |
554 | 1648 | # ./debian conflicts. | 1657 | # ./debian conflicts. |
555 | 1649 | self.assertEqual(3, conflicts) | 1658 | self.assertEqual(3, conflicts) |
556 | 1650 | 1659 | ||
557 | @@ -1686,7 +1695,7 @@ | |||
558 | 1686 | db.merge_upstream([(builder.tar_name(), None)], "package", str(version2), | 1695 | db.merge_upstream([(builder.tar_name(), None)], "package", str(version2), |
559 | 1687 | version1.upstream_version, | 1696 | version1.upstream_version, |
560 | 1688 | upstream_branch=upstream_tree.branch, | 1697 | upstream_branch=upstream_tree.branch, |
562 | 1689 | upstream_revision=upstream_rev) | 1698 | upstream_revisions={None: upstream_rev}) |
563 | 1690 | rh1 = tree.branch.revision_history() | 1699 | rh1 = tree.branch.revision_history() |
564 | 1691 | self.assertEqual(2, len(rh1)) | 1700 | self.assertEqual(2, len(rh1)) |
565 | 1692 | packaging_upstream_tip = tree.get_parent_ids()[1] | 1701 | packaging_upstream_tip = tree.get_parent_ids()[1] |
566 | @@ -1765,7 +1774,7 @@ | |||
567 | 1765 | version2.upstream_version, | 1774 | version2.upstream_version, |
568 | 1766 | version1.upstream_version, | 1775 | version1.upstream_version, |
569 | 1767 | upstream_branch=upstream_tree.branch, | 1776 | upstream_branch=upstream_tree.branch, |
571 | 1768 | upstream_revision=upstream_rev2) | 1777 | upstream_revisions={None: upstream_rev2}) |
572 | 1769 | self.assertEqual("a-id", tree.path2id("b")) | 1778 | self.assertEqual("a-id", tree.path2id("b")) |
573 | 1770 | 1779 | ||
574 | 1771 | def test_merge_upstream_rename_on_top(self): | 1780 | def test_merge_upstream_rename_on_top(self): |
575 | @@ -1802,7 +1811,7 @@ | |||
576 | 1802 | version2.upstream_version, | 1811 | version2.upstream_version, |
577 | 1803 | version1.upstream_version, | 1812 | version1.upstream_version, |
578 | 1804 | upstream_branch=upstream_tree.branch, | 1813 | upstream_branch=upstream_tree.branch, |
580 | 1805 | upstream_revision=upstream_rev2) | 1814 | upstream_revisions={None:upstream_rev2}) |
581 | 1806 | self.assertEqual("a-id", tree.path2id("b")) | 1815 | self.assertEqual("a-id", tree.path2id("b")) |
582 | 1807 | 1816 | ||
583 | 1808 | def test_merge_upstream_rename_in_packaging_branch(self): | 1817 | def test_merge_upstream_rename_in_packaging_branch(self): |
584 | 1809 | 1818 | ||
585 | === modified file 'tests/test_upstream.py' | |||
586 | --- tests/test_upstream.py 2011-09-09 13:20:42 +0000 | |||
587 | +++ tests/test_upstream.py 2011-09-26 22:30:28 +0000 | |||
588 | @@ -432,6 +432,20 @@ | |||
589 | 432 | self.tree.commit("msg") | 432 | self.tree.commit("msg") |
590 | 433 | self.assertEquals("2.1+bzr2", source.get_latest_version("foo", "1.0")) | 433 | self.assertEquals("2.1+bzr2", source.get_latest_version("foo", "1.0")) |
591 | 434 | 434 | ||
592 | 435 | def test_version_as_revisions(self): | ||
593 | 436 | revid1 = self.tree.commit("msg") | ||
594 | 437 | self.tree.branch.tags.set_tag("2.1", self.tree.branch.last_revision()) | ||
595 | 438 | config = DebBuildConfig( | ||
596 | 439 | [('user.conf', True), ('default.conf', False)], | ||
597 | 440 | branch=self.tree.branch) | ||
598 | 441 | source = UpstreamBranchSource(self.tree.branch, | ||
599 | 442 | {"2.1": self.tree.branch.last_revision()}, | ||
600 | 443 | config=config) | ||
601 | 444 | revid2 = self.tree.commit("msg") | ||
602 | 445 | self.assertEquals(revid2, | ||
603 | 446 | source.version_as_revision("foo", "2.1+bzr2")) | ||
604 | 447 | self.assertEquals({None: revid1}, source.version_as_revisions("foo", "2.1")) | ||
605 | 448 | |||
606 | 435 | def test_version_as_revision(self): | 449 | def test_version_as_revision(self): |
607 | 436 | revid1 = self.tree.commit("msg") | 450 | revid1 = self.tree.commit("msg") |
608 | 437 | self.tree.branch.tags.set_tag("2.1", self.tree.branch.last_revision()) | 451 | self.tree.branch.tags.set_tag("2.1", self.tree.branch.last_revision()) |
609 | @@ -766,14 +780,31 @@ | |||
610 | 766 | rev.properties["deb-pristine-delta"] = standard_b64encode("bla") | 780 | rev.properties["deb-pristine-delta"] = standard_b64encode("bla") |
611 | 767 | self.assertEquals("bla", self.source.pristine_tar_delta(rev)) | 781 | self.assertEquals("bla", self.source.pristine_tar_delta(rev)) |
612 | 768 | 782 | ||
614 | 769 | def test_version_as_revision_missing(self): | 783 | def test_version_as_revisions_missing(self): |
615 | 770 | self.assertRaises(PackageVersionNotPresent, | 784 | self.assertRaises(PackageVersionNotPresent, |
622 | 771 | self.source.version_as_revision, None, "1.2") | 785 | self.source.version_as_revisions, None, "1.2") |
623 | 772 | 786 | ||
624 | 773 | def test_version_as_revision(self): | 787 | def test_version_as_revisions_single(self): |
625 | 774 | revid1 = self.tree.commit("msg") | 788 | revid1 = self.tree.commit("msg") |
626 | 775 | self.tree.branch.tags.set_tag("upstream-2.1", revid1) | 789 | self.tree.branch.tags.set_tag("upstream-2.1", revid1) |
627 | 776 | self.assertEquals(revid1, self.source.version_as_revision(None, "2.1")) | 790 | self.assertEquals({None: revid1}, |
628 | 791 | self.source.version_as_revisions(None, "2.1")) | ||
629 | 792 | |||
630 | 793 | def test_version_component_as_revision(self): | ||
631 | 794 | revid1 = self.tree.commit("msg") | ||
632 | 795 | self.tree.branch.tags.set_tag("upstream-2.1/lib", revid1) | ||
633 | 796 | self.assertEquals(revid1, | ||
634 | 797 | self.source.version_component_as_revision(None, "2.1", "lib")) | ||
635 | 798 | |||
636 | 799 | def test_version_as_revisions(self): | ||
637 | 800 | revid1 = self.tree.commit("msg") | ||
638 | 801 | revid2 = self.tree.commit("msg") | ||
639 | 802 | self.tree.branch.tags.set_tag("upstream-2.1", revid1) | ||
640 | 803 | self.tree.branch.tags.set_tag("upstream-2.1/lib", revid2) | ||
641 | 804 | self.assertEquals({ None: revid1, "lib": revid2 }, | ||
642 | 805 | self.source.version_as_revisions(None, "2.1", [ | ||
643 | 806 | ("upstream_2.1.orig.tar.gz", None, "somemd5sum"), | ||
644 | 807 | ("upstream_2.1.orig-lib.tar.gz", "lib", "othermd5sum")])) | ||
645 | 777 | 808 | ||
646 | 778 | 809 | ||
647 | 779 | class TarfileSourceTests(TestCaseWithTransport): | 810 | class TarfileSourceTests(TestCaseWithTransport): |
648 | 780 | 811 | ||
649 | === modified file 'upstream/__init__.py' | |||
650 | --- upstream/__init__.py 2011-09-07 20:11:50 +0000 | |||
651 | +++ upstream/__init__.py 2011-09-26 22:30:28 +0000 | |||
652 | @@ -75,15 +75,16 @@ | |||
653 | 75 | """ | 75 | """ |
654 | 76 | raise NotImplementedError(self.get_latest_version) | 76 | raise NotImplementedError(self.get_latest_version) |
655 | 77 | 77 | ||
658 | 78 | def version_as_revision(self, package, version): | 78 | def version_as_revisions(self, package, version, tarballs=None): |
659 | 79 | """Lookup the revision id for a particular version. | 79 | """Lookup the revision ids for a particular version. |
660 | 80 | 80 | ||
661 | 81 | :param package: Package name | 81 | :param package: Package name |
663 | 82 | :package version: Version string | 82 | :param version: Version string |
664 | 83 | :raise PackageVersionNotPresent: When the specified version was not | 83 | :raise PackageVersionNotPresent: When the specified version was not |
665 | 84 | found | 84 | found |
666 | 85 | :return: dictionary mapping component names to revision ids | ||
667 | 85 | """ | 86 | """ |
669 | 86 | raise NotImplementedError(self.version_as_revision) | 87 | raise NotImplementedError(self.version_as_revisions) |
670 | 87 | 88 | ||
671 | 88 | def has_version(self, package, version, md5=None): | 89 | def has_version(self, package, version, md5=None): |
672 | 89 | """Check whether this upstream source contains a particular package. | 90 | """Check whether this upstream source contains a particular package. |
673 | 90 | 91 | ||
674 | === modified file 'upstream/branch.py' | |||
675 | --- upstream/branch.py 2011-06-26 21:02:48 +0000 | |||
676 | +++ upstream/branch.py 2011-09-26 22:30:28 +0000 | |||
677 | @@ -28,7 +28,10 @@ | |||
678 | 28 | from bzrlib.revisionspec import RevisionSpec | 28 | from bzrlib.revisionspec import RevisionSpec |
679 | 29 | from bzrlib.trace import note | 29 | from bzrlib.trace import note |
680 | 30 | 30 | ||
682 | 31 | from bzrlib.plugins.builddeb.errors import PackageVersionNotPresent | 31 | from bzrlib.plugins.builddeb.errors import ( |
683 | 32 | MultipleUpstreamTarballsNotSupported, | ||
684 | 33 | PackageVersionNotPresent, | ||
685 | 34 | ) | ||
686 | 32 | from bzrlib.plugins.builddeb.upstream import UpstreamSource | 35 | from bzrlib.plugins.builddeb.upstream import UpstreamSource |
687 | 33 | from bzrlib.plugins.builddeb.util import ( | 36 | from bzrlib.plugins.builddeb.util import ( |
688 | 34 | export, | 37 | export, |
689 | @@ -228,7 +231,7 @@ | |||
690 | 228 | else: | 231 | else: |
691 | 229 | self.upstream_revision_map = upstream_revision_map | 232 | self.upstream_revision_map = upstream_revision_map |
692 | 230 | 233 | ||
694 | 231 | def version_as_revision(self, package, version): | 234 | def version_as_revision(self, package, version, tarballs=None): |
695 | 232 | assert isinstance(version, str) | 235 | assert isinstance(version, str) |
696 | 233 | if version in self.upstream_revision_map: | 236 | if version in self.upstream_revision_map: |
697 | 234 | revspec = self.upstream_revision_map[version] | 237 | revspec = self.upstream_revision_map[version] |
698 | @@ -242,6 +245,13 @@ | |||
699 | 242 | raise PackageVersionNotPresent(package, version, self) | 245 | raise PackageVersionNotPresent(package, version, self) |
700 | 243 | raise PackageVersionNotPresent(package, version, self) | 246 | raise PackageVersionNotPresent(package, version, self) |
701 | 244 | 247 | ||
702 | 248 | def version_as_revisions(self, package, version, tarballs=None): | ||
703 | 249 | # FIXME: Support multiple upstream locations if there are multiple | ||
704 | 250 | # components | ||
705 | 251 | if tarballs is not None and tarballs.keys() != [None]: | ||
706 | 252 | raise MultipleUpstreamTarballsNotSupported() | ||
707 | 253 | return { None: self.version_as_revision(package, version, tarballs) } | ||
708 | 254 | |||
709 | 245 | def get_latest_version(self, package, current_version): | 255 | def get_latest_version(self, package, current_version): |
710 | 246 | return self.get_version(package, current_version, | 256 | return self.get_version(package, current_version, |
711 | 247 | self.upstream_branch.last_revision()) | 257 | self.upstream_branch.last_revision()) |
712 | 248 | 258 | ||
713 | === modified file 'upstream/pristinetar.py' | |||
714 | --- upstream/pristinetar.py 2011-09-09 13:20:42 +0000 | |||
715 | +++ upstream/pristinetar.py 2011-09-26 22:30:28 +0000 | |||
716 | @@ -39,13 +39,17 @@ | |||
717 | 39 | subprocess_setup, | 39 | subprocess_setup, |
718 | 40 | ) | 40 | ) |
719 | 41 | 41 | ||
721 | 42 | from bzrlib import osutils | 42 | from bzrlib import ( |
722 | 43 | osutils, | ||
723 | 44 | revision as _mod_revision, | ||
724 | 45 | ) | ||
725 | 43 | from bzrlib.errors import ( | 46 | from bzrlib.errors import ( |
726 | 44 | BzrError, | 47 | BzrError, |
727 | 45 | NoSuchRevision, | 48 | NoSuchRevision, |
728 | 46 | NoSuchTag, | 49 | NoSuchTag, |
729 | 47 | ) | 50 | ) |
730 | 48 | from bzrlib.trace import ( | 51 | from bzrlib.trace import ( |
731 | 52 | mutter, | ||
732 | 49 | note, | 53 | note, |
733 | 50 | warning, | 54 | warning, |
734 | 51 | ) | 55 | ) |
735 | @@ -166,32 +170,43 @@ | |||
736 | 166 | :param parent_ids: Parent revisions | 170 | :param parent_ids: Parent revisions |
737 | 167 | :param tarballs: List of (path, component, md5) | 171 | :param tarballs: List of (path, component, md5) |
738 | 168 | :param timestamp: Optional timestamp for new commits | 172 | :param timestamp: Optional timestamp for new commits |
740 | 169 | :param author: Optional author for new commits | 173 | :param author: Optional author for new commitscopmone |
741 | 170 | :return: List of tuples with (component, tag, revid) | 174 | :return: List of tuples with (component, tag, revid) |
742 | 171 | """ | 175 | """ |
743 | 172 | ret = [] | 176 | ret = [] |
744 | 177 | component_paths = [cp for (_, cp, _) in tarballs if cp is not None] | ||
745 | 173 | for (tarball, component, md5) in tarballs: | 178 | for (tarball, component, md5) in tarballs: |
746 | 179 | if component is None: | ||
747 | 180 | exclude = component_paths | ||
748 | 181 | else: | ||
749 | 182 | exclude = [] | ||
750 | 174 | (tag, revid) = self.import_component_tarball( | 183 | (tag, revid) = self.import_component_tarball( |
753 | 175 | package, version, tree, parent_ids, component, | 184 | package, version, tree, parent_ids, component, |
754 | 176 | md5, tarball, author=author, timestamp=timestamp) | 185 | md5, tarball, author=author, timestamp=timestamp, |
755 | 186 | exclude=exclude) | ||
756 | 177 | ret.append((component, tag, revid)) | 187 | ret.append((component, tag, revid)) |
757 | 188 | # FIXME: Handle multiple components | ||
758 | 189 | tree.branch.generate_revision_history(revid) | ||
759 | 178 | return ret | 190 | return ret |
760 | 179 | 191 | ||
761 | 180 | def import_component_tarball(self, package, version, tree, parent_ids, | 192 | def import_component_tarball(self, package, version, tree, parent_ids, |
763 | 181 | component=None, md5=None, tarball=None, author=None, timestamp=None): | 193 | component=None, md5=None, tarball=None, author=None, timestamp=None, |
764 | 194 | subdir=None, exclude=None): | ||
765 | 182 | """Import a tarball. | 195 | """Import a tarball. |
766 | 183 | 196 | ||
767 | 184 | :param package: Package name | 197 | :param package: Package name |
768 | 185 | :param version: Upstream version | 198 | :param version: Upstream version |
769 | 186 | :param component: Component name (None for base) | 199 | :param component: Component name (None for base) |
770 | 200 | :param exclude: Exclude directories | ||
771 | 187 | """ | 201 | """ |
775 | 188 | if component is not None: | 202 | if exclude is not None or subdir is not None: |
776 | 189 | raise BzrError("Importing non-base tarballs not yet supported") | 203 | raise NotImplementedError |
777 | 190 | tree.set_parent_ids(parent_ids) | 204 | if exclude is None: |
778 | 205 | exclude = [] | ||
779 | 191 | revprops = {} | 206 | revprops = {} |
780 | 192 | if md5 is not None: | 207 | if md5 is not None: |
781 | 193 | revprops["deb-md5"] = md5 | 208 | revprops["deb-md5"] = md5 |
783 | 194 | delta = self.make_pristine_tar_delta(tree, tarball) | 209 | delta = self.make_pristine_tar_delta(tree, tarball, subdir=subdir) |
784 | 195 | uuencoded = standard_b64encode(delta) | 210 | uuencoded = standard_b64encode(delta) |
785 | 196 | if tarball.endswith(".tar.bz2"): | 211 | if tarball.endswith(".tar.bz2"): |
786 | 197 | revprops["deb-pristine-delta-bz2"] = uuencoded | 212 | revprops["deb-pristine-delta-bz2"] = uuencoded |
787 | @@ -208,9 +223,31 @@ | |||
788 | 208 | message = "Import upstream version %s" % (version,) | 223 | message = "Import upstream version %s" % (version,) |
789 | 209 | if component is not None: | 224 | if component is not None: |
790 | 210 | message += ", component %s" % component | 225 | message += ", component %s" % component |
794 | 211 | revid = tree.commit(message, revprops=revprops, timestamp=timestamp, | 226 | if len(parent_ids) == 0: |
795 | 212 | timezone=timezone) | 227 | base_revid = _mod_revision.NULL_REVISION |
796 | 213 | tag_name, _ = self.tag_version(version, revid=revid) | 228 | else: |
797 | 229 | base_revid = parent_ids[0] | ||
798 | 230 | basis_tree = tree.branch.repository.revision_tree(base_revid) | ||
799 | 231 | tree.lock_write() | ||
800 | 232 | try: | ||
801 | 233 | builder = tree.branch.get_commit_builder(parents=parent_ids, | ||
802 | 234 | revprops=revprops, timestamp=timestamp, timezone=timezone) | ||
803 | 235 | builder.will_record_deletes() | ||
804 | 236 | try: | ||
805 | 237 | list(builder.record_iter_changes(tree, base_revid, | ||
806 | 238 | tree.iter_changes(basis_tree))) | ||
807 | 239 | builder.finish_inventory() | ||
808 | 240 | except: | ||
809 | 241 | builder.abort() | ||
810 | 242 | raise | ||
811 | 243 | revid = builder.commit(message) | ||
812 | 244 | tag_name, _ = self.tag_version(version, revid=revid, component=component) | ||
813 | 245 | tree.update_basis_by_delta(revid, builder.get_basis_delta()) | ||
814 | 246 | finally: | ||
815 | 247 | tree.unlock() | ||
816 | 248 | mutter( | ||
817 | 249 | 'imported %s version %s component %r as revid %s, tagged %s', | ||
818 | 250 | package, version, component, revid, tag_name) | ||
819 | 214 | return tag_name, revid | 251 | return tag_name, revid |
820 | 215 | 252 | ||
821 | 216 | def fetch_component_tarball(self, package, version, component, target_dir): | 253 | def fetch_component_tarball(self, package, version, component, target_dir): |
822 | @@ -256,14 +293,16 @@ | |||
823 | 256 | "revision %s", revid) | 293 | "revision %s", revid) |
824 | 257 | return True | 294 | return True |
825 | 258 | 295 | ||
827 | 259 | def version_as_revision(self, package, version, tarballs=None): | 296 | def version_as_revisions(self, package, version, tarballs=None): |
828 | 260 | if tarballs is None: | 297 | if tarballs is None: |
835 | 261 | return self.version_component_as_revision(package, version, component=None) | 298 | # FIXME: What if there are multiple tarballs? |
836 | 262 | elif len(tarballs) > 1: | 299 | return { |
837 | 263 | raise MultipleUpstreamTarballsNotSupported() | 300 | None: self.version_component_as_revision(package, version, component=None) } |
838 | 264 | else: | 301 | ret = {} |
839 | 265 | return self.version_component_as_revision(package, version, tarballs[0][1], | 302 | for (tarball, component, md5) in tarballs: |
840 | 266 | tarballs[0][2]) | 303 | ret[component] = self.version_component_as_revision( |
841 | 304 | package, version, component, md5) | ||
842 | 305 | return ret | ||
843 | 267 | 306 | ||
844 | 268 | def version_component_as_revision(self, package, version, component, md5=None): | 307 | def version_component_as_revision(self, package, version, component, md5=None): |
845 | 269 | assert isinstance(version, str) | 308 | assert isinstance(version, str) |
846 | @@ -359,7 +398,7 @@ | |||
847 | 359 | finally: | 398 | finally: |
848 | 360 | shutil.rmtree(tmpdir) | 399 | shutil.rmtree(tmpdir) |
849 | 361 | 400 | ||
851 | 362 | def make_pristine_tar_delta(self, tree, tarball_path): | 401 | def make_pristine_tar_delta(self, tree, tarball_path, subdir=None): |
852 | 363 | tmpdir = tempfile.mkdtemp(prefix="builddeb-pristine-") | 402 | tmpdir = tempfile.mkdtemp(prefix="builddeb-pristine-") |
853 | 364 | try: | 403 | try: |
854 | 365 | dest = os.path.join(tmpdir, "orig") | 404 | dest = os.path.join(tmpdir, "orig") |
855 | @@ -367,7 +406,7 @@ | |||
856 | 367 | try: | 406 | try: |
857 | 368 | for (dp, ie) in tree.inventory.iter_entries(): | 407 | for (dp, ie) in tree.inventory.iter_entries(): |
858 | 369 | ie._read_tree_state(dp, tree) | 408 | ie._read_tree_state(dp, tree) |
860 | 370 | export(tree, dest, format='dir') | 409 | export(tree, dest, format='dir', subdir=subdir) |
861 | 371 | finally: | 410 | finally: |
862 | 372 | tree.unlock() | 411 | tree.unlock() |
863 | 373 | return make_pristine_tar_delta(dest, tarball_path) | 412 | return make_pristine_tar_delta(dest, tarball_path) |