test-bugzilla.t
109 lines
| 3.2 KiB
| text/troff
|
Tads3Lexer
/ tests / test-bugzilla.t
Yuya Nishihara
|
r28950 | mock bugzilla driver for testing template output: | ||
$ cat <<EOF > bzmock.py | ||||
> from __future__ import absolute_import | ||||
> from mercurial import extensions | ||||
Augie Fackler
|
r41379 | > from mercurial import pycompat | ||
Boris Feld
|
r33432 | > from mercurial import registrar | ||
Augie Fackler
|
r41379 | > from mercurial.utils import stringutil | ||
Yuya Nishihara
|
r28950 | > | ||
Boris Feld
|
r33432 | > configtable = {} | ||
> configitem = registrar.configitem(configtable) | ||||
> | ||||
Pulkit Goyal
|
r38081 | > configitem(b'bugzilla', b'mocklog', | ||
Boris Feld
|
r33432 | > default=None, | ||
> ) | ||||
Yuya Nishihara
|
r28950 | > def extsetup(ui): | ||
Pulkit Goyal
|
r38081 | > bugzilla = extensions.find(b'bugzilla') | ||
Yuya Nishihara
|
r28950 | > class bzmock(bugzilla.bzaccess): | ||
> def __init__(self, ui): | ||||
> super(bzmock, self).__init__(ui) | ||||
Pulkit Goyal
|
r38081 | > self._logfile = ui.config(b'bugzilla', b'mocklog') | ||
Yuya Nishihara
|
r28950 | > def updatebug(self, bugid, newstate, text, committer): | ||
Augie Fackler
|
r41379 | > with open(pycompat.fsdecode(self._logfile), 'ab') as f: | ||
> f.write(b'update bugid=%s, newstate=%s, committer=%s\n' | ||||
> % (stringutil.pprint(bugid), | ||||
> stringutil.pprint(newstate), | ||||
> stringutil.pprint(committer))) | ||||
> f.write(b'----\n' + text + b'\n----\n') | ||||
Yuya Nishihara
|
r28950 | > def notify(self, bugs, committer): | ||
Augie Fackler
|
r41379 | > with open(pycompat.fsdecode(self._logfile), 'ab') as f: | ||
> f.write(b'notify bugs=%s, committer=%s\n' | ||||
> % (stringutil.pprint(bugs), | ||||
> stringutil.pprint(committer))) | ||||
Pulkit Goyal
|
r38081 | > bugzilla.bugzilla._versions[b'mock'] = bzmock | ||
Yuya Nishihara
|
r28950 | > EOF | ||
set up mock repository: | ||||
$ hg init mockremote | ||||
$ cat <<EOF > mockremote/.hg/hgrc | ||||
> [extensions] | ||||
> bugzilla = | ||||
> bzmock = $TESTTMP/bzmock.py | ||||
> | ||||
> [bugzilla] | ||||
> version = mock | ||||
> mocklog = $TESTTMP/bzmock.log | ||||
> | ||||
> [hooks] | ||||
> incoming.bugzilla = python:hgext.bugzilla.hook | ||||
> | ||||
> [web] | ||||
> baseurl=http://example.org/hg | ||||
> | ||||
> %include $TESTTMP/bzstyle.hgrc | ||||
> EOF | ||||
$ hg clone -q mockremote mocklocal | ||||
push with default template: | ||||
$ echo '[bugzilla]' > bzstyle.hgrc | ||||
$ echo foo > mocklocal/foo | ||||
$ hg ci -R mocklocal -Aqm 'Fixes bug 123' | ||||
$ hg -R mocklocal push -q | ||||
$ cat bzmock.log && rm bzmock.log | ||||
update bugid=123, newstate={}, committer='test' | ||||
---- | ||||
Matt Harbison
|
r35394 | changeset 7875a8342c6f in repo $TESTTMP/mockremote refers to bug 123. | ||
Yuya Nishihara
|
r28950 | details: | ||
Fixes bug 123 | ||||
---- | ||||
notify bugs={123: {}}, committer='test' | ||||
push with style: | ||||
$ cat <<EOF > bzstyle.map | ||||
> changeset = "{node|short} refers to bug {bug}." | ||||
> EOF | ||||
$ echo "style = $TESTTMP/bzstyle.map" >> bzstyle.hgrc | ||||
$ echo foo >> mocklocal/foo | ||||
$ hg ci -R mocklocal -qm 'Fixes bug 456' | ||||
$ hg -R mocklocal push -q | ||||
$ cat bzmock.log && rm bzmock.log | ||||
update bugid=456, newstate={}, committer='test' | ||||
---- | ||||
2808b172464b refers to bug 456. | ||||
---- | ||||
notify bugs={456: {}}, committer='test' | ||||
push with template (overrides style): | ||||
$ cat <<EOF >> bzstyle.hgrc | ||||
> template = Changeset {node|short} in {root|basename}. | ||||
> {hgweb}/rev/{node|short}\n | ||||
> {desc} | ||||
> EOF | ||||
$ echo foo >> mocklocal/foo | ||||
$ hg ci -R mocklocal -qm 'Fixes bug 789' | ||||
$ hg -R mocklocal push -q | ||||
$ cat bzmock.log && rm bzmock.log | ||||
update bugid=789, newstate={}, committer='test' | ||||
---- | ||||
Changeset a770f3e409f2 in mockremote. | ||||
http://example.org/hg/rev/a770f3e409f2 | ||||
Fixes bug 789 | ||||
---- | ||||
notify bugs={789: {}}, committer='test' | ||||