Download:
child 28:5ec22aeef122
parent 26:ba80cf1291a8
27:41767a02e8da draft
Anton Shestakov <av6@dwimlabs.net>, Wed, 21 Nov 2018 20:42:40 +0800
plugin: move repo paths to config, finally add tests for changelog command

3 файлов изменено, 22 вставок(+), 4 удалений(-) [+]
config.py file | annotate | diff | comparison | revisions
plugin.py file | annotate | diff | comparison | revisions
test.py file | annotate | diff | comparison | revisions
--- a/config.py Wed Nov 21 20:41:07 2018 +0800
+++ b/config.py Wed Nov 21 20:42:40 2018 +0800
@@ -47,3 +47,14 @@
conf.registerGlobalValue(Mercurial, 'path',
registry.String('hg',
"""Path to the mercurial binary"""))
+
+conf.registerGroup(Mercurial, 'repos')
+conf.registerGlobalValue(Mercurial.repos, 'hg',
+ registry.String('/home/hg/repos/hg',
+ """Path to the main hg repo."""))
+conf.registerGlobalValue(Mercurial.repos, 'hg-committed',
+ registry.String('/home/hg/repos/hg-committed',
+ """Path to the hg-committed repo."""))
+conf.registerGlobalValue(Mercurial.repos, 'hg-all',
+ registry.String('/home/hg/repos/hg-all',
+ """Path to the hg-all repo."""))
--- a/plugin.py Wed Nov 21 20:41:07 2018 +0800
+++ b/plugin.py Wed Nov 21 20:42:40 2018 +0800
@@ -115,16 +115,17 @@
url = "%s/rev/%s" % (baseurl.strip("\n/"), rev)
irc.replies(lines[:2] + [url])
- def _changelogcmd(repo):
+ def _changelogcmd(key):
def cmd(self, irc, msg, args, rev):
"""<revision>
Returns the changelog message and the URL for the given revision."""
- self._changelog(irc, repo, rev)
+ self._changelog(irc, self.registryValue(key), rev)
return wrap(cmd, ['revision'])
- main = _changelogcmd('/home/hg/repos/hg')
- crew = _changelogcmd('/home/brendan/hg/mirror/mercurial/crew')
+ main = _changelogcmd('repos.hg')
+ hgcommitted = _changelogcmd('repos.hg-committed')
+ hgall = _changelogcmd('repos.hg-all')
def glossary(self, irc, msg, args, term):
"""<term>
--- a/test.py Wed Nov 21 20:41:07 2018 +0800
+++ b/test.py Wed Nov 21 20:42:40 2018 +0800
@@ -32,6 +32,7 @@
class MercurialTestCase(PluginTestCase):
plugins = ('Mercurial',)
+ config = {'supybot.plugins.Mercurial.repos.hg': '.'}
def testHghelp(self):
self.assertRegexp('hghelp verify', '.*verify the integrity.*')
@@ -44,4 +45,9 @@
self.assertResponse('glossary foo', 'no match found')
self.assertHelp('glossary')
+ def testChangelog(self):
+ self.assertRegexp('main 0', 'Mercurial plugin 0\.1')
+ self.assertNotError('main null')
+ self.assertHelp('main')
+
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: