463
468
_register_directory()
470
# This is kept in __init__ so that we don't load lp_api_lite unless the branch
471
# actually matches. That way we can avoid importing extra dependencies like
473
_package_branch = lazy_regex.lazy_compile(
474
r'bazaar.launchpad.net.*?/'
475
r'(?P<user>~[^/]+/)?(?P<archive>ubuntu|debian)/(?P<series>[^/]+/)?'
476
r'(?P<project>[^/]+)(?P<branch>/[^/]+)?'
479
def _get_package_branch_info(url):
480
"""Determine the packaging information for this URL.
482
:return: If this isn't a packaging branch, return None. If it is, return
483
(archive, series, project)
485
m = _package_branch.search(url)
488
archive, series, project, user = m.group('archive', 'series',
490
if series is not None:
491
# series is optional, so the regex includes the extra '/', we don't
492
# want to send that on (it causes Internal Server Errors.)
493
series = series.strip('/')
495
user = user.strip('~/')
496
if user != 'ubuntu-branches':
498
return archive, series, project
501
def _check_is_up_to_date(the_branch):
502
info = _get_package_branch_info(the_branch.base)
505
archive, series, project = info
506
from bzrlib.plugins.launchpad import lp_api_lite
508
latest_pub = lp_api_lite.LatestPublication(archive, series, project)
509
latest_ver = latest_pub.get_latest_version()
510
t_latest_ver = time.time() - t
511
trace.mutter('LatestPublication.get_latest_version took %.3fs'
513
if latest_ver is None:
514
trace.note('Could not find a published version for packaging branch:\n'
515
' %s' % (the_branch.base,))
518
tags = the_branch.tags.get_tag_dict()
519
t_tag_dict = time.time() - t
520
trace.mutter('LatestPublication get_tag_dict took: %.3fs' % (t_tag_dict,))
521
if latest_ver in tags:
522
trace.note('Found most recent published version: %s'
523
' in packaging branch:\n %s'
524
% (latest_ver, the_branch.base))
526
place = archive.title()
527
if series is not None:
528
place = '%s/%s' % (place, series.title())
529
best_tag = lp_api_lite.get_most_recent_tag(tags, the_branch)
533
best_message = '\nThe most recent tag found is %s' % (best_tag,)
535
'Packaging branch is not up-to-date. The most recent published\n'
536
'version in %s is %s, but it is not in the branch tags for:\n %s%s'
537
% (place, latest_ver, the_branch.base, best_message))
539
def _register_hooks():
540
_mod_branch.Branch.hooks.install_named_hook('open',
541
_check_is_up_to_date, 'package-branch-up-to-date')
466
546
def load_tests(basic_tests, module, loader):
467
547
testmod_names = [
471
552
'test_lp_directory',