# HG changeset patch # User David Champion # Date 2009-09-23 07:31:09 # Node ID f8048c3340661b20a916b52b5b3cbe75ec521852 # Parent f7d85980261c7056377159c6269319b1b853b79a notify: permit suppression of merge changeset notification In some environments merges occur regularly but with no conflicts, and committers find merge notifications more of a bother than a help. By setting merge=False in [notify], merge notifications are suppressed. This works both for incoming and for changegroup hooks. diff --git a/hgext/notify.py b/hgext/notify.py --- a/hgext/notify.py +++ b/hgext/notify.py @@ -43,6 +43,7 @@ Optional configuration items:: 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] @@ -111,6 +112,7 @@ class notifier(object): self.test = self.ui.configbool('notify', 'test', True) self.charsets = mail._charsets(self.ui) self.subs = self.subscribers() + self.merge = self.ui.configbool('notify', 'merge', True) mapfile = self.ui.config('notify', 'style') template = (self.ui.config('notify', hooktype) or @@ -166,10 +168,13 @@ class notifier(object): return self.ui.config('web', 'baseurl') + (path or self.root) def node(self, ctx, **props): - '''format one changeset.''' + '''format one changeset, unless it is a suppressed merge.''' + if not self.merge and len(ctx.parents()) > 1: + return False self.t.show(ctx, changes=ctx.changeset(), baseurl=self.ui.config('web', 'baseurl'), root=self.repo.root, webroot=self.root, **props) + return True def skipsource(self, source): '''true if incoming changes from this source should be skipped.''' @@ -283,16 +288,29 @@ def hook(ui, repo, hooktype, node=None, return ui.pushbuffer() + data = '' + count = 0 if hooktype == 'changegroup': start, end = ctx.rev(), len(repo) - count = end - start for rev in xrange(start, end): - n.node(repo[rev]) - n.diff(ctx, repo['tip']) + if n.node(repo[rev]): + count += 1 + else: + data += ui.popbuffer() + ui.note(_('notify: suppressing notification for merge %d:%s\n') % + (rev, repo[rev].hex()[:12])) + ui.pushbuffer() + if count: + n.diff(ctx, repo['tip']) else: - count = 1 - n.node(ctx) + if not n.node(ctx): + ui.popbuffer() + ui.note(_('notify: suppressing notification for merge %d:%s\n') % + (ctx.rev(), ctx.hex()[:12])) + return + count += 1 n.diff(ctx) - data = ui.popbuffer() - n.send(ctx, count, data) + data += ui.popbuffer() + if count: + n.send(ctx, count, data)