# HG changeset patch # User Yuya Nishihara # Date 1459777850 -32400 # Node ID 1bba1b43525ae9476456ae0401b95ac2dfc6c624 # Parent 9e1c9f016b720f3ed605b3206f3c8cc3d9d23b75 notify: do not load style file if template is specified (BC) This patch makes sure that either "tmpl" or "mapfile" is exclusively set, which is the same behavior as common log-like templates and formatter outputs. See the previous patch for why. diff -r 9e1c9f016b72 -r 1bba1b43525a hgext/notify.py --- a/hgext/notify.py Mon Apr 04 22:48:34 2016 +0900 +++ b/hgext/notify.py Mon Apr 04 22:50:50 2016 +0900 @@ -196,9 +196,11 @@ self.subs = self.subscribers() self.merge = self.ui.configbool('notify', 'merge', True) - mapfile = self.ui.config('notify', 'style') + mapfile = None template = (self.ui.config('notify', hooktype) or self.ui.config('notify', 'template')) + if not template: + mapfile = self.ui.config('notify', 'style') if not mapfile and not template: template = deftemplates.get(hooktype) or single_template self.t = cmdutil.changeset_templater(self.ui, self.repo, False, None, diff -r 9e1c9f016b72 -r 1bba1b43525a tests/test-notify.t --- a/tests/test-notify.t Mon Apr 04 22:48:34 2016 +0900 +++ b/tests/test-notify.t Mon Apr 04 22:50:50 2016 +0900 @@ -553,3 +553,76 @@ description: test (run 'hg heads' to see heads) +default template: + + $ grep -v '^template =' $HGRCPATH > "$HGRCPATH.new" + $ mv "$HGRCPATH.new" $HGRCPATH + $ echo a >> a/a + $ hg --cwd a commit -m 'default template' + $ hg --cwd b pull ../a -q | \ + > $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' + Content-Type: text/plain; charset="us-ascii" + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + Date: * (glob) + Subject: changeset in b: default template + From: test@test.com + X-Hg-Notification: changeset 3548c9e294b6 + Message-Id: (glob) + To: baz@test.com, foo@bar + + changeset 3548c9e294b6 in $TESTTMP/b + details: http://test/b?cmd=changeset;node=3548c9e294b6 + description: default template + +with style: + + $ cat < notifystyle.map + > changeset = "Subject: {desc|firstline|strip} + > From: {author} + > {""} + > changeset {node|short}" + > EOF + $ cat <> $HGRCPATH + > [notify] + > style = $TESTTMP/notifystyle.map + > EOF + $ echo a >> a/a + $ hg --cwd a commit -m 'with style' + $ hg --cwd b pull ../a -q | \ + > $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' + Content-Type: text/plain; charset="us-ascii" + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + Date: * (glob) + Subject: with style + From: test@test.com + X-Hg-Notification: changeset e917dbd961d3 + Message-Id: (glob) + To: baz@test.com, foo@bar + + changeset e917dbd961d3 + +with template (overrides style): + + $ cat <> $HGRCPATH + > template = Subject: {node|short}: {desc|firstline|strip} + > From: {author} + > {""} + > {desc} + > EOF + $ echo a >> a/a + $ hg --cwd a commit -m 'with template' + $ hg --cwd b pull ../a -q | \ + > $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' + Content-Type: text/plain; charset="us-ascii" + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + Date: * (glob) + Subject: a09743fd3edd: with template + From: test@test.com + X-Hg-Notification: changeset a09743fd3edd + Message-Id: (glob) + To: baz@test.com, foo@bar + + with template