Skip to content

Commit a899cad

Browse files
committed
Issue #16405: Explain how to set up the whitespace commit hook locally.
Original patch by Carol Willing.
1 parent 830784e commit a899cad

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

committing.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,33 @@ create or modify versioned files. The public repository has a hook which
304304
will reject all changesets having the wrong line endings, so enabling this
305305
extension on your local computer is in your best interest.
306306

307+
As a core developer, it can be very helpful to set up the same commit checks
308+
locally that the main repo enforces for incoming patch sets. This can save a
309+
great deal of frustration with the server rejecting ``hg push`` for changes
310+
(which can be especially time consuming if you have already merged changes
311+
across branches).
312+
313+
Configuring and using the whitespace checking hook found in the `hooks
314+
repository`_ will help check incoming patch sets. To configure a hook,
315+
add configuration settings to ``~/.hgrc`` for the relevant repo(s) (remember
316+
to adjust the path appropriately for the checked out location of the
317+
`hooks repository`_). To configure a "pretxncommit" hook that will check
318+
whitespace before the changeset is committed and can thus abort the commit
319+
if whitespace is found, add::
320+
321+
[hooks]
322+
pretxncommit.whitespace = python:~/path/to/checkwhitespace.py:check_whitespace_single
323+
324+
Another option is to configure it as a "commit" hook; if used, a warning
325+
will still be issued but the changeset will be applied anyway::
326+
327+
[hooks]
328+
commit = python:~/path/to/checkwhitespace.py:check_whitespace_single
307329

308330
.. _configuration file: http://www.selenic.com/mercurial/hgrc.5.html#files
309331
.. _extended diff format: http://www.selenic.com/mercurial/hg.1.html#diffs
310332
.. _eol extension: http://mercurial.selenic.com/wiki/EolExtension
333+
.. _hooks repository: https://hg.python.org/hooks
311334

312335

313336
Clones Setup

0 commit comments

Comments
 (0)