Merge ~nacc/git-ubuntu:lp1730655-fix-importer-devel-branches into git-ubuntu:master

Proposed by Nish Aravamudan
Status: Merged
Merged at revision: b1551b1da50cfc3aa46e935e09abec90dc56a72c
Proposed branch: ~nacc/git-ubuntu:lp1730655-fix-importer-devel-branches
Merge into: git-ubuntu:master
Diff against target: 281 lines (+130/-68)
2 files modified
gitubuntu/importer.py (+102/-62)
gitubuntu/source_information.py (+28/-6)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Robie Basak Pending
Review via email: mp+333320@code.launchpad.net

Description of the change

Make jenkins happy.

To post a comment you must log in.
02e3e7d... by Nish Aravamudan

source_information: fix incorrect API comments

f53eda9... by Nish Aravamudan

source_information: cleanup formatting per style

9507164... by Nish Aravamudan

source_information: add API to obtain all series objects/names

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:69c9b3397ceec3843bc1706b065b2fe4475d5e5b
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/197/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Style Check
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/197/rebuild

review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:853cb2e401a1122295562357225c63c127426aa5
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/211/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Style Check
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/211/rebuild

review: Approve (continuous-integration)
Revision history for this message
Robie Basak (racb) wrote :

Looks good!

I refactored and added unit tests in https://code.launchpad.net/~racb/usd-importer/+git/usd-importer/+ref/fix-importer-devel-branches

I have not however tested integration (ie. that my update_devel_branches() function is still correct or even works at all).

