Download:
child 4:cf0cac509fcf
parent 2:39f0d8a77f61
3:096e1a63071c
Brendan Cully <brendan@cs.ubc.ca>, Sat, 30 May 2009 21:32:17 -0700
Improve help parser

1 файлов изменено, 18 вставок(+), 11 удалений(-) [+]
plugin.py file | annotate | diff | comparison | revisions
--- a/plugin.py Sat May 30 21:03:37 2009 -0700
+++ b/plugin.py Sat May 30 21:32:17 2009 -0700
@@ -52,29 +52,36 @@
super(Mercurial, self).__init__(irc)
self.path = self.registryValue('path')
- def hg(self, irc, msg, args, cmd):
+ def hghelp(self, irc, msg, args, cmd):
"""runs hg help with the given args"""
def fmt(text):
lines = text.splitlines()
out = []
for line in lines:
line = line.strip()
- if line.startswith('aliases:') or line.startswith('options'):
+ if not line or line.startswith('aliases:'):
+ continue
+ if line.startswith('options') or line.startswith('enabled extensions:'):
break
- if line:
- out.append(line)
- if len(out) > 1:
- out.insert(2, '--')
- out = out[1:]
+ out.append(line)
+ if out and ' extension - ' in out[0]:
+ out[0] = ircutils.bold(out[0])
+ elif len(out) > 1:
+ out[1] = ircutils.bold(out[1])
+ out = out[:10]
+
+ if out and out[0].startswith('Mercurial Distributed SCM'):
+ out = ['"%s": unknown command' % cmd]
return out
fd = os.popen('%s help %s' % (self.path, cmd))
out = fd.read()
fd.close()
- irc.replies(fmt(out), joiner=' '.join)
- hg = wrap(hg, ['text'])
+ irc.replies(fmt(out))
- def hglog(self, irc, msg, args, rev):
+ hghelp = wrap(hghelp, ['text'])
+
+ def crew(self, irc, msg, args, rev):
"gets the changelog message for the given revision"
# make configurable
@@ -100,7 +107,7 @@
lines = ['%s %s %s: %s' % (rev, user, date, files)] + lines
irc.replies(lines)
- hglog = wrap(hglog, ['revision'])
+ crew = wrap(crew, ['revision'])
Class = Mercurial