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