/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 bzrlib/bugtracker.py

Add bzrlib.pyutils, which has get_named_object, a wrapper around __import__.

This is used to replace various ad hoc implementations of the same logic,
notably the version used in registry's _LazyObjectGetter which had a bug when
getting a module without also getting a member.  And of course, this new
function has unit tests, unlike the replaced code.

This also adds a KnownHooksRegistry subclass to provide a more natural home for
some other logic.

I'm not thrilled about the name of the new module or the new functions, but it's
hard to think of good names for such generic functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
 
128
128
    bugtracker_cpan_url = http://rt.cpan.org/Public/Bug/Display.html?id={id}
129
129
 
130
 
for CPAN's RT bug tracker.
 
130
would allow ``bzr commit --fixes cpan:1234`` to mark bug 1234 in CPAN's
 
131
RT bug tracker as fixed, or::
 
132
 
 
133
    bugtracker_hudson_url = http://issues.hudson-ci.org/browse/{id}
 
134
 
 
135
would allow ``bzr commit --fixes hudson:HUDSON-1234`` to mark bug HUDSON-1234
 
136
in Hudson's JIRA bug tracker as fixed.
131
137
"""
132
138
 
133
139
 
228
234
    UniqueIntegerBugTracker('gnome', 'http://bugzilla.gnome.org/show_bug.cgi?id='))
229
235
 
230
236
 
231
 
class URLParametrizedIntegerBugTracker(IntegerBugTracker):
 
237
class URLParametrizedBugTracker(BugTracker):
232
238
    """A type of bug tracker that can be found on a variety of different sites,
233
239
    and thus needs to have the base URL configured.
234
240
 
235
241
    Looks for a config setting in the form '<type_name>_<abbreviation>_url'.
236
 
    `type_name` is the name of the type of tracker (e.g. 'bugzilla' or 'trac')
237
 
    and `abbreviation` is a short name for the particular instance (e.g.
238
 
    'squid' or 'apache').
 
242
    `type_name` is the name of the type of tracker and `abbreviation`
 
243
    is a short name for the particular instance.
239
244
    """
240
245
 
241
246
    def get(self, abbreviation, branch):
256
261
        return urlutils.join(self._base_url, self._bug_area) + str(bug_id)
257
262
 
258
263
 
 
264
class URLParametrizedIntegerBugTracker(IntegerBugTracker, URLParametrizedBugTracker):
 
265
    """A type of bug tracker that can be found on a variety of different sites,
 
266
    and thus needs to have the base URL configured, but only allows integer bug IDs.
 
267
 
 
268
    Looks for a config setting in the form '<type_name>_<abbreviation>_url'.
 
269
    `type_name` is the name of the type of tracker (e.g. 'bugzilla' or 'trac')
 
270
    and `abbreviation` is a short name for the particular instance (e.g.
 
271
    'squid' or 'apache').
 
272
    """
 
273
 
259
274
tracker_registry.register(
260
275
    'trac', URLParametrizedIntegerBugTracker('trac', 'ticket/'))
261
276
 
264
279
    URLParametrizedIntegerBugTracker('bugzilla', 'show_bug.cgi?id='))
265
280
 
266
281
 
267
 
class GenericBugTracker(URLParametrizedIntegerBugTracker):
 
282
class GenericBugTracker(URLParametrizedBugTracker):
268
283
    """Generic bug tracker specified by an URL template."""
269
284
 
270
285
    def __init__(self):