Ticket #7743 (closed enhancement: wontfix)
Opened 3 years ago
Last modified 19 months ago
Add/document commit-hook
| Reported by: | Marcus Lindblom <macke@…> | Owned by: | cboos |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | plugin/mercurial | Version: | 0.11 |
| Severity: | normal | Keywords: | multirepos |
| Cc: | |||
| Release Notes: | |||
| API Changes: | |||
Description
There is a commit hook here which IMHO should be incorporated into the plugin.
The comments also refer to a built-in hook, but I was unable to find it (neither in code nor on the TracMercurial page).
Attachments
Change History
comment:1 Changed 3 years ago by cboos
comment:2 Changed 2 years ago by anonymous
looks like #7723 has been fixed; does that mean there's a way to do this now?
comment:3 Changed 2 years ago by rblank
In the MultiRepos branch, the automatic change of tickets based on commit messages has been re-written as a proper plugin (source:sandbox/multirepos/tracopt/ticket/commit_updater.py), which is independent of the VC backend. So there's nothing more to be done in the Mercurial plugin. We still need to document how to call the generic hook (trac-admin $ENV changeset added) for the various backends.
I suggest we close this against 0.12-multirepos.
comment:4 Changed 2 years ago by cboos
- Keywords multirepos added
- Milestone changed from not applicable to mercurial-plugin
- Priority changed from normal to high
comment:5 Changed 2 years ago by dholth
This is the Mercurial hook I use to automatically close tickets when "fixes #1234" appears in a commit message. Must also enable the CommitTicketUpdater plugin.
#!/bin/sh
# Notify trac when new Mercurial changesets arrive.
# Short repository name must be the same as its directory.
# Add to hgrc in the trac repository as
# [hooks]
# changegroup.trac = /path/to/this/script.sh
ENVIRON=/path/to/trac/environ
REPONAME=`basename $PWD`
REVS=`hg log -r $HG_NODE:tip --template {node}\ `
CMD="/usr/bin/trac-admin $ENVIRON added $REPONAME $REVS"
$CMD
comment:6 Changed 2 years ago by rblank
You also need to set the "commit" hook, and your current script might break for large numbers of revisions (ok, thousands, so that's not going to happen very often). See the bottom of MultipleRepositorySupport#Merge for a complete example.
comment:7 Changed 19 months ago by rblank
- Milestone plugin - mercurial deleted
- Resolution set to wontfix
- Status changed from new to closed
Superseded by the CommitTicketUpdater.



The hook itself: http://www.bitbucket.org/madssj/mercurial-trac-hook/src/tip/trachook.py
Surely having a changeset hook for TracMercurial would be a good thing, but I prefer to base that on the new emerging interface for changeset change notification, as started in #7723.
That way the mercurial hook itself will be quite minimalistic, and the actions to be taken (closing tickets, etc.) would be done externally.