156
157
trace.log_exception_quietly()
161
"""Text-form for what location this represents.
164
ubuntu, natty => Ubuntu Natty
165
ubuntu, natty-proposed => Ubuntu Natty Proposed
166
:return: A string representing the location we are checking.
168
place = self._archive
169
if self._series is not None:
170
place = '%s %s' % (place, self._series)
171
if self._pocket is not None and self._pocket != 'Release':
172
place = '%s %s' % (place, self._pocket)
160
176
def get_latest_publication(archive, series, project):
161
177
"""Get the most recent publication for a given project.
187
203
return reverse_dict[rev_id]
189
205
the_branch.unlock()
208
def _get_newest_versions(the_branch, latest_pub):
209
"""Get information about how 'fresh' this packaging branch is.
211
:param the_branch: The Branch to check
212
:param latest_pub: The LatestPublication used to check most recent
214
:return: (latest_ver, branch_latest_ver)
217
latest_ver = latest_pub.get_latest_version()
218
t_latest_ver = time.time() - t
219
trace.mutter('LatestPublication.get_latest_version took: %.3fs'
221
if latest_ver is None:
224
tags = the_branch.tags.get_tag_dict()
225
t_tag_dict = time.time() - t
226
trace.mutter('LatestPublication.get_tag_dict took: %.3fs' % (t_tag_dict,))
227
if latest_ver in tags:
228
# branch might have a newer tag, but we don't really care
229
return latest_ver, latest_ver
231
best_tag = get_most_recent_tag(tags, the_branch)
232
return latest_ver, best_tag
235
def _report_freshness(latest_ver, branch_latest_ver, place, verbosity,
237
"""Report if the branch is up-to-date."""
238
if latest_ver is None:
239
if verbosity == 'all':
240
report_func('Most recent %s version: MISSING' % (place,))
241
elif verbosity == 'short':
242
report_func('%s is MISSING a version' % (place,))
244
elif latest_ver == branch_latest_ver:
245
if verbosity == 'minimal':
247
elif verbosity == 'short':
248
report_func('%s is CURRENT in %s' % (latest_ver, place))
250
report_func('Most recent %s version: %s\n'
251
'Packaging branch status: CURRENT'
252
% (place, latest_ver))
254
if verbosity in ('minimal', 'short'):
255
if branch_latest_ver is None:
256
branch_latest_ver = 'Branch'
257
report_func('%s is OUT-OF-DATE, %s has %s'
258
% (branch_latest_ver, place, latest_ver))
260
report_func('Most recent %s version: %s\n'
261
'Packaging branch version: %s\n'
262
'Packaging branch status: OUT-OF-DATE'
263
% (place, latest_ver, branch_latest_ver))
266
def report_freshness(the_branch, verbosity, latest_pub):
267
"""Report to the user how up-to-date the packaging branch is.
269
:param the_branch: A Branch object
270
:param verbosity: Can be one of:
271
off: Do not print anything, and skip all checks.
272
all: Print all information that we have in a verbose manner, this
273
includes misses, etc.
274
short: Print information, but only one-line summaries
275
minimal: Only print a one-line summary when the package branch is
277
:param latest_pub: A LatestPublication instance
279
if verbosity == 'off':
281
if verbosity is None:
283
latest_ver, branch_ver = _get_newest_versions(the_branch, latest_pub)
284
place = latest_pub.place()
285
_report_freshness(latest_ver, branch_ver, place, verbosity,