Commit Graph

103 Commits

Author SHA1 Message Date
Boris Feld
16425ec90a configitems: register the 'notify.config' config 2017-06-30 03:43:18 +02:00
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
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
FUJIWARA Katsunori
04f80329bc notify: make a message translatable
This message has been overlooked by check-code, because it starts with
non-alphabet character ('\').

Making this message translatable seems reasonable, because messages
below in same function are already translatable

  - '\ndiffs (truncated from %d to %d lines):\n\n'
  - '\ndiffs (%d lines):\n\n'

This is also a part of preparation for making "missing _() in ui
message" detection of check-code more exact.
2016-05-26 01:57:34 +09:00
Yuya Nishihara
a5c934df3c py3: move up symbol imports to enforce import-checker rules
Since (b) is banned, we should do the same for (a) for consistency.

 a) from mercurial import hg
    from mercurial.i18n import _

 b) from . import hg
    from .i18n import _
2016-05-14 14:03:12 +09:00
Yuya Nishihara
b427a832a6 notify: do not load style file if template is specified (BC)
This patch makes sure that either "tmpl" or "mapfile" is exclusively set,
which is the same behavior as common log-like templates and formatter outputs.

See the previous patch for why.
2016-04-04 22:50:50 +09:00
timeless
78f32a823b notify: use absolute_import 2016-03-02 21:48:08 +00: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
Bruce Cran
f9dd2d6f9f notify: fix fromauthor setting for 'incoming' hook type (issue4194)
Set the author field in notification emails for the 'incoming' hook type
in addition to 'changegroup' and 'outgoing' types.
2015-10-05 10:43:16 -06: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
Pierre-Yves David
a748b89b23 notify: drop import required by Python 2.4
Toto, I've a feeling we're not in anno 2004 anymore.
2015-05-18 16:24:16 -05: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
Jordi Gutiérrez Hermoso
8eb132f5ea style: kill ersatz if-else ternary operators
Although Python supports `X = Y if COND else Z`, this was only
introduced in Python 2.5. Since we have to support Python 2.4, it was
a very common thing to write instead `X = COND and Y or Z`, which is a
bit obscure at a glance. It requires some intricate knowledge of
Python to understand how to parse these one-liners.

We change instead all of these one-liners to 4-liners. This was
executed with the following perlism:

    find -name "*.py" -exec perl -pi -e 's,(\s*)([\.\w]+) = \(?(\S+)\s+and\s+(\S*)\)?\s+or\s+(\S*)$,$1if $3:\n$1    $2 = $4\n$1else:\n$1    $2 = $5,' {} \;

I tweaked the following cases from the automatic Perl output:

    prev = (parents and parents[0]) or nullid
    port = (use_ssl and 443 or 80)
    cwd = (pats and repo.getcwd()) or ''
    rename = fctx and webutil.renamelink(fctx) or []
    ctx = fctx and fctx or ctx
    self.base = (mapfile and os.path.dirname(mapfile)) or ''

I also added some newlines wherever they seemd appropriate for readability

There are probably a few ersatz ternary operators still in the code
somewhere, lurking away from the power of a simple regex.
2015-03-13 17:00:06 -04:00
Siddharth Agarwal
134022a8b9 notify: explicitly honor all diffopts
The notify output doesn't seem to be parseable anyway, what with the maxdiff
config option. Plus it is designed mainly for servers where hopefully the
admins are doing sensible things.
2014-11-18 21:47:47 -08:00
Matt Mackall
694de7920e changeset_templater: remove use_template method 2014-03-08 16:14:08 -06:00
Augie Fackler
67877b90cc python2.4: fix imports of sub-packages of the email package
These all have an obvious comment so if/when we finally ditch Python
2.4 we can eradicate them easily.
2013-09-24 15:10:32 -04:00
Augie Fackler
8031af5c75 notify: correct import of email module, sort stdlib modules to top 2013-09-20 10:16:55 -04:00
Michal Sznajder
d536428fac notify: support revset selection for subscriptions
A repo pattern for any notify configuration contains a glob matching the
path to the repo. Additionally, it may now contain a revset spec, separated
from the glob by '#'.

Example:
  [reposubs]
  */widgets#branch(release) = qa-team@example.com

This sends to ``qa-team@example.com`` whenever a changeset on the ``release``
branch triggers a notification in any repository ending in ``widgets``.

This patch was completely done by David Champion <dgc@uchicago.edu> with me
making tiny changes to his tests.
2012-08-13 22:42:10 +02:00
Martin Geisler
f92437e97c merge with stable 2012-06-13 20:14:28 +02:00
David Champion
fe8fba0ab7 notify: various fixes to docstring
Typo corrections, grammar adjustments, clarity improvements.
2012-05-29 07:07:10 -05: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
FUJIWARA Katsunori
116491f524 doc: fix careless document miss in help of hgext/notify
according to configuration example below, and direction of changeset
transference, this paragraph should describe about "changegroup" hook.

  [hooks]
  # one email for each incoming changeset
  incoming.notify = python:hgext.notify.hook
  # one email for all incoming changesets
  changegroup.notify = python:hgext.notify.hook

  # one email for all outgoing changesets
  outgoing.notify = python:hgext.notify.hook
