Merge lp:~jelmer/bzr-builddeb/inline-get-upstream-sources into lp:bzr-builddeb

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 454
Proposed branch: lp:~jelmer/bzr-builddeb/inline-get-upstream-sources
Merge into: lp:bzr-builddeb
Diff against target: 137 lines (+33/-49)
2 files modified
cmds.py (+32/-13)
upstream.py (+1/-36)
To merge this branch: bzr merge lp:~jelmer/bzr-builddeb/inline-get-upstream-sources
Reviewer Review Type Date Requested Status
Bzr-builddeb-hackers Pending
Review via email: mp+25865@code.launchpad.net

Description of the change

This inlines get_upstream_sources, the current indirection is unnecessary imho and makes it harder to see what's actually used to find the upstream sources for a certain situation.

To post a comment you must log in.

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 2010-05-06 14:30:28 +0000
3+++ cmds.py 2010-05-24 02:04:25 +0000
4@@ -76,9 +76,13 @@
5 upstream_tag_version,
6 )
7 from bzrlib.plugins.builddeb.upstream import (
8+ AptSource,
9+ GetOrigSourceSource,
10+ PristineTarSource,
11+ SelfSplitSource,
12+ UScanSource,
13 UpstreamProvider,
14 UpstreamBranchSource,
15- get_upstream_sources,
16 )
17 from bzrlib.plugins.builddeb.util import (
18 debuild_config,
19@@ -364,17 +368,28 @@
20 result_dir, build_dir, orig_dir = self._get_dirs(config, branch,
21 is_local, result_dir or result, build_dir, orig_dir)
22
23- upstream_branch, upstream_revision = \
24- self._get_upstream_branch(merge, export_upstream,
25- export_upstream_revision, config,
26- changelog.version)
27- upstream_provider = UpstreamProvider(
28- changelog.package, changelog.version,
29- orig_dir, get_upstream_sources(tree, branch,
30- larstiq=larstiq, upstream_branch=upstream_branch,
31- upstream_revision_map={
32- changelog.version.upstream_version:upstream_revision
33- }, allow_split=split))
34+ upstream_sources = [
35+ PristineTarSource(tree, branch),
36+ AptSource(),
37+ ]
38+ if merge:
39+ upstream_branch, upstream_revision = self._get_upstream_branch(
40+ merge, export_upstream, export_upstream_revision, config,
41+ changelog.version)
42+ upstream_sources.append(UpstreamBranchSource(upstream_branch,
43+ {changelog.version.upstream_version: upstream_revision}))
44+ elif not native and config.upstream_branch:
45+ upstream_branch = Branch.open(config.upstream_branch)
46+ upstream_sources.append(UpstreamBranchSource(upstream_branch))
47+ upstream_sources.extend([
48+ GetOrigSourceSource(tree, larstiq),
49+ UScanSource(tree, larstiq),
50+ ])
51+ if split:
52+ upstream_sources.append(SelfSplitSource(tree))
53+
54+ upstream_provider = UpstreamProvider(changelog.package,
55+ changelog.version, orig_dir, upstream_sources)
56
57 if merge:
58 distiller_cls = MergeModeDistiller
59@@ -873,9 +888,13 @@
60 orig_dir = config.orig_dir
61 if orig_dir is None:
62 orig_dir = default_orig_dir
63+
64 upstream_provider = UpstreamProvider(changelog.package,
65 changelog.version.upstream_version, orig_dir,
66- get_upstream_sources(t, t.branch, larstiq=larstiq))
67+ [PristineTarSource(t, t.branch),
68+ AptSource(),
69+ GetOrigSourceSource(t, larstiq),
70+ UScanSource(t, larstiq) ])
71
72 distiller = MergeModeDistiller(t, upstream_provider,
73 larstiq=larstiq)
74
75=== modified file 'upstream.py'
76--- upstream.py 2010-04-22 10:54:52 +0000
77+++ upstream.py 2010-05-24 02:04:25 +0000
78@@ -153,21 +153,17 @@
79 :ivar upstream_version_map: Map from version strings to revids
80 """
81
82- def __init__(self, upstream_branch, upstream_revision_map=None,
83- fallback_revspec=None):
84+ def __init__(self, upstream_branch, upstream_revision_map=None):
85 self.upstream_branch = upstream_branch
86 if upstream_revision_map is None:
87 self.upstream_revision_map = {}
88 else:
89 self.upstream_revision_map = upstream_revision_map
90- self.fallback_revspec = fallback_revspec
91
92 def _get_revision_id(self, version):
93 if version in self.upstream_revision_map:
94 return self.upstream_revision_map[version]
95 revspec = get_snapshot_revision(version)
96- if revspec is None:
97- revspec = self.fallback_revspec
98 if revspec is not None:
99 return RevisionSpec.from_string(
100 revspec).as_revision_id(self.upstream_branch)
101@@ -352,37 +348,6 @@
102 return None
103
104
105-def get_upstream_sources(tree, branch, larstiq=False, upstream_branch=None,
106- upstream_revision_map=None, allow_split=False):
107- """Get the list of upstream sources to retrieve upstream versions from.
108-
109- :param tree: The tree that is being built from.
110- :param branch: The branch that is being built from.
111- :param larstiq: Whether the tree versions the root of ./debian.
112- :param upstream_branch: An upstream branch that can be exported
113- if needed.
114- :param upstream_revision_map: Map mapping upstream version strings
115- to revision ids.
116- :param allow_split: Whether the provider can provide the tarball
117- by exporting the branch and removing the "debian" dir.
118-
119- """
120- sources = [
121- PristineTarSource(tree, branch),
122- AptSource(),
123- ]
124- if upstream_branch is not None:
125- sources.append(
126- UpstreamBranchSource(upstream_branch, upstream_revision_map))
127- sources.extend([
128- GetOrigSourceSource(tree, larstiq),
129- UScanSource(tree, larstiq),
130- ])
131- if allow_split:
132- sources.append(SelfSplitSource(tree))
133- return sources
134-
135-
136 class UpstreamProvider(object):
137 """An upstream provider can provide the upstream source for a package.
138

Subscribers

People subscribed via source and target branches