diff options
Diffstat (limited to 'tests/test-notify.t')
-rw-r--r-- | tests/test-notify.t | 217 |
1 files changed, 49 insertions, 168 deletions
diff --git a/tests/test-notify.t b/tests/test-notify.t index 543ceba..06554ce 100644 --- a/tests/test-notify.t +++ b/tests/test-notify.t @@ -17,125 +17,67 @@ > * = baz > EOF $ hg help notify - notify extension - hooks for sending email push notifications + notify extension - hooks for sending email notifications at commit/push time - This extension implements hooks to send email notifications when changesets - are sent from or received by the local repository. + Subscriptions can be managed through a hgrc file. Default mode is to print + messages to stdout, for testing and configuring. - First, enable the extension as explained in "hg help extensions", and register - the hook you want to run. "incoming" and "changegroup" hooks are run when - changesets are received, while "outgoing" hooks are for changesets sent to - another repository: + To use, configure the notify extension and enable it in hgrc like this: + + [extensions] + notify = [hooks] # one email for each incoming changeset incoming.notify = python:hgext.notify.hook - # one email for all incoming changesets + # batch emails when many changesets incoming at one time changegroup.notify = python:hgext.notify.hook - - # one email for all outgoing changesets + # batch emails when many changesets outgoing at one time (client side) outgoing.notify = python:hgext.notify.hook - This registers the hooks. To enable notification, subscribers must be assigned - to repositories. The "[usersubs]" section maps multiple repositories to a - given recipient. The "[reposubs]" section maps multiple recipients to a single - repository: + [notify] + # config items go here + + Required configuration items: + + config = /path/to/file # file containing subscriptions + + Optional configuration items: + + test = True # print messages to stdout for testing + strip = 3 # number of slashes to strip for url paths + domain = example.com # domain to use if committer missing domain + style = ... # style file to use when formatting email + template = ... # template to use when formatting email + incoming = ... # template to use when run as incoming hook + outgoing = ... # template to use when run as outgoing hook + changegroup = ... # template to use when run as changegroup hook + maxdiff = 300 # max lines of diffs to include (0=none, -1=all) + maxsubject = 67 # truncate subject line longer than this + diffstat = True # add a diffstat before the diff content + sources = serve # notify if source of incoming changes in this list + # (serve == ssh or http, push, pull, bundle) + merge = False # send notification for merges (default True) + [email] + from = user@host.com # email address to send as if none given + [web] + baseurl = http://hgserver/... # root of hg web site for browsing commits + + The notify config file has same format as a regular hgrc file. It has two + sections so you can express subscriptions in whatever way is handier for you. [usersubs] - # key is subscriber email, value is a comma-separated list of repo glob - # patterns + # key is subscriber email, value is ","-separated list of glob patterns user@host = pattern [reposubs] - # key is glob pattern, value is a comma-separated list of subscriber - # emails + # key is glob pattern, value is ","-separated list of subscriber emails pattern = user@host - Glob patterns are matched against absolute path to repository root. - - In order to place them under direct user management, "[usersubs]" and - "[reposubs]" sections may be placed in a separate "hgrc" file and incorporated - by reference: - - [notify] - config = /path/to/subscriptionsfile - - Notifications will not be sent until the "notify.test" value is set to - "False"; see below. - - Notifications content can be tweaked with the following configuration entries: - - notify.test - If "True", print messages to stdout instead of sending them. Default: True. - - notify.sources - Space-separated list of change sources. Notifications are activated only - when a changeset's source is in this list. Sources may be: - - "serve" changesets received via http or ssh - "pull" changesets received via "hg pull" - "unbundle" changesets received via "hg unbundle" - "push" changesets sent or received via "hg push" - "bundle" changesets sent via "hg unbundle" - - Default: serve. - - notify.strip - Number of leading slashes to strip from url paths. By default, notifications - reference repositories with their absolute path. "notify.strip" lets you - turn them into relative paths. For example, "notify.strip=3" will change - "/long/path/repository" into "repository". Default: 0. - - notify.domain - Default email domain for sender or recipients with no explicit domain. - - notify.style - Style file to use when formatting emails. + Glob patterns are matched against path to repository root. - notify.template - Template to use when formatting emails. - - notify.incoming - Template to use when run as an incoming hook, overriding "notify.template". - - notify.outgoing - Template to use when run as an outgoing hook, overriding "notify.template". - - notify.changegroup - Template to use when running as a changegroup hook, overriding - "notify.template". - - notify.maxdiff - Maximum number of diff lines to include in notification email. Set to 0 to - disable the diff, or -1 to include all of it. Default: 300. - - notify.maxsubject - Maximum number of characters in email's subject line. Default: 67. - - notify.diffstat - Set to True to include a diffstat before diff content. Default: True. - - notify.merge - If True, send notifications for merge changesets. Default: True. - - notify.mbox - If set, append mails to this mbox file instead of sending. Default: None. - - notify.fromauthor - If set, use the committer of the first changeset in a changegroup for the - "From" field of the notification mail. If not set, take the user from the - pushing repo. Default: False. - - If set, the following entries will also be used to customize the - notifications: - - email.from - Email "From" address to use if none can be found in the generated email - content. - - web.baseurl - Root repository URL to combine with repository paths when making references. - See also "notify.strip". + If you like, you can put notify config file in repository that users can push + changes to, they can manage their own subscriptions. no commands defined $ hg init a @@ -187,7 +129,7 @@ pull (minimal config) Message-Id: <*> (glob) To: baz, foo@bar - changeset 0647d048b600 in $TESTTMP/b (glob) + changeset 0647d048b600 in $TESTTMP/b details: $TESTTMP/b?cmd=changeset;node=0647d048b600 description: b @@ -214,6 +156,7 @@ fail for config file is missing $ hg --cwd b rollback repository tip rolled back to revision 0 (undo pull) + working directory now based on revision 0 $ hg --cwd b pull ../a 2>&1 | grep 'error.*\.notify\.conf' > /dev/null && echo pull failed pull failed $ touch ".notify.conf" @@ -222,6 +165,7 @@ pull $ hg --cwd b rollback repository tip rolled back to revision 0 (undo pull) + working directory now based on revision 0 $ hg --traceback --cwd b pull ../a | \ > python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' pulling from ../a @@ -266,6 +210,7 @@ pull $ hg --cwd b rollback repository tip rolled back to revision 0 (undo pull) + working directory now based on revision 0 $ hg --traceback --cwd b pull ../a | \ > python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' pulling from ../a @@ -364,7 +309,7 @@ test merge description: merge (run 'hg update' to get a working copy) -non-ascii content and truncation of multi-byte subject +truncate multi-byte subject $ cat <<EOF >> $HGRCPATH > [notify] @@ -409,67 +354,3 @@ non-ascii content and truncation of multi-byte subject a +a (run 'hg update' to get a working copy) - -long lines - - $ cat <<EOF >> $HGRCPATH - > [notify] - > maxsubject = 67 - > test = False - > mbox = mbox - > EOF - $ python -c 'file("a/a", "ab").write("no" * 500 + "\n")' - $ hg --cwd a commit -A -m "long line" - $ hg --traceback --cwd b pull ../a - pulling from ../a - searching for changes - adding changesets - adding manifests - adding file changes - added 1 changesets with 1 changes to 1 files - notify: sending 2 subscribers 1 changes - (run 'hg update' to get a working copy) - $ python -c 'import sys,re; print re.sub("\n\t", " ", file("b/mbox").read()),' - From test@test.com ... ... .. ..:..:.. .... (re) - Content-Type: text/plain; charset="us-ascii" - MIME-Version: 1.0 - Content-Transfer-Encoding: quoted-printable - X-Test: foo - Date: * (glob) - Subject: long line - From: test@test.com - X-Hg-Notification: changeset e0be44cf638b - Message-Id: <hg.e0be44cf638b.*.*@*> (glob) - To: baz@test.com, foo@bar - - changeset e0be44cf638b in b - description: long line - diffstat: - - a | 1 + - 1 files changed, 1 insertions(+), 0 deletions(-) - - diffs (8 lines): - - diff -r 7ea05ad269dc -r e0be44cf638b a - --- a/a Thu Jan 01 00:00:00 1970 +0000 - +++ b/a Thu Jan 01 00:00:00 1970 +0000 - @@ -1,3 +1,4 @@ - a - a - a - +nonononononononononononononononononononononononononononononononononononono= - nononononononononononononononononononononononononononononononononononononon= - ononononononononononononononononononononononononononononononononononononono= - nononononononononononononononononononononononononononononononononononononon= - ononononononononononononononononononononononononononononononononononononono= - nononononononononononononononononononononononononononononononononononononon= - ononononononononononononononononononononononononononononononononononononono= - nononononononononononononononononononononononononononononononononononononon= - ononononononononononononononononononononononononononononononononononononono= - nononononononononononononononononononononononononononononononononononononon= - ononononononononononononononononononononononononononononononononononononono= - nononononononononononononononononononononononononononononononononononononon= - ononononononononononononononononononononononononononononononononononononono= - nonononononononononononono - |