/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

  • Committer: Vincent Ladeuil
  • Date: 2012-01-18 14:09:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120118140919-rlvdrhpc0nq1lbwi
Change set/remove to require a lock for the branch config files.

This means that tests (or any plugin for that matter) do not requires an
explicit lock on the branch anymore to change a single option. This also
means the optimisation becomes "opt-in" and as such won't be as
spectacular as it may be and/or harder to get right (nothing fails
anymore).

This reduces the diff by ~300 lines.

Code/tests that were updating more than one config option is still taking
a lock to at least avoid some IOs and demonstrate the benefits through
the decreased number of hpss calls.

The duplication between BranchStack and BranchOnlyStack will be removed
once the same sharing is in place for local config files, at which point
the Stack class itself may be able to host the changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
from bzrlib import registry
18
20
from bzrlib.lazy_import import lazy_import
19
21
lazy_import(globals(), """
48
50
 
49
51
    bzr commit --fixes <tracker>:<id>
50
52
 
 
53
or::
 
54
 
 
55
    bzr commit --fixes <id>
 
56
 
51
57
where "<tracker>" is an identifier for the bug tracker, and "<id>" is the
52
58
identifier for that bug within the bugtracker, usually the bug number.
 
59
If "<tracker>" is not specified the ``bugtracker`` set in the branch
 
60
or global configuration is used.
53
61
 
54
62
Bazaar knows about a few bug trackers that have many users. If
55
63
you use one of these bug trackers then there is no setup required to
93
101
--fixes`` to mark bugs in that tracker as being fixed by that commit. For
94
102
example::
95
103
 
96
 
    bugzilla_squid_url = http://www.squid-cache.org/bugs
 
104
    bugzilla_squid_url = http://bugs.squid-cache.org
97
105
 
98
106
would allow ``bzr commit --fixes squid:1234`` to mark Squid's bug 1234 as
99
107
fixed.
127
135
 
128
136
    bugtracker_cpan_url = http://rt.cpan.org/Public/Bug/Display.html?id={id}
129
137
 
130
 
for CPAN's RT bug tracker.
 
138
would allow ``bzr commit --fixes cpan:1234`` to mark bug 1234 in CPAN's
 
139
RT bug tracker as fixed, or::
 
140
 
 
141
    bugtracker_hudson_url = http://issues.hudson-ci.org/browse/{id}
 
142
 
 
143
would allow ``bzr commit --fixes hudson:HUDSON-1234`` to mark bug HUDSON-1234
 
144
in Hudson's JIRA bug tracker as fixed.
131
145
"""
132
146
 
133
147
 
225
239
 
226
240
 
227
241
tracker_registry.register('gnome',
228
 
    UniqueIntegerBugTracker('gnome', 'http://bugzilla.gnome.org/show_bug.cgi?id='))
229
 
 
230
 
 
231
 
class URLParametrizedIntegerBugTracker(IntegerBugTracker):
 
242
    UniqueIntegerBugTracker('gnome',
 
243
                            'http://bugzilla.gnome.org/show_bug.cgi?id='))
 
244
 
 
245
 
 
246
class URLParametrizedBugTracker(BugTracker):
232
247
    """A type of bug tracker that can be found on a variety of different sites,
233
248
    and thus needs to have the base URL configured.
234
249
 
235
250
    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').
 
251
    `type_name` is the name of the type of tracker and `abbreviation`
 
252
    is a short name for the particular instance.
239
253
    """
240
254
 
241
255
    def get(self, abbreviation, branch):
242
256
        config = branch.get_config()
243
257
        url = config.get_user_option(
244
 
            "%s_%s_url" % (self.type_name, abbreviation))
 
258
            "%s_%s_url" % (self.type_name, abbreviation), expand=False)
245
259
        if url is None:
246
260
            return None
247
261
        self._base_url = url
256
270
        return urlutils.join(self._base_url, self._bug_area) + str(bug_id)
257
271
 
258
272
 
 
273
class URLParametrizedIntegerBugTracker(IntegerBugTracker,
 
274
                                       URLParametrizedBugTracker):
 
275
    """A type of bug tracker that  only allows integer bug IDs.
 
276
 
 
277
    This can be found on a variety of different sites, and thus needs to have
 
278
    the base URL configured.
 
279
 
 
280
    Looks for a config setting in the form '<type_name>_<abbreviation>_url'.
 
281
    `type_name` is the name of the type of tracker (e.g. 'bugzilla' or 'trac')
 
282
    and `abbreviation` is a short name for the particular instance (e.g.
 
283
    'squid' or 'apache').
 
284
    """
 
285
 
259
286
tracker_registry.register(
260
287
    'trac', URLParametrizedIntegerBugTracker('trac', 'ticket/'))
261
288
 
264
291
    URLParametrizedIntegerBugTracker('bugzilla', 'show_bug.cgi?id='))
265
292
 
266
293
 
267
 
class GenericBugTracker(URLParametrizedIntegerBugTracker):
 
294
class GenericBugTracker(URLParametrizedBugTracker):
268
295
    """Generic bug tracker specified by an URL template."""
269
296
 
270
297
    def __init__(self):