Package: hghooks
ContentshghooksDocumentationInstallationUsageHow to skip the hooksSkipping specific pep8 errorsTrac integrationChanges0.7.0 (2016-05-05)0.6.0 (2013-04-17)0.5.5 (2013-02-01)0.5.4 (2012-10-12)0.5.3 (2012-10-12)0.5.2 (2012-01-12)0.5.1 (2011-11-16)0.5.0 (2011-11-06)0.4.3 (2011-10-23)0.4.2 (2011-02-24)0.4.1 (2011-01-11)0.4.0 (2011-01-09)0.3.2 (2010-11-08)0.3.1 (2010-10-21)0.3.0 (2010-10-17)0.2.1 (2010-10-14)0.2.0 (2010-10-14)0.1.2 (2010-08-31)0.1.1 (2010-06-13)0.1.0 (2010-06-13)hghookshghooks is a simple module that adds several useful hooks for use in
Mercurial hooks system.Right now it includes hooks for:pep8 checking of python filespyflakes checking of python filesjslint checking of javascript fileschecking for forgotten pdb statements in python filesTrac integration. This includes:
- Making sure at least a ticket is mentioned in the changeset message
- Updating the Trac ticket with the changesetDocumentationInstallationhghooks is distributed as a Python egg so is quite easy to install. You just
need to type the following command:easy_install hghooksAnd Easy Install will go to the Cheeseshop and grab the last hghooks for you.
It will also install it for you at no extra cost :-)UsageTo use one of the hooks provided by this package edit your hgrc file of
your Mercurial repository and add these lines:[hooks]
pretxncommit.pep8 = python:hghooks.code.pep8hook
pretxncommit.pyflakes = python:hghooks.code.pyflakeshook
pretxncommit.pdb = python:hghooks.code.pdbhook
pretxncommit.jslint = python:hghooks.code.jslinthookYou can add as many hooks as you need. From version 0.2.0 it supports the
pretxnchangegroup hook too.When using the pretxnchangegroup hook, hghooks’ default behavior is to check
only the last revision being pushed. If you want to check every new revision,
you can activate hghooks’ strict mode by adding these lines to your hgrc
file:[hghooks]
strict_checking = trueThis way you will enforce the correctness of every commit. Offending commits
would need to be fixed locally using queues.How to skip the hooksIf you need to avoid a hook for a specific changeset you can add one or
more of the following keywords to the commit message: no-pep8,
no-pyflakes and no-pdb.On the other hand, if you want to avoid a hook in a specific file you
can add a comment somewhere in the file saying so. For example:# hghooks: no-pyflakes no-pdb no-jslintin this case the pyflakes and pdb hooks will skip this file. The
“# hghooks:” prolog is important and you have to type it exactly
like that. Then add the skip keyworkds separated by spaces.Skipping specific pep8 errorsIf you want to ignore some pep8 errors you can do so by adding a [pep8]
configuration section into your hgrc file. For example, if you want
to allow longer than 79 character lines, you would add this configuration:[pep8]
ignore = E501The format of the value of the ignore option is a space separate list of
pep8 errors or warnings. Check pep8 documentation to see these codes.Note: this only works since pep8 0.6.0 and later versions.Trac integrationStarting with version 0.3.0 there is some limited support for Trac integration.Right now there are two useful hooks for those that use Trac as their project
system. The first one is a hook suitable for the pretxnchangegroup event in the
centralized repository that Trac syncs from that checks at least a ticket is
mentioned in the changeset message. The other one could be used in two ways:One is suitable for incoming event and will add a comment for every
changeset in the ticket mentioned in the changeset message. In summary,
one comment per commit.The other one is suitable for changegroup event. It all changesets will
be grouped in one comment and will be added in every ticket mentioned in
the changeset message. So for summarizing, it will register comment per
push.To use these hooks you must configure your repository with the Trac environment
path you want to integrate with. Write this in your .hg/hgrc repository conf:[trac]
environment = /full/path/to/your/trac/environmentNow you can add both hooks in the same configuration file:[hooks]
pretxnchangegroup.trac = python:hghooks.trachooks.ticket_checker
incoming.trac = python:hghooks.trachooks.ticket_updateror[hooks]
pretxnchangegroup.trac = python:hghooks.trachooks.ticket_checker
changegroup.trac = python:hghooks.trachooks.ticket_updaterRight now these hooks checks for the following pattern in your changeset
messages: [action] [ticket] [number] where action is any of ‘close’, ‘closed’,
‘closes’, ‘fix’, ‘fixed’, ‘fixes’, ‘addresses’, ‘references’, ‘refs’, ‘re’
and ‘see’, ticket is any of ‘ticket’, ‘issue’ and ‘bug’ and number is the
number of the ticket with a leading # character.In the ticket_checker hook only the presence of a ticket number and any
of these actions is checked. In the ticket_updater, additional changes
are done to the ticket depending on the action itself. And a comment
is added to the ticket with a configurable message.If you use Trac 0.12 and have more than one repository configured in
your environment you must tell the hook, which one you want to use. To
do so add the following option in the [trac] section of the repository hgrc
configuration file:[trac]
repo_name = your_repo_name_in_tracIf you don’t specify this option, the repository should be the default
repository in Trac. Otherwise, the links to the changeset will not work.You can also configure how the messages will look like in the Ticket. There
are two configuration options for that:[trac]
msg_template = (At [%(changeset)s]) %(msg)s
changeset_style = long-hexThe msg_template specifies how the text of the comments will looks like. It
has two placeholders: one for the changeset id and one for the changeset
description or message. As you can see in the above example, by putting
the changeset between brackets we automatically generate a Trac link to
that changeset in the ticket comment.The other option, changeset_style can have one of these three values:number: integer with the revision numberlong-hex: full hexadecimal hash of the changesetshort-hex: the first 12 characters of the long-hexBy default, short-hex is used as the changeset_style.You can also add more actions if the ones supplied with hghooks are not
enough for you. The extending mechanism used to allow this feature is
based in setuptools entry points so you must be familiar with them in
order to use them. Right now there are two entry points:hghooks.trac.ticket_commandshghooks.trac.token_commandsEach of them should point to a callable that returns a dictionary where
the keys are the action names and the values are callables that receive
a ticket and can modify them if they need it.Changes0.7.0 (2016-05-05)Add support for Mercurial >= 3.6.1. Thanks to Ernesto RevillaAdd support to detect pudb statements. Thanks to Andrey Kolomoets0.6.0 (2013-04-17)By default only check the last revision of a push. There is a configurable
option to get back the default strict behavior. Thanks to Gabriel Rodriguezpep257 support. Thanks to pszablow.0.5.5 (2013-02-01)Fix pep8 support for newer versions than 1.20.5.4 (2012-10-12)Fix documentation rst errors0.5.3 (2012-10-12)Remove pep8, pyflakes and pyjslint from the depenencies since they
are optionalMake Trac an optional dependency0.5.2 (2012-01-12)Fix pyjslint integration. Thanks to Alejandro Blanco.0.5.1 (2011-11-16)Use the new pyjslint 0.3.1.0.5.0 (2011-11-06)Add support to jslint through the pyjslint package. Contribution by Manuel
Viera and Pablo Martín.Add support for the changegroup hook type in the trachooks.ticket_updater
hook. In this case, merge all changeset messages into one message and
add just one comment to the Trac ticket. Manuel and Pablo.Use the server time in the trachooks.ticket_updater hook. Manuel and Pablo.0.4.3 (2011-10-23)Works with pyflakes 0.5.0 and backwards compatibility for previous versionsFixed pep8 –ignore handling, by Waldemar Kornewald0.4.2 (2011-02-24)Fix a bug with non ascii characters in the commit message0.4.1 (2011-01-11)Fix a bug when running the pyflakes hook over a syntactically wrong file0.4.0 (2011-01-09)Make pyflakes hook ignore those code lines with a “pyflakes:ignore”
comment0.3.2 (2010-11-08)Fix documentation0.3.1 (2010-10-21)Allow ignoring pep8 erros0.3.0 (2010-10-17)Add hooks for Trac integration:A pretxnchangegroup hook that checks a metion to a ticket exist in the
changeset message.An incoming hook that add a comment to the Trac ticket with the changeset
message.0.2.1 (2010-10-14)Fixes installation problem because setup.py was importing pep8 and pyflakesFixes bug in pdb checker when adding new files0.2.0 (2010-10-14)Support for the pretxnchangegroup hook0.1.2 (2010-08-31)Fixes issue #2 about erros when removing files0.1.1 (2010-06-13)Add documentatin about how to skip the checks0.1.0 (2010-06-13)Initial release