Download:
child 23:78c3d66226a4
parent 21:36132d921a97
22:469ce066f4a4 draft
Anton Shestakov <av6@dwimlabs.net>, Wed, 21 Nov 2018 18:13:37 +0800
plugin: generate changelog-using commands easier Also, "using capital letters is a good way of assuring that you don’t accidentally expose helper functions to users as commands". Oh yes, and so self-explanatory too!

1 файлов изменено, 8 вставок(+), 9 удалений(-) [+]
plugin.py file | annotate | diff | comparison | revisions
--- a/plugin.py Wed Nov 21 18:08:57 2018 +0800
+++ b/plugin.py Wed Nov 21 18:13:37 2018 +0800
@@ -154,7 +154,7 @@
hghelp = wrap(hghelp, ['text'])
- def changelog(self, irc, repo, rev):
+ def _changelog(self, irc, repo, rev):
tmpl = '{rev}:{node|short}\n{date|age}\n{author|person}\n{files}\n{desc}'
out, err = self.hg.run([
'-R', repo, 'log', '-r', rev, '-l', '1', '--template', tmpl, '-v'
@@ -177,15 +177,14 @@
url = "%s/rev/%s" % (baseurl.strip("\n/"), rev)
irc.replies(lines[:2] + [url])
- def crew(self, irc, msg, args, rev):
- "gets the changelog message for the given revision of the crew repository"
- self.changelog(irc, '/home/brendan/hg/mirror/mercurial/crew', rev)
- crew = wrap(crew, ['revision'])
+ def _changelogcmd(repo):
+ def cmd(self, irc, msg, args, rev):
+ """gets the changelog message for the given revision of the repository"""
+ self._changelog(irc, repo, rev)
+ return wrap(cmd, ['revision'])
- def main(self, irc, msg, args, rev):
- "gets the changelog message for the given revision of the crew repository"
- self.changelog(irc, '/home/hg/repos/hg', rev)
- main = wrap(main, ['revision'])
+ main = _changelogcmd('/home/hg/repos/hg')
+ crew = _changelogcmd('/home/brendan/hg/mirror/mercurial/crew')
def bts(self, irc, msg, args, issue):
"""usage: bts (url|<issueno>)