41
41
# see http://wiki.bazaar.canonical.com/Specs/BranchRegistrationTool
43
# Since we are a built-in plugin we share the bzrlib version
44
from bzrlib import version_info
46
43
from bzrlib.lazy_import import lazy_import
47
44
lazy_import(globals(), """
48
45
from bzrlib import (
49
branch as _mod_branch,
55
from bzrlib import bzrdir
52
branch as _mod_branch,
55
# Since we are a built-in plugin we share the bzrlib version
56
58
from bzrlib.commands import (
463
465
_register_directory()
467
# This is kept in __init__ so that we don't load lp_api_lite unless the branch
468
# actually matches. That way we can avoid importing extra dependencies like
470
_package_branch = lazy_regex.lazy_compile(
471
r'bazaar.launchpad.net.*?/'
472
r'(?P<user>~[^/]+/)?(?P<archive>ubuntu|debian)/(?P<series>[^/]+/)?'
473
r'(?P<project>[^/]+)(?P<branch>/[^/]+)?'
476
def _get_package_branch_info(url):
477
"""Determine the packaging information for this URL.
479
:return: If this isn't a packaging branch, return None. If it is, return
480
(archive, series, project)
482
m = _package_branch.search(url)
485
archive, series, project, user = m.group('archive', 'series',
487
if series is not None:
488
# series is optional, so the regex includes the extra '/', we don't
489
# want to send that on (it causes Internal Server Errors.)
490
series = series.strip('/')
492
user = user.strip('~/')
493
if user != 'ubuntu-branches':
495
return archive, series, project
498
def _check_is_up_to_date(the_branch):
499
info = _get_package_branch_info(the_branch.base)
502
c = the_branch.get_config()
503
verbosity = c.get_user_option('launchpad.packaging_verbosity')
504
if verbosity is not None:
505
verbosity = verbosity.lower()
506
if verbosity == 'off':
507
trace.mutter('not checking %s because verbosity is turned off'
508
% (the_branch.base,))
510
archive, series, project = info
511
from bzrlib.plugins.launchpad import lp_api_lite
512
latest_pub = lp_api_lite.LatestPublication(archive, series, project)
513
lp_api_lite.report_freshness(the_branch, verbosity, latest_pub)
516
def _register_hooks():
517
_mod_branch.Branch.hooks.install_named_hook('open',
518
_check_is_up_to_date, 'package-branch-up-to-date')
466
523
def load_tests(basic_tests, module, loader):
467
524
testmod_names = [
471
529
'test_lp_directory',