2012-04-23 00:30:45 +09:00
Nikolaus Schueler
efb688abc6 notify: change behavior of "changegroup" hook
Change the behavior so that the sender (the "From" header in the notification
mail) in case of the "changegroup" hook is the user that did the first commit
in the changegroup.  The option is configurable, if you set "notify.fromauthor"
to "True" in your config, the new behavior is activated.  If you do not set the
option, the behavior is as before.  The commit adds to an existing test to show
various aspects of the changed behavior.
2011-12-15 13:57:54 +01:00
Mads Kiilerich
ae4bd7a809 notify: add option for writing to mbox
This makes it possible to test how the mails that are sent _really_ look like.
2011-11-23 02:36:33 +01:00
Patrick Mezard
50825774f7 notify: rewrite user documentation
The main intent is to turn the reference help into a configuration walkthrough.
It also fix several things:
- Do not suggest to use it for commit notifications, it cannot work
- Fix notify.strip default value
- Mention that subscriptions can be setup in Mercurial configuration files
- Improve notify.strip and notify.domain documentation
2011-07-26 21:30:12 +02:00
Patrick Mezard
6be8a9192e notify: remove unused url() method 2011-07-13 19:23:33 +02:00
Ingo Bressler
215b100937 notify: send changesets on 'outgoing' hook, updated doc 2011-06-14 13:29:25 +02:00
Matt Mackall
a8dd64dcb0 misc: replace .parents()[0] with p1() 2011-04-04 16:21:59 -05:00
Yuya Nishihara
92b5cbe067 notify: use util.ellipsis() to truncate long subject 2010-12-24 01:17:18 +09:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Martin Geisler
70de345b15 hgext: enable extensions without "hgext." prefix in help texts 2009-12-22 00:50:03 +01:00
David Champion
93e20c18e6 notify: permit suppression of merge changeset notification
In some environments merges occur regularly but with no conflicts, and
committers find merge notifications more of a bother than a help.

By setting merge=False in [notify], merge notifications are suppressed.
This works both for incoming and for changegroup hooks.
2009-09-23 02:31:09 -05:00
Bryan O'Sullivan
c2ccd4cd98 Merge with crew 2009-09-28 13:21:41 -07:00
Martin Geisler
9f1896c083 do not attempt to translate ui.debug output 2009-09-19 01:15:38 +02:00
Bryan O'Sullivan
f90184795a notify: make it possible to pass extra info into templates 2009-08-24 16:30:42 -07:00
Dirkjan Ochtman
8bd1e15bc5 merge with crew-stable 2009-08-05 17:21:29 +02:00
Christian Ebert
ba76e4ec6a notify: do not mime encode multipart templates
Mulitpart templates should take care of this themselves.
See http://www.selenic.com/pipermail/mercurial/2009-July/027017.html

Also catch potential parsing errors gracefully.
2009-08-05 17:19:08 +02:00
Martin Geisler
e682fe597d notify: wrap docstrings at 70 characters 2009-07-26 01:55:18 +02:00
Martin Geisler
3951831e0b commands: use minirst parser when displaying help 2009-07-16 23:25:26 +02:00
Nicolas Dumazet
7eadbe8d42 for calls expecting bool args, pass bool instead of int
str.splitlines and email.message.as_string both expect a bool argument
defaulting at False: replace f(1) by f(True) and f(0) by f()
2009-07-13 09:50:26 +09:00
Martin Geisler
82d550f2c0 notify: fix indentation in module docstring 2009-07-09 22:43:24 +02:00
Martin Geisler
c5357392bb notify: cleanup module docstring 2009-07-09 22:42:43 +02:00
Martin Geisler
06ba3dfad7 notify: wrapped docstrings at 78 characters 2009-07-07 23:54:42 +02:00
Dirkjan Ochtman
c8e6583765 extensions: change descriptions for hook-providing extensions
Thanks to timeless and Dave Townsend for advice!
2009-06-24 13:42:34 +02:00
Cédric Duval
dbcec5595d extensions: improve the consistency of synopses
Trying as much as possible to consistently:
 - use a present tense predicate followed by a direct object
 - verb referring directly to the functionality provided
   (ie. not "add command that does this" but simple "do that")
 - keep simple and to the point, leaving details for the long help
   (width is tight, possibly even more so for translations)

Thanks to timeless, Martin Geisler, Rafael Villar Burke, Dan Villiom
Podlaski Christiansen and others for the helpful suggestions.
2009-06-22 15:48:08 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Martin Geisler
91a80784c5 notify: turned a set-like dict into a real set 2009-04-24 17:32:18 +02:00