##// END OF EJS Templates
bugzilla: do not load style file if template is specified (BC)...
Yuya Nishihara -
r28950:9e1c9f01 default
parent child Browse files
Show More
@@ -0,0 +1,97 b''
1 mock bugzilla driver for testing template output:
2
3 $ cat <<EOF > bzmock.py
4 > from __future__ import absolute_import
5 > from mercurial import extensions
6 >
7 > def extsetup(ui):
8 > bugzilla = extensions.find('bugzilla')
9 > class bzmock(bugzilla.bzaccess):
10 > def __init__(self, ui):
11 > super(bzmock, self).__init__(ui)
12 > self._logfile = ui.config('bugzilla', 'mocklog')
13 > def updatebug(self, bugid, newstate, text, committer):
14 > with open(self._logfile, 'a') as f:
15 > f.write('update bugid=%r, newstate=%r, committer=%r\n'
16 > % (bugid, newstate, committer))
17 > f.write('----\n' + text + '\n----\n')
18 > def notify(self, bugs, committer):
19 > with open(self._logfile, 'a') as f:
20 > f.write('notify bugs=%r, committer=%r\n'
21 > % (bugs, committer))
22 > bugzilla.bugzilla._versions['mock'] = bzmock
23 > EOF
24
25 set up mock repository:
26
27 $ hg init mockremote
28 $ cat <<EOF > mockremote/.hg/hgrc
29 > [extensions]
30 > bugzilla =
31 > bzmock = $TESTTMP/bzmock.py
32 >
33 > [bugzilla]
34 > version = mock
35 > mocklog = $TESTTMP/bzmock.log
36 >
37 > [hooks]
38 > incoming.bugzilla = python:hgext.bugzilla.hook
39 >
40 > [web]
41 > baseurl=http://example.org/hg
42 >
43 > %include $TESTTMP/bzstyle.hgrc
44 > EOF
45
46 $ hg clone -q mockremote mocklocal
47
48 push with default template:
49
50 $ echo '[bugzilla]' > bzstyle.hgrc
51 $ echo foo > mocklocal/foo
52 $ hg ci -R mocklocal -Aqm 'Fixes bug 123'
53 $ hg -R mocklocal push -q
54 $ cat bzmock.log && rm bzmock.log
55 update bugid=123, newstate={}, committer='test'
56 ----
57 changeset 7875a8342c6f in repo $TESTTMP/mockremote refers to bug 123.
58 details:
59 Fixes bug 123
60 ----
61 notify bugs={123: {}}, committer='test'
62
63 push with style:
64
65 $ cat <<EOF > bzstyle.map
66 > changeset = "{node|short} refers to bug {bug}."
67 > EOF
68 $ echo "style = $TESTTMP/bzstyle.map" >> bzstyle.hgrc
69 $ echo foo >> mocklocal/foo
70 $ hg ci -R mocklocal -qm 'Fixes bug 456'
71 $ hg -R mocklocal push -q
72 $ cat bzmock.log && rm bzmock.log
73 update bugid=456, newstate={}, committer='test'
74 ----
75 2808b172464b refers to bug 456.
76 ----
77 notify bugs={456: {}}, committer='test'
78
79 push with template (overrides style):
80
81 $ cat <<EOF >> bzstyle.hgrc
82 > template = Changeset {node|short} in {root|basename}.
83 > {hgweb}/rev/{node|short}\n
84 > {desc}
85 > EOF
86 $ echo foo >> mocklocal/foo
87 $ hg ci -R mocklocal -qm 'Fixes bug 789'
88 $ hg -R mocklocal push -q
89 $ cat bzmock.log && rm bzmock.log
90 update bugid=789, newstate={}, committer='test'
91 ----
92 Changeset a770f3e409f2 in mockremote.
93 http://example.org/hg/rev/a770f3e409f2
94
95 Fixes bug 789
96 ----
97 notify bugs={789: {}}, committer='test'
@@ -886,8 +886,10 b' class bugzilla(object):'
886 count -= 1
886 count -= 1
887 return root
887 return root
888
888
889 mapfile = self.ui.config('bugzilla', 'style')
889 mapfile = None
890 tmpl = self.ui.config('bugzilla', 'template')
890 tmpl = self.ui.config('bugzilla', 'template')
891 if not tmpl:
892 mapfile = self.ui.config('bugzilla', 'style')
891 if not mapfile and not tmpl:
893 if not mapfile and not tmpl:
892 tmpl = _('changeset {node|short} in repo {root} refers '
894 tmpl = _('changeset {node|short} in repo {root} refers '
893 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
895 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
General Comments 0
You need to be logged in to leave comments. Login now