Please could you review and pull in my commits if you're happy?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/gitubuntu/importer.py b/gitubuntu/importer.py
2index f7dfe92..2674f4b 100644
3--- a/gitubuntu/importer.py
4+++ b/gitubuntu/importer.py
5@@ -355,6 +355,13 @@ def main(
6 allow_applied_failures=allow_applied_failures,
7 )
8
9+ update_devel_branches(
10+ repo=repo,
11+ namespace=namespace,
12+ pkgname=pkgname,
13+ ubuntu_sinfo=ubuntu_sinfo,
14+ )
15+
16 os.chdir(oldcwd)
17
18 repo.garbage_collect()
19@@ -905,62 +912,111 @@ def override_parents(repo, spi, namespace):
20 applied_changelog_parent_commit,
21 )
22
23-def _update_devel_branches(
24+def update_devel_branches(
25 repo,
26 namespace,
27 pkgname,
28 ubuntu_sinfo,
29- spi,
30 ):
31- # spi previously had a default argument value of None, but the
32- # functionality has since been dropped. Let's ensure that no caller
33- # depending on this functionality remains.
34- assert spi
35+ """update_devel_branches - move the 'meta' -devel branches to the
36+ latest publication in each series
37
38- # we do not maintain -devel pointers for debian
39- if str(spi.distribution.name.lower()) != "ubuntu":
40- return
41- for devel_head in (
42- '%s/ubuntu/%s-devel' % (namespace, spi.series.name.lower()),
43- '%s/ubuntu/devel' % namespace
44- ):
45- logging.debug("Updating %s to %s" % (devel_head,
46- spi.head_name(namespace)))
47- repo.update_head_to_commit(
48- devel_head,
49- repo.head_to_commit(spi.head_name(namespace)),
50+ For all known series in @ubuntu_sinfo, update the
51+ ubuntu/series-devel branch to the latest version in the series'
52+ pocket branches.
53+
54+ Update the ubuntu/devel branch to the latest ubuntu/series-devel
55+ branch.
56+
57+ Do this for both the unapplied and applied branches.
58+
59+ Arguments:
60+ repo - gitubuntu.git_repository.GitUbuntuRepository object
61+ pkgname - string source package name
62+ namespace - string namespace under which the relevant branch refs
63+ can be found
64+ ubuntu_sinfo - GitUbuntuSourceInformation object for the ubuntu
65+ archive
66+ """
67+
68+ for applied_prefix in ('', 'applied/',):
69+ head_versions = repo.get_heads_and_versions(
70+ '%subuntu' % applied_prefix,
71+ namespace=namespace,
72+ )
73+ devel_hash = None
74+ devel_name = None
75+ devel_branch_name = '%s/%subuntu/devel' % (
76+ namespace,
77+ applied_prefix,
78 )
79
80+ for series_name in ubuntu_sinfo.all_series_name_list:
81+ series_devel_hash = None
82+ series_devel_name = None
83+ series_devel_version = None
84+ # Find highest version publish in these pockets, favoring this
85+ # order of pockets
86+ for suff in ("-proposed", "-updates", "-security", "",):
87+ name = "%s/%subuntu/%s%s" % (
88+ namespace,
89+ applied_prefix,
90+ series_name,
91+ suff,
92+ )
93+ if name in head_versions and version_compare(
94+ head_versions[name]['version'],
95+ series_devel_version
96+ ) > 0:
97+ series_devel_name = name
98+ series_devel_version = head_versions[name]['version']
99+ series_devel_hash = str(
100+ head_versions[name]['head'].peel().id
101+ )
102+ if series_devel_hash:
103+ series_devel_branch_name = '%s/%subuntu/%s-devel' % (
104+ namespace,
105+ applied_prefix,
106+ series_name,
107+ )
108+ logging.debug(
109+ "Setting %s branch to '%s' (%s)",
110+ series_devel_branch_name,
111+ series_devel_name,
112+ series_devel_hash,
113+ )
114+ repo.update_head_to_commit(
115+ series_devel_branch_name,
116+ series_devel_hash,
117+ )
118
119-def update_devel_branches(
120- repo,
121- namespace,
122- pkgname,
123- ubuntu_sinfo,
124- spi,
125-):
126- _update_devel_branches(
127- repo=repo,
128- namespace=namespace,
129- pkgname=pkgname,
130- ubuntu_sinfo=ubuntu_sinfo,
131- spi=spi,
132- )
133+ # the first series devel pointer we find is the most recent
134+ # XXX: if a source package was published, but no longer is,
135+ # do we want to have a ubuntu-devel pointer? This was the
136+ # old behavior, but we need to decide on the semantics of
137+ # the devel branch (most recent or development release)
138+ if not devel_hash:
139+ devel_name = series_devel_name
140+ devel_hash = series_devel_hash
141
142-def update_applied_devel_branches(
143- repo,
144- namespace,
145- pkgname,
146- ubuntu_sinfo,
147- spi,
148-):
149- _update_devel_branches(
150- repo=repo,
151- namespace='%s/applied' % namespace,
152- pkgname=pkgname,
153- ubuntu_sinfo=ubuntu_sinfo,
154- spi=spi,
155- )
156+ if devel_hash is None:
157+ logging.warn(
158+ "Source package '%s' does not appear to have been published "
159+ "in Ubuntu. No %s branch created.",
160+ pkgname,
161+ devel_branch_name,
162+ )
163+ else:
164+ logging.debug(
165+ "Setting %s branch to '%s' (%s)",
166+ devel_branch_name,
167+ devel_name,
168+ devel_hash,
169+ )
170+ repo.update_head_to_commit(
171+ "%s/%subuntu/devel" % (namespace, applied_prefix),
172+ devel_hash,
173+ )
174
175 # imports a package based upon source package information
176 def import_unapplied_spi(repo, spi, namespace, skip_orig, ubuntu_sinfo):
177@@ -1159,14 +1215,6 @@ def import_unapplied_spi(repo, spi, namespace, skip_orig, ubuntu_sinfo):
178 upload_parent_commit,
179 )
180
181- update_devel_branches(
182- repo=repo,
183- namespace=namespace,
184- pkgname=spi.name,
185- ubuntu_sinfo=ubuntu_sinfo,
186- spi=spi,
187- )
188-
189 def import_applied_spi(
190 repo,
191 spi,
192@@ -1337,14 +1385,6 @@ def import_applied_spi(
193 unapplied_parent_commit,
194 )
195
196- update_applied_devel_branches(
197- repo=repo,
198- pkgname=spi.name,
199- namespace=namespace,
200- ubuntu_sinfo=ubuntu_sinfo,
201- spi=spi,
202- )
203-
204 def import_publishes(
205 repo,
206 pkgname,
207diff --git a/gitubuntu/source_information.py b/gitubuntu/source_information.py
208index 3fef4ec..b97bc8a 100644
209--- a/gitubuntu/source_information.py
210+++ b/gitubuntu/source_information.py
211@@ -290,6 +290,7 @@ class NoPublicationHistoryException(Exception):
212
213 # An abstraction of an information source about source packages
214 class GitUbuntuSourceInformation(object):
215+ _all_series_list = None
216 _active_series_list = None
217 _stable_series_list = None
218 _current_series = None
219@@ -345,11 +346,12 @@ class GitUbuntuSourceInformation(object):
220 def active_series(self):
221 if self.dist_name.startswith('ppa:'):
222 return []
223- # return a list of series names sorted with newest first.
224+ # return a list of series objects sorted with newest first.
225 if self._active_series_list is None:
226 self._active_series_list = sorted(
227 [r for r in self.dist.series if r.active],
228- key=lambda s: float(s.version), reverse=True
229+ key=lambda s: float(s.version),
230+ reverse=True,
231 )
232 return self._active_series_list
233
234@@ -357,16 +359,32 @@ class GitUbuntuSourceInformation(object):
235 def stable_series(self):
236 if self.dist_name.startswith('ppa:'):
237 return []
238- # return a list of released series names sorted with newest first.
239+ # return a list of released series objects sorted with newest first.
240 if self._stable_series_list is None:
241 self._stable_series_list = sorted(
242- [r for r in self.dist.series if r.active and
243- r.status in ('Current Stable Release', 'Supported')],
244- key=lambda s: float(s.version), reverse=True
245+ [
246+ r for r in self.dist.series if r.active and
247+ r.status in ('Current Stable Release', 'Supported')
248+ ],
249+ key=lambda s: float(s.version),
250+ reverse=True,
251 )
252 return self._stable_series_list
253
254 @property
255+ def all_series(self):
256+ if self.dist_name.startswith('ppa:'):
257+ return []
258+ # return a list of all series objects sorted with newest first
259+ if self._all_series_list is None:
260+ self._all_series_list = sorted(
261+ self.dist.series,
262+ key=lambda s: float(s.version),
263+ reverse=True,
264+ )
265+ return self._all_series_list
266+
267+ @property
268 def current_series_name(self):
269 if not self.current_series:
270 return None
271@@ -380,6 +398,10 @@ class GitUbuntuSourceInformation(object):
272 def stable_series_name_list(self):
273 return [r.name for r in self.stable_series]
274
275+ @property
276+ def all_series_name_list(self):
277+ return [r.name for r in self.all_series]
278+
279 def get_corrected_spi(self, srcpkg, workdir=None):
280 try:
281 pull_override = self.pull_overrides[srcpkg.source_package_version]

Subscribers

People subscribed via source and target branches