--- a/plugin.py Tue Sep 14 12:27:53 2010 -0500
+++ b/plugin.py Wed Oct 19 17:10:10 2011 -0500
state.args.append(args.pop(0))
addConverter('revision', revparse)
+ def __init__(self, path):
+ fd = os.popen('%s %s' % (self.path, args))
class Mercurial(callbacks.Plugin):
"""Add the help for "@plugin help Mercurial" here
This should describe *how* to use this plugin."""
super(Mercurial, self).__init__(irc)
self.path = self.registryValue('path')
+ self.hg = Hg(self.path)
def hghelp(self, irc, msg, args, cmd):
"""runs hg help with the given args"""
out = ['"%s": unknown command' % cmd]
- fd = os.popen('%s help %s' % (self.path, cmd))
+ out = self.hg.run('help ' + cmd)
hghelp = wrap(hghelp, ['text'])
def changeLog(self, repo, rev):
tmpl = '{rev}:{node|short}\n{date|age}\n{author|person}\n{files}\n{desc}'
- cmd = "%s -R %s log -v --limit 1 --template '%s' -r %s" \
- % (self.path, repo, tmpl, rev)
+ cmd = "-R %s log -v --limit 1 --template '%s' -r %s" \
return ['No result found.']
bts = wrap(bts, ['text'])
+ def glossary(self, irc, msg, args, term):
+ """usage: glossary <term>"""
+ raw = self.hg.run('help glossary').splitlines()
+ if not found and line.lower().startswith(' ' + term.lower()):
+ elif found and not (line.startswith(' ') or not line):
+ if found and not done and line:
+ answer = ['', 'no match found']
+ irc.reply(' '.join(answer[1:]))
+ glossary = wrap(glossary, ['text'])
--- a/test.py Tue Sep 14 12:27:53 2010 -0500
+++ b/test.py Wed Oct 19 17:10:10 2011 -0500
class MercurialTestCase(PluginTestCase):
+ ChannelPluginTestCase.setUp(self)
- self.assertNotError('hghelp')
+ self.assertNotError('hghelp foo')
+ def testGlossary(self):
+ self.assertNotError('glossary foo')
+ m = self.getMsg('glossary foo')
+ self.assertError('glossary foo')
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: