/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/launchpad/__init__.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2019-01-28 23:05:35 UTC
  • mfrom: (7254.2.1 drop-up-to-date-check)
  • Revision ID: breezy.the.bot@gmail.com-20190128230535-8uzi152xu5yxqn5i
Drop support for launchpad packaging branch up-to-date checking.

Merged from https://code.launchpad.net/~jelmer/brz/drop-up-to-date-check/+merge/362286

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
 
86
86
_register_directory()
87
87
 
88
 
# This is kept in __init__ so that we don't load lp_api_lite unless the branch
89
 
# actually matches. That way we can avoid importing extra dependencies like
90
 
# json.
91
 
_package_branch = lazy_regex.lazy_compile(
92
 
    r'bazaar.launchpad.net.*?/'
93
 
    r'(?P<user>~[^/]+/)?(?P<archive>ubuntu|debian)/(?P<series>[^/]+/)?'
94
 
    r'(?P<project>[^/]+)(?P<branch>/[^/]+)?'
95
 
    )
96
 
 
97
 
 
98
 
def _get_package_branch_info(url):
99
 
    """Determine the packaging information for this URL.
100
 
 
101
 
    :return: If this isn't a packaging branch, return None. If it is, return
102
 
        (archive, series, project)
103
 
    """
104
 
    if url is None:
105
 
        return None
106
 
    m = _package_branch.search(url)
107
 
    if m is None:
108
 
        return None
109
 
    archive, series, project, user = m.group('archive', 'series',
110
 
                                             'project', 'user')
111
 
    if series is not None:
112
 
        # series is optional, so the regex includes the extra '/', we don't
113
 
        # want to send that on (it causes Internal Server Errors.)
114
 
        series = series.strip('/')
115
 
    if user is not None:
116
 
        user = user.strip('~/')
117
 
        if user != 'ubuntu-branches':
118
 
            return None
119
 
    return archive, series, project
120
 
 
121
 
 
122
 
def _check_is_up_to_date(the_branch):
123
 
    info = _get_package_branch_info(the_branch.base)
124
 
    if info is None:
125
 
        return
126
 
    c = the_branch.get_config_stack()
127
 
    verbosity = c.get('launchpad.packaging_verbosity')
128
 
    if not verbosity:
129
 
        trace.mutter('not checking %s because verbosity is turned off'
130
 
                     % (the_branch.base,))
131
 
        return
132
 
    archive, series, project = info
133
 
    from . import lp_api_lite
134
 
    latest_pub = lp_api_lite.LatestPublication(archive, series, project)
135
 
    lp_api_lite.report_freshness(the_branch, verbosity, latest_pub)
136
 
 
137
 
 
138
 
def _register_hooks():
139
 
    _mod_branch.Branch.hooks.install_named_hook('open',
140
 
                                                _check_is_up_to_date, 'package-branch-up-to-date')
141
 
 
142
 
 
143
 
_register_hooks()
144
 
 
145
 
 
146
88
def load_tests(loader, basic_tests, pattern):
147
89
    testmod_names = [
148
90
        'test_account',
149
91
        'test_register',
150
92
        'test_lp_api',
151
 
        'test_lp_api_lite',
152
93
        'test_lp_directory',
153
94
        'test_lp_login',
154
95
        'test_lp_open',
187
128
topic_registry.register('launchpad',
188
129
                        _launchpad_help,
189
130
                        'Using Bazaar with Launchpad.net')
190
 
 
191
 
_mod_config.option_registry.register(
192
 
    _mod_config.Option('launchpad.packaging_verbosity', default=True,
193
 
                       from_unicode=_mod_config.bool_from_store,
194
 
                       help="""\
195
 
Whether to warn if a UDD package import branch is accessed that is out of date.
196
 
 
197
 
Setting this option to 'off' will disable verbosity.
198
 
"""))
199
 
_mod_config.option_registry.register(
200
 
    _mod_config.Option('launchpad_username', default=None,
201
 
                       help="The username to login with when conneting to Launchpad."))