--- a/plugin.py Wed Nov 21 18:13:37 2018 +0800
+++ b/plugin.py Wed Nov 21 18:20:21 2018 +0800
-fields = {'issue':'title',
-def fetch_item(nodeid, kind='issue', tracker='http://mercurial.selenic.com/bts'):
- """Use Roundup's CSV exports to fetch arbitrary item descriptions
- Default behavior is to return subject for a new issue:
- >>> fetch_item(1201569)
- '[issue1201569] allow running multiple instances of IDLE'
- Can also fetch message contents:
- >>> fetch_item(108, 'msg')
- 'Assigned to Guido for obvious reasons.'
- Multiline messages have spurious quotes, thanks to CSV format:
- >>> print fetch_item(81362, 'msg')
- File descriptions work too:
- >>> fetch_item(102, 'file')
- 'Example of message from frustrated user on c.l.py'
- Missing descriptions show as 'None':
- >>> fetch_item(12227, 'file')
- # This should be the smallest query able to fetch what we need
- query_tpl = [('@action', 'export_csv'), ('@filter', 'id'),
- ('id', nodeid), ('@columns', fields[kind])]
- item_url = '/%s?%s' % (kind, urllib.urlencode(query_tpl))
- content = urllib.urlopen(tracker + item_url).read().split('\r\n')
- if content[0] == 'title':
- # Got a single data row CSV, format and return it
- return '[issue%s] %s' % (nodeid, content[1].strip())
- elif content[0] == 'content':
- return content[1].strip()
- elif content[0] == 'description':
- return content[1].strip()
-def fetch(nodeid, debug=True):
- ''' Format input for fetch_item, add debug messages '''
- if nodeid.startswith('msg'):
- elif nodeid.startswith('file'):
- nodeid = nodeid.replace(kind, '')
- result = fetch_item(int(nodeid), kind)
- result = 'No item found for %s%s' % (kind, nodeid)
- logging.info('Fetched "%s: %s"' % (kind, result))
def revparse(irc, msg, args, state):
state.errorInvalid('revision', args[0],
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>)
- url gets the url of the bts, <issueno> summarizes that bug
- url = 'http://mercurial.selenic.com/bts'
- if title.startswith('[issue'):
- link = '/'.join([url, title[1:end]])
- title = ircutils.bold(title[:end+1]) + title[end+1:]
- title = title.replace('\n', ' ')
- bts = wrap(bts, ['text'])
def glossary(self, irc, msg, args, term):
"""usage: glossary <term>"""
raw, err = self.hg.run(['help', 'glossary'])