Commit Graph

103 Commits

Author SHA1 Message Date
Yuya Nishihara
5249aa5b36 cmdutil: pass templatespec tuple directly to changeset_templater (API)
A fewer number of arguments should be better.
2017-04-22 19:02:47 +09:00
Wagner Bruna
8d9192e033 bugzilla: fix typo in help text 2017-05-31 19:24:00 -03:00
Gregory Szorc
48793a9cc5 bugzilla: use util.urlreq.urlparse
And stop saving a module variable because it shouldn't be
necessary.
2017-03-21 22:39:52 -07:00
John Mulligan
01f8fb7c8f bugzilla: add a rest api backend (usable with bugzilla 5.0+)
Add support for the bugzilla rest api documented at
 https://wiki.mozilla.org/Bugzilla:REST_API
and at
 https://bugzilla.readthedocs.io/en/latest/

This backend has the following benefits:
* It supports the bugzilla api keys so hgrc does not need to contain
  a user's bugzilla password
* Works with Mercurial's "hostfingerprints" support making handling
  bugzilla instances with self-signed certs easier
* Does not use xmlrpc ;-)

Adds configuration item 'apikey' in [bugzilla] section.

My major concern with these patches is if the approach to HTTP access
is the right way for an extension and if hooking into request object
and the overriding the get_method to perform PUT requests was a
sensible approach.

# no-check-commit
2017-02-09 15:20:41 -05:00
Augie Fackler
ce63567c20 bugzilla: stop mentioning Pythons older than 2.6
We don't support those anyway.
2016-11-21 17:52:32 -05:00
Augie Fackler
4e1c384d0a extensions: change magic "shipped with hg" string
I've caught multiple extensions in the wild lying about being
'internal', so it's time to move the goalposts on people. Goalpost
moving will continue until third party extensions stop trying to
defeat the system.
2016-08-23 11:26:08 -04:00
Pulkit Goyal
fdc0861e35 py3: conditionalize xmlrpclib import
The xmlrpclib library is renamed to xmlrpc.client in python 3
2016-06-27 16:37:37 +05:30
Pulkit Goyal
5fcc6a2628 py3: conditionalize the urlparse import
The urlparse library is renamed to urllib.parse in python 3
2016-06-27 16:16:10 +05:30
Yuya Nishihara
59e8edaa91 bugzilla: do not load style file if template is specified (BC)
This prepares for the API change to support template aliases. I'm going to
extract a factory function of templater that reads a map file:

  # original
  templater(mapfile, ..., cache, ...)
  # new
  templater.frommapfile(mapfile, ...)  # read mapfile to build cache/map
  templater(..., cache, ...)           # use specified cache (= map elements)

This will make it clear to isolate stock styles (i.e. map files) from user
aliases. Template aliases should be applied to command arguments and templates
in hgrc, but not to map files. Otherwise, our stock styles and web templates
could be modified unintentionally.

This patch makes sure that either "tmpl" or "mapfile" is exclusively set. It's
theoretically a behavior change, since you could put new keywords in template
by defining them in a map file before:

  # mapfile
  foo = "{rev}"
  # hgrc
  [bugzilla]
  style = mapfile
  template = {foo}

But the old behavior would be a bug because bugzilla.template is documented
as "overrides style if specified". Also, common log-like templates and
formatter doesn't allow using mapfile-keywords in a separate template. So
I decided to make a BC.

Since there was no test for the bugzilla extension, this adds new test that
covers style/template output.
2016-04-04 22:48:34 +09:00
Gregory Szorc
6dc0d92138 bugzilla: use absolute_import 2016-02-09 17:31:50 -08:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Augie Fackler
f95a6caba1 extensions: document that testedwith = 'internal' is special
Extension authors (notably at companies using hg) have been
cargo-culting the `testedwith = 'internal'` bit from hg's own
extensions, which then defeats our "file bugs over here" logic in
dispatch. Let's be more aggressive about trying to give extension
authors a hint about what testedwith should say.
2015-04-28 16:44:37 -04:00
Yuya Nishihara
71c4aa007f templater: remove noop calls of parsestring(s, quoted=False) (API)
Since e926f2ef639a, parsestring(s, quoted=False) just returns s.
2015-05-04 10:01:03 +09:00
Jim Hague
15bbbb3991 bugzilla: stop trying to cache setup across hook invocation
In the context of standalone Hg receiving a set of incoming changes, it makes
sense for the Bugzilla module to cache basic setup to avoid reconnecting
to Bugzilla for each change. After processing the changes, Hg will exit
and so the connection is short-lived.

