0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
### |
1
1:eeb22e49b1fb
Add revision lookup
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 0:5c1cbeda25de
line |
diff
|
# Copyright (c) 2007, 2009 Brendan Cully |
0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# All rights reserved. |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# Redistribution and use in source and binary forms, with or without |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# modification, are permitted provided that the following conditions are met: |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# * Redistributions of source code must retain the above copyright notice, |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# this list of conditions, and the following disclaimer. |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# * Redistributions in binary form must reproduce the above copyright notice, |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# this list of conditions, and the following disclaimer in the |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# documentation and/or other materials provided with the distribution. |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# * Neither the name of the author of this software nor the name of |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# contributors to this software may be used to endorse or promote products |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# derived from this software without specific prior written consent. |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
# POSSIBILITY OF SUCH DAMAGE. |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
|
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
### |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
|
18
18:674e48fa93db
plugin: use limnoria plugin template
Anton Shestakov <av6@dwimlabs.net>
previous changes: 12:7c18de2de921
line |
diff
|
from supybot import utils, plugins, ircutils, callbacks |
0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
from supybot.commands import * |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
|
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
import os |
30
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
import re |
20
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
import subprocess |
0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
|
2
2:39f0d8a77f61
Hook to validate revisions
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 1:eeb22e49b1fb
line |
diff
|
def revparse(irc, msg, args, state): |
2:39f0d8a77f61
Hook to validate revisions
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 1:eeb22e49b1fb
line |
diff
|
if ':' in args[0]: |
30
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
state.errorInvalid('revision', args[0], 'Contains ":".') |
2
2:39f0d8a77f61
Hook to validate revisions
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 1:eeb22e49b1fb
line |
diff
|
state.args.append(args.pop(0)) |
2:39f0d8a77f61
Hook to validate revisions
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 1:eeb22e49b1fb
line |
diff
|
addConverter('revision', revparse) |
2:39f0d8a77f61
Hook to validate revisions
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 1:eeb22e49b1fb
line |
diff
|
|
30
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
def phabrevparse(irc, msg, args, state): |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
if args[0].startswith('D'): |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
args[0] = args[0][1:] |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
callConverter('positiveInt', irc, msg, args, state) |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
addConverter('phabrev', phabrevparse) |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
|
9
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
class Hg(object): |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
def __init__(self, path): |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
self.path = path |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
|
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
def run(self, args): |
20
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
with open(os.devnull) as null: |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
p = subprocess.Popen([self.path] + args, stdout=subprocess.PIPE, |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
stderr=subprocess.PIPE, stdin=null, |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
env={'HGPLAIN': '1', 'HGENCODING': 'UTF-8'}) |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
out, err = p.communicate() |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
return (out.decode('utf-8'), err.decode('utf-8')) |
9
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
|
31
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
class Mercurial(callbacks.PluginRegexp): |
29
29:8f03cd5eaace
plugin: describe the plugin
Anton Shestakov <av6@dwimlabs.net>
previous changes: 27:41767a02e8da
line |
diff
|
"""Goodies for #mercurial.""" |
0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
threaded = True |
31
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
callBefore = ['URL', 'Web'] |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
regexps = ['snarfDifferential', 'snarfDifferentialURL'] |
0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
|
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
def __init__(self, irc): |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
super(Mercurial, self).__init__(irc) |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
self.path = self.registryValue('path') |
9
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
self.hg = Hg(self.path) |
0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
|
3
3:096e1a63071c
Improve help parser
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 2:39f0d8a77f61
line |
diff
|
def hghelp(self, irc, msg, args, cmd): |
24
24:751c2fca6ce6
plugin: more supybot-esque help for commands
Anton Shestakov <av6@dwimlabs.net>
previous changes: 23:78c3d66226a4
line |
diff
|
"""<topic> |
24:751c2fca6ce6
plugin: more supybot-esque help for commands
Anton Shestakov <av6@dwimlabs.net>
previous changes: 23:78c3d66226a4
line |
diff
|
|
24:751c2fca6ce6
plugin: more supybot-esque help for commands
Anton Shestakov <av6@dwimlabs.net>
previous changes: 23:78c3d66226a4
line |
diff
|
Runs hg help with the given args.""" |
0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
def fmt(text): |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
lines = text.splitlines() |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
out = [] |
6
6:3773fa2d0805
Trim help text to first descriptive line
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 5:0b8327ad3140
line |
diff
|
for line in lines[:3]: |
0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
line = line.strip() |
3
3:096e1a63071c
Improve help parser
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 2:39f0d8a77f61
line |
diff
|
if not line or line.startswith('aliases:'): |
3:096e1a63071c
Improve help parser
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 2:39f0d8a77f61
line |
diff
|
continue |
21
21:36132d921a97
plugin: use a 2-tuple as an argument to string.startswith()
Anton Shestakov <av6@dwimlabs.net>
previous changes: 20:b83b3319ff6b
line |
diff
|
if line.startswith(('options', 'enabled extensions:')): |
0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
break |
3
3:096e1a63071c
Improve help parser
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 2:39f0d8a77f61
line |
diff
|
out.append(line) |
3:096e1a63071c
Improve help parser
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 2:39f0d8a77f61
line |
diff
|
if out and ' extension - ' in out[0]: |
3:096e1a63071c
Improve help parser
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 2:39f0d8a77f61
line |
diff
|
out[0] = ircutils.bold(out[0]) |
3:096e1a63071c
Improve help parser
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 2:39f0d8a77f61
line |
diff
|
elif len(out) > 1: |
3:096e1a63071c
Improve help parser
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 2:39f0d8a77f61
line |
diff
|
out[1] = ircutils.bold(out[1]) |
3:096e1a63071c
Improve help parser
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 2:39f0d8a77f61
line |
diff
|
out = out[:10] |
0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
return out |
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
|
20
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
out, err = self.hg.run(['help', cmd]) |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
if err: |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
irc.reply(err.splitlines()[0]) |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
else: |
33
33:b0e492877263
plugin: use custom joiners for hghelp and changelog replies
Anton Shestakov <av6@dwimlabs.net>
previous changes: 32:6f02219bf75b
line |
diff
|
irc.replies(fmt(out), joiner=' ') |
0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
|
3
3:096e1a63071c
Improve help parser
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 2:39f0d8a77f61
line |
diff
|
hghelp = wrap(hghelp, ['text']) |
3:096e1a63071c
Improve help parser
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 2:39f0d8a77f61
line |
diff
|
|
22
22:469ce066f4a4
plugin: generate changelog-using commands easier
Anton Shestakov <av6@dwimlabs.net>
previous changes: 21:36132d921a97
line |
diff
|
def _changelog(self, irc, repo, rev): |
25
25:02687e613b7d
plugin: drop {files} from changelog template, they weren't used anyway
Anton Shestakov <av6@dwimlabs.net>
previous changes: 24:751c2fca6ce6
line |
diff
|
tmpl = '{rev}:{node|short}\n{date|age}\n{author|person}\n{desc}' |
20
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
out, err = self.hg.run([ |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
'-R', repo, 'log', '-r', rev, '-l', '1', '--template', tmpl, '-v' |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
]) |
1
1:eeb22e49b1fb
Add revision lookup
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 0:5c1cbeda25de
line |
diff
|
|
20
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
if err: |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
return irc.reply(err.splitlines()[0]) |
1
1:eeb22e49b1fb
Add revision lookup
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 0:5c1cbeda25de
line |
diff
|
if not out: |
20
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
return irc.reply('no changesets found') |
1
1:eeb22e49b1fb
Add revision lookup
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 0:5c1cbeda25de
line |
diff
|
|
26
26:ba80cf1291a8
plugin: strip individual lines in changelog, and not skip empty lines
Anton Shestakov <av6@dwimlabs.net>
previous changes: 25:02687e613b7d
line |
diff
|
lines = [line.strip() for line in out.splitlines()] |
25
25:02687e613b7d
plugin: drop {files} from changelog template, they weren't used anyway
Anton Shestakov <av6@dwimlabs.net>
previous changes: 24:751c2fca6ce6
line |
diff
|
node, date, user = lines[:3] |
25:02687e613b7d
plugin: drop {files} from changelog template, they weren't used anyway
Anton Shestakov <av6@dwimlabs.net>
previous changes: 24:751c2fca6ce6
line |
diff
|
lines = lines[3:] |
10
10:198302d7eeaf
add url to changelog results
Brendan Cully <brendan@kublai.com>
previous changes: 9:84423e165ad2
line |
diff
|
node = ircutils.bold(node) |
1
1:eeb22e49b1fb
Add revision lookup
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 0:5c1cbeda25de
line |
diff
|
user = ircutils.mircColor(user, fg='green') |
4
4:cf0cac509fcf
Allow multiple repositories
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 3:096e1a63071c
line |
diff
|
|
10
10:198302d7eeaf
add url to changelog results
Brendan Cully <brendan@kublai.com>
previous changes: 9:84423e165ad2
line |
diff
|
lines = ['%s %s %s' % (node, user, date)] + lines |
10:198302d7eeaf
add url to changelog results
Brendan Cully <brendan@kublai.com>
previous changes: 9:84423e165ad2
line |
diff
|
|
39
39:ddc609bd0303
plugin: use configurable base URL instead of paths.default in repo hgrc
Anton Shestakov <av6@dwimlabs.net>
previous changes: 38:ec32ce289f91
line |
diff
|
baseurl = self.registryValue('hgweburl').rstrip('/') |
39:ddc609bd0303
plugin: use configurable base URL instead of paths.default in repo hgrc
Anton Shestakov <av6@dwimlabs.net>
previous changes: 38:ec32ce289f91
line |
diff
|
reponame = os.path.basename(os.path.normpath(repo)) |
39:ddc609bd0303
plugin: use configurable base URL instead of paths.default in repo hgrc
Anton Shestakov <av6@dwimlabs.net>
previous changes: 38:ec32ce289f91
line |
diff
|
url = '{}/{}/rev/{}'.format(baseurl, reponame, rev) |
33
33:b0e492877263
plugin: use custom joiners for hghelp and changelog replies
Anton Shestakov <av6@dwimlabs.net>
previous changes: 32:6f02219bf75b
line |
diff
|
irc.replies(lines[:2] + [url], joiner=' - ') |
4
4:cf0cac509fcf
Allow multiple repositories
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 3:096e1a63071c
line |
diff
|
|
27
27:41767a02e8da
plugin: move repo paths to config, finally add tests for changelog command
Anton Shestakov <av6@dwimlabs.net>
previous changes: 26:ba80cf1291a8
line |
diff
|
def _changelogcmd(key): |
22
22:469ce066f4a4
plugin: generate changelog-using commands easier
Anton Shestakov <av6@dwimlabs.net>
previous changes: 21:36132d921a97
line |
diff
|
def cmd(self, irc, msg, args, rev): |
24
24:751c2fca6ce6
plugin: more supybot-esque help for commands
Anton Shestakov <av6@dwimlabs.net>
previous changes: 23:78c3d66226a4
line |
diff
|
"""<revision> |
24:751c2fca6ce6
plugin: more supybot-esque help for commands
Anton Shestakov <av6@dwimlabs.net>
previous changes: 23:78c3d66226a4
line |
diff
|
|
24:751c2fca6ce6
plugin: more supybot-esque help for commands
Anton Shestakov <av6@dwimlabs.net>
previous changes: 23:78c3d66226a4
line |
diff
|
Returns the changelog message and the URL for the given revision.""" |
27
27:41767a02e8da
plugin: move repo paths to config, finally add tests for changelog command
Anton Shestakov <av6@dwimlabs.net>
previous changes: 26:ba80cf1291a8
line |
diff
|
self._changelog(irc, self.registryValue(key), rev) |
22
22:469ce066f4a4
plugin: generate changelog-using commands easier
Anton Shestakov <av6@dwimlabs.net>
previous changes: 21:36132d921a97
line |
diff
|
return wrap(cmd, ['revision']) |
1
1:eeb22e49b1fb
Add revision lookup
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 0:5c1cbeda25de
line |
diff
|
|
27
27:41767a02e8da
plugin: move repo paths to config, finally add tests for changelog command
Anton Shestakov <av6@dwimlabs.net>
previous changes: 26:ba80cf1291a8
line |
diff
|
main = _changelogcmd('repos.hg') |
27:41767a02e8da
plugin: move repo paths to config, finally add tests for changelog command
Anton Shestakov <av6@dwimlabs.net>
previous changes: 26:ba80cf1291a8
line |
diff
|
hgcommitted = _changelogcmd('repos.hg-committed') |
27:41767a02e8da
plugin: move repo paths to config, finally add tests for changelog command
Anton Shestakov <av6@dwimlabs.net>
previous changes: 26:ba80cf1291a8
line |
diff
|
hgall = _changelogcmd('repos.hg-all') |
32
32:6f02219bf75b
plugin: add more repos
Anton Shestakov <av6@dwimlabs.net>
previous changes: 31:c3c5a64068a5
line |
diff
|
hgwebsite = _changelogcmd('repos.hg-website') |
32:6f02219bf75b
plugin: add more repos
Anton Shestakov <av6@dwimlabs.net>
previous changes: 31:c3c5a64068a5
line |
diff
|
evolve = _changelogcmd('repos.evolve') |
1
1:eeb22e49b1fb
Add revision lookup
Brendan Cully <brendan@cs.ubc.ca>
previous changes: 0:5c1cbeda25de
line |
diff
|
|
9
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
def glossary(self, irc, msg, args, term): |
24
24:751c2fca6ce6
plugin: more supybot-esque help for commands
Anton Shestakov <av6@dwimlabs.net>
previous changes: 23:78c3d66226a4
line |
diff
|
"""<term> |
24:751c2fca6ce6
plugin: more supybot-esque help for commands
Anton Shestakov <av6@dwimlabs.net>
previous changes: 23:78c3d66226a4
line |
diff
|
|
24:751c2fca6ce6
plugin: more supybot-esque help for commands
Anton Shestakov <av6@dwimlabs.net>
previous changes: 23:78c3d66226a4
line |
diff
|
Returns glossary definition (from hg help glossary) for the term.""" |
20
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
raw, err = self.hg.run(['help', 'glossary']) |
9
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
found = False |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
done = False |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
answer = [] |
20
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
for line in raw.splitlines(): |
9
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
if not found and line.lower().startswith(' ' + term.lower()): |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
found = True |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
elif found and not (line.startswith(' ') or not line): |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
done = True |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
|
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
line = line.strip() |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
if found and not done and line: |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
answer.append(line) |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
|
20
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
if answer: |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
irc.replies(answer[1:], joiner=' ') |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
else: |
20:b83b3319ff6b
plugin: use subprocess.Popen instead of os.popen, handle stderr
Anton Shestakov <av6@dwimlabs.net>
previous changes: 19:cee789a8154e
line |
diff
|
irc.reply('no match found') |
9
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
glossary = wrap(glossary, ['text']) |
9:84423e165ad2
Add glossary command
Brendan Cully <brendan@kublai.com>
previous changes: 8:28e93659ea08
line |
diff
|
|
34
34:0497bddba297
plugin: make differential snarfing actually work
Anton Shestakov <av6@dwimlabs.net>
previous changes: 33:b0e492877263
line |
diff
|
def _differential(self, irc, phabrev, gotURL=False): |
30
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
baseurl = self.registryValue('phaburl') |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
url = '{}/D{}'.format(baseurl.rstrip('/'), phabrev) |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
page = utils.web.getUrl(url).decode('utf-8') |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
|
37
37:b4e3fa814a17
plugin: fallback values for phab status and desc don't need to be so verbose
Anton Shestakov <av6@dwimlabs.net>
previous changes: 35:ec831f0ca300
line |
diff
|
status = '?' |
37:b4e3fa814a17
plugin: fallback values for phab status and desc don't need to be so verbose
Anton Shestakov <av6@dwimlabs.net>
previous changes: 35:ec831f0ca300
line |
diff
|
desc = '?' |
30
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
match = re.search(r'<div class="phui-header-subheader">.*?</span>(?P<status>[^<]+?)</span>', page) |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
if match: |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
status = utils.web.htmlToText(match.group('status')) |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
match = re.search(r'<span class="phui-header-header">.*?</span>(?P<desc>[^<]+?)</span>', page) |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
if match: |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
desc = utils.web.htmlToText(match.group('desc')) |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
|
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
if gotURL: |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
url = 'D{}'.format(phabrev) |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
|
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
item = 'Revision {} {}, {}'.format(url, status, desc) |
38
38:ec32ce289f91
plugin: highlight differential replies in color, similar to bz
Anton Shestakov <av6@dwimlabs.net>
previous changes: 37:b4e3fa814a17
line |
diff
|
irc.reply(ircutils.mircColor(item, fg='blue')) |
34
34:0497bddba297
plugin: make differential snarfing actually work
Anton Shestakov <av6@dwimlabs.net>
previous changes: 33:b0e492877263
line |
diff
|
|
34:0497bddba297
plugin: make differential snarfing actually work
Anton Shestakov <av6@dwimlabs.net>
previous changes: 33:b0e492877263
line |
diff
|
def differential(self, irc, msg, args, phabrev): |
34:0497bddba297
plugin: make differential snarfing actually work
Anton Shestakov <av6@dwimlabs.net>
previous changes: 33:b0e492877263
line |
diff
|
"""<revision id> |
34:0497bddba297
plugin: make differential snarfing actually work
Anton Shestakov <av6@dwimlabs.net>
previous changes: 33:b0e492877263
line |
diff
|
|
34:0497bddba297
plugin: make differential snarfing actually work
Anton Shestakov <av6@dwimlabs.net>
previous changes: 33:b0e492877263
line |
diff
|
Returns URL, description and status of revisions on differential.""" |
34:0497bddba297
plugin: make differential snarfing actually work
Anton Shestakov <av6@dwimlabs.net>
previous changes: 33:b0e492877263
line |
diff
|
self._differential(irc, phabrev) |
30
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
differential = wrap(differential, ['phabrev']) |
30:8db5c52046c7
plugin: add a basic differential parser
Anton Shestakov <av6@dwimlabs.net>
previous changes: 29:8f03cd5eaace
line |
diff
|
|
31
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
def snarfDifferential(self, irc, msg, match): |
35
35:ec831f0ca300
plugin: only catch ".*/D1234" patterns in URL snarfer
Anton Shestakov <av6@dwimlabs.net>
previous changes: 34:0497bddba297
line |
diff
|
r'(^|[^/])\bD(?P<phabrev>\d+)\b' |
31
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
channel = msg.args[0] |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
if not irc.isChannel(channel): |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
return |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
|
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
phabrev = match.group('phabrev') |
34
34:0497bddba297
plugin: make differential snarfing actually work
Anton Shestakov <av6@dwimlabs.net>
previous changes: 33:b0e492877263
line |
diff
|
self._differential(irc, phabrev) |
31
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
|
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
@urlSnarfer |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
def snarfDifferentialURL(self, irc, msg, match): |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
r'\b(?P<url>https?://\S+/)D(?P<phabrev>\d+)\b' |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
channel = msg.args[0] |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
if not irc.isChannel(channel): |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
return |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
|
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
url = match.group('url') |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
if url.rstrip('/') != self.registryValue('phaburl').rstrip('/'): |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
return |
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
|
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
phabrev = match.group('phabrev') |
34
34:0497bddba297
plugin: make differential snarfing actually work
Anton Shestakov <av6@dwimlabs.net>
previous changes: 33:b0e492877263
line |
diff
|
self._differential(irc, phabrev, gotURL=True) |
31
31:c3c5a64068a5
plugin: snarf differential revisions and URLs
Anton Shestakov <av6@dwimlabs.net>
previous changes: 30:8db5c52046c7
line |
diff
|
|
0
0:5c1cbeda25de
Import Mercurial plugin 0.1
Brendan Cully <brendan@cs.ubc.ca>
previous changes:
line |
diff
|
Class = Mercurial |