Mercurial > hg-stable
changeset 28951:1bba1b43525a
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.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 04 Apr 2016 22:50:50 +0900 |
parents | 9e1c9f016b72 |
children | f59e24002678 |
files | hgext/notify.py tests/test-notify.t |
diffstat | 2 files changed, 76 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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,
--- 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: <hg.3548c9e294b6.*.*@*> (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 <<EOF > notifystyle.map + > changeset = "Subject: {desc|firstline|strip} + > From: {author} + > {""} + > changeset {node|short}" + > EOF + $ cat <<EOF >> $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: <hg.e917dbd961d3.*.*@*> (glob) + To: baz@test.com, foo@bar + + changeset e917dbd961d3 + +with template (overrides style): + + $ cat <<EOF >> $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: <hg.a09743fd3edd.*.*@*> (glob) + To: baz@test.com, foo@bar + + with template