But this doesn't work too well when used from a long-lived environment
such as hgweb or Kallithea where, for example, the connection can time out.
So take the simple approach, abandon the cache and do the basic setup on
each call. This fixes current problems with Kallithea.
2014-07-03 10:48:37 +01:00
Jim Hague
a8d33ec9dd bugzilla: correct config documentation error
The config documentation specifies the wrong access method in the XMLRPC+email
configuration.
2014-07-03 10:56:03 +01:00
Jim Hague
14c4476395 bugzilla: support Bugzilla 4.4.3+ API login token authentication (issue4257)
Bugzilla 4.4.3 and later remove the old cookie based session authentication
from the Web Services API and replace it with a login token. The session
can now also be restricted to the originating IP.

Add the necessary to the extension so it works with 4.4.3 and later.
2014-05-23 17:29:04 +01:00
Augie Fackler
98c42c8081 bugzilla: move from dict() construction to {} literals
The latter are both faster and more consistent across Python 2 and 3.
2014-03-12 13:13:10 -04:00
Matt Mackall
694de7920e changeset_templater: remove use_template method 2014-03-08 16:14:08 -06:00
Bryan O'Sullivan
dc9ede17dc Merge spelling fixes 2012-09-11 08:36:09 -07:00
timeless@mozdev.org
49f2d80b82 en-us: recognized 2012-08-17 13:58:19 -07:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Matt Mackall
cb4824284b merge with stable 2012-06-06 21:17:33 -05:00
Jim Hague
1b46810a77 bugzilla: stop bugs always being marked as fixed in xmlrpc (issue3484)
Bugs should only be marked fixed if the comment parser gives them the
fixed state. xmlrpc+email got this right, xmlrpc screwed it up.
2012-06-06 16:44:17 +01:00
Augie Fackler
96d44b39f7 hgext: mark all first-party extensions as such 2012-05-15 14:37:49 -05:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Steven Stallion
66e5651b6d bugzilla: fix transport initialization on python 2.4 2012-05-11 22:48:19 -07:00
Matt Mackall
4a144a5db5 merge with stable 2012-03-04 16:48:04 -06:00
Jim Hague
cad5cac971 bugzilla: add xmlrpcemail submission for Bugzilla 3.6 email interface
Some of the formatting details required for bug submission via email
changed between Bugzilla 3.4 and 3.6. Bugzilla 3.4 requires lines of
the form '@fieldname = value', while 3.6 wants '@fieldname value'.
Also the field @bug_id in 3.4 becomes @id in 3.6.

Bugzilla up to and including 4.0 also recognises the 3.4 format. To save
surprises in the future, check the Bugzilla version and use the 3.6
format from all major versions >= 4. At some point we will
drop support for Bugzilla prior to 3.6 and support the new format only.
2012-03-01 14:50:31 +00:00
Jim Hague
ef9d8e60cc bugzilla: allow change comment to mark bugs fixed
Add a second regular expression used when scanning change comments.
Bugs matched by this new regular expression have the bug comments and
optionally hours updated as with the first regular expression, but they
are also marked as fixed.

The bug status and resolution to set to mark a bug as fixed can be
configured. By default status is set to RESOLVED and resolution to
FIXED, the default Bugzilla settings.

For example, a change comment containing 'Fixes 1234 h1.5' will be
added to bug 1234, the bug will have its working time increased by
1.65 hours, and the bug will be marked RESOLVED/FIXED.

Change comments may contain both bug update and fix instructions. If
the same bug ID occurs in both, the last instruction found takes
precedence.

