[Python-checkins] hooks: Allow more than one issue number in the hgroundup hook.
ezio.melotti
python-checkins at python.org
Sun Nov 13 17:36:28 CET 2011
http://hg.python.org/hooks/rev/ebdd1c1c365b
changeset: 78:ebdd1c1c365b
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Sun Nov 13 18:36:08 2011 +0200
summary:
Allow more than one issue number in the hgroundup hook.
files:
hgroundup.py | 34 +++++++++++++++++++---------------
1 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/hgroundup.py b/hgroundup.py
--- a/hgroundup.py
+++ b/hgroundup.py
@@ -1,7 +1,7 @@
"""Mercurial hook to update a Roundup issue.
-Update a Roundup issue via email for changesets where commit messages
-mention an issue anywhere in the commit message in the following way:
+Update Roundup issue(s) via email for changesets where commit messages
+mention one or more issues anywhere in the commit message in the following way:
#12345
issue12345
@@ -83,19 +83,23 @@
for rev in xrange(start, len(repo)):
ctx = repo[rev]
description = fromlocal(ctx.description().strip())
- match = ISSUE_PATTERN.search(description)
- ui.debug('match in commit msg: %s\n' % (match and match.groupdict() or 'no'))
- if not match:
- continue
- data = match.groupdict()
- comment = Template(COMMENT_TEMPLATE).substitute({
- 'author': fromlocal(person(ctx.user())),
- 'branch': ctx.branch(),
- 'changeset_id': str(ctx),
- 'changeset_url': posixpath.join(repourl, str(ctx)),
- 'commit_msg': description.splitlines()[0],
- })
- add_comment(issues, data, comment)
+ matches = ISSUE_PATTERN.finditer(description)
+ ids = set()
+ for match in matches:
+ data = match.groupdict()
+ ui.debug('match in commit msg: %s\n' % data)
+ # check for duplicated issue numbers in the same commit msg
+ if data['issue_id'] in ids:
+ continue
+ ids.add(data['issue_id'])
+ comment = Template(COMMENT_TEMPLATE).substitute({
+ 'author': fromlocal(person(ctx.user())),
+ 'branch': ctx.branch(),
+ 'changeset_id': str(ctx),
+ 'changeset_url': posixpath.join(repourl, str(ctx)),
+ 'commit_msg': description.splitlines()[0],
+ })
+ add_comment(issues, data, comment)
if issues:
try:
send_comments(mailrelay, fromaddr, toaddr, issues)
--
Repository URL: http://hg.python.org/hooks
More information about the Python-checkins
mailing list