The patch adds new bug states 'bug_status' and 'resolution' and actions
to update them to the XMLRPC and XMLRPC/email access methods. XMLRPC does
not support marking bugs as fixed when used with Bugzilla versions prior
to 4.0. When used with an earlier Bugzilla version, a warning is issued
and only comment and hours updated.
2012-03-01 15:27:24 +00:00
Jim Hague
6c5c699aef bugzilla: extract optional hours from commit message and update bug time
If an 'hours' group is present in the bug matching regular expression,
and that group contains a float value, update the bug working time in
Bugzilla with those hours.

The patch adds a key 'hours' to the bug state dictionary, and adds
support for the key to the XMLRPC and XMLRPC/email access methods.
The MySQL access method is not supported; a warning is given.
2012-03-01 15:25:37 +00:00
Jim Hague
df2c50f6f8 bugzilla: modify access interface to include new bug states
As a first step to allowing comment text to update bug state, rework the
Bugzilla access interface to use a dictionary keyed on bug ID. Dictionary
entries will contain new state info in future changes.
2012-03-01 14:51:40 +00:00
Jim Hague
d51f75e5f8 bugzilla: correct comment typo 2012-03-01 14:42:23 +00:00
Jim Hague
dae7a893f8 bugzilla: stop XMLRPC requests from requesting gzipped responses
Python 2.7 introduced support for gzip encoding in xmlrpclib.Transport.
We do our own handling of responses, and don't currently support gzip encoding.
So to run successfully under Python 2.7 with a web server configured
to gzip encode, stop XMLRPC requests from announcing gzip encoding support.
2012-02-29 17:43:03 +00:00
Jim Hague
627ffc395e bugzilla: make XMLRPC interface support http and https access
Inadvertently support is currently only for https. For some reason I
thought xmlrpclib.SafeTransport did http and https, but it is https only.

So create http and https XMLRPC transports that retain cookies. Decide which
to use by inspecting the Bugzilla URL.
2012-01-11 16:54:29 +00:00
Wagner Bruna
e9d8028876 bugzilla: fix typo in documentation 2011-06-14 20:08:35 -03:00
Adrian Buehlmann
e94d06bb79 rename explain_exit to explainexit 2011-05-06 15:31:09 +02:00
Jim Hague
80a125d068 bugzilla: more documentation formatting fixups
Correct typo in numbering list of access methods.
Convert a section reference and a template parameter reference into
literal text, for consistency with other use.
2011-04-06 11:30:08 +01:00
Martin Geisler
9dfcd73e5b bugzilla: convert a verbatim block to a field list 2011-04-05 10:22:58 +02:00
Martin Geisler
3d9f5b0e1f bugzilla: fix reST error introduced in a2e32837d8f5
All blocks must be indented. Here we can use a field list instead of a
verbatim block for a real list layout.
2011-04-05 10:20:59 +02:00
Jim Hague
65534172e2 bugzilla: more documentation fixes
Correct formatting of the possible values of bugzilla.version.
Fix typo and polish XMLRPC/email mode description.
2011-04-04 17:37:18 +01:00
Jim Hague
3be6a4e3fe bugzilla: correct sample configurations
Use consistent sample domains and wording in all configuration examples.

Add missing template and strip parameters to XMLRPC examples and correct
Bugzilla URL key in XMLRPC+email.
2011-04-04 13:31:37 +01:00
Patrick Mezard
964b307b71 bugzilla: fix documentation typo 2011-04-01 20:40:27 +02:00
Martin Geisler
d8a6341a37 bugzilla: fix bad reST markup
The indented second line turned the first line into a description
header.
2011-04-01 12:30:40 +02:00
Martin Geisler
8cb176c788 bugzilla: markup literal text as such 2011-04-01 12:27:12 +02:00
Martin Geisler
0d1109205c bugzilla: refer to hgrc(5) man page with normal notation 2011-04-01 12:09:11 +02:00
Martin Geisler
459fedb4ee bugzilla: markup section names as literal text 2011-04-01 12:07:37 +02:00
Martin Geisler
f9635687a7 bugzilla: show usermap syntax more clearly 2011-04-01 12:05:19 +02:00
Martin Geisler
c285f18e77 bugzilla: use standard section.name notation 2011-04-01 12:03:23 +02:00
Martin Geisler
36682a123f bugzilla: prefix each config option with section 2011-04-01 12:00:57 +02:00