mod_hgpoll.py

Sat, 15 Nov 2014 16:48:08 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sat, 15 Nov 2014 16:48:08 +0200
changeset 85
302e2bec51d8
parent 82
c6e853703ca8
child 87
9e757b602586
permissions
-rw-r--r--

- fixed bad find_developer_by_email call

72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 from hgapi import hgapi, Repo
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
2 from datetime import datetime
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 import hgpoll as HgPoll
74
9f14fb6995ff - added a missing import..
Teemu Piippo <crimsondusk64@gmail.com>
parents: 73
diff changeset
4 import re
76
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
5 import bt as Bt
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
6 from configfile import Config
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 ModuleData = {
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 'commands':
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 [
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 {
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 'name': 'checkhg',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 'description': 'Polls the zandronum repositories for updates',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 'args': None,
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 'level': 'admin',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 },
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 {
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 'name': 'cset',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 'description': 'Yields changeset information (use a hash or date as key)',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 'args': '<key>',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 'level': 'normal',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 },
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 {
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 'name': 'hg',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 'description': 'Executes a hg command',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 'args': '<repo> <command...>',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 'level': 'admin',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 }
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 ]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 }
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31
76
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
32 def plural (a):
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
33 return '' if a == 1 else 's'
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
34
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 def cmd_checkhg (bot, **rest):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 HgPoll.force_poll()
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37
76
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
38 def cmd_cset (bot, args, replyto, **rest):
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 repo = Repo ('zandronum-everything')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 data = ""
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 node = args['key']
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 # Possibly we're passed a date version instead. Try find the node for this.
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 datetime.strptime (args['key'], '%y%m%d-%H%M')
76
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
46 HgPoll.make_commits_txt()
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 commits_txt = open ('commits.txt', 'r')
79
6d17630d1468 - update formatting on mod_hgpoll.py
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
48
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 for line in commits_txt:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 data = line.replace ('\n', '').split (' ')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 if data[1] == args['key']:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 node = data[0]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 break
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 else:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 bot.privmsg (replyto, 'couldn\'t find changset for date %s' % args['key'])
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 return
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 except ValueError:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 pass
79
6d17630d1468 - update formatting on mod_hgpoll.py
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
59
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 # The sandboxes contain all revisions in zandronum and zandronum-stable.
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 # Thus we only need to try find the revision in the sandbox repos.
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 try:
80
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
63 data = repo.hg_command ("log", "-r", node, "--template",
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
64 "{node|short}@@@@@@@{desc}@@@@@@@{author}@@@@@@@{diffstat}@@@@@@@{date|hgdate}")
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 except hgapi.HgException:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 bot.privmsg (replyto, 'couldn\'t find changeset %s' % (node))
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 return
79
6d17630d1468 - update formatting on mod_hgpoll.py
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
68
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 data = data.split ('@@@@@@@')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 node = data[0]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 message = data[1]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 author = data[2]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 diffstat = data[3]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 date = datetime.utcfromtimestamp (int (data[4].split (' ')[0]))
82
c6e853703ca8 - fixed bad age message in .cset
Teemu Piippo <crimsondusk64@gmail.com>
parents: 80
diff changeset
76 delta = datetime.utcnow() - date
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 datestring = ''
79
6d17630d1468 - update formatting on mod_hgpoll.py
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
78
80
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
79 # Find out the Zandronum version of this changeset
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
80 repo.hg_command ('revert', '-r', node, 'src/version.h')
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
81 zanversion = '<unknown zandronum version>'
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
82
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
83 with open ('zandronum-everything/src/version.h') as version_file:
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
84 regexps = [ \
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
85 re.compile (r'#define\s+GAMEVER_STRING\s+"([^"]+)"'), \
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
86 re.compile (r'#define\s+DOTVERSIONSTR_NOREV\s+"([^"]+)"'), \
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
87 re.compile (r'#define\s+DOTVERSIONSTR\s+"([^"]+)"')]
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
88
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
89 for line in version_file:
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
90 for rex in regexps:
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
91 match = rex.match (line)
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
92 if match != None:
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
93 zanversion = match.group (1)
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
94 break
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
95
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
96 if match != None:
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
97 break
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
98
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
99
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
100 repo.hg_command ('revert', '--all')
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
101
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 # Remove the email address from the author if possible
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103 match = re.compile (r'^(.+) <([^>]+)>$.*').match (author)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 if match:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 author = match.group (1)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106 email = match.group (2)
79
6d17630d1468 - update formatting on mod_hgpoll.py
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
107
76
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
108 username = Config.find_developer_by_email (email)
79
6d17630d1468 - update formatting on mod_hgpoll.py
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
109
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 if username != '':
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 author = username
79
6d17630d1468 - update formatting on mod_hgpoll.py
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
112
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 if delta.days < 4:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114 if delta.days == 0:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 if delta.seconds < 60:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 datestring = 'just now'
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 elif delta.seconds < 3600:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 minutes = delta.seconds / 60
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 datestring = '%d minute%s ago' % (minutes, plural (minutes))
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 else:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 hours = delta.seconds / 3600
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 datestring = '%d hour%s ago' % (hours, plural (hours))
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 else:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 datestring = '%d day%s ago' % (delta.days, plural (delta.days))
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 else:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 datestring = 'on %s' % (str (date))
79
6d17630d1468 - update formatting on mod_hgpoll.py
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
127
80
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
128 bot.privmsg (replyto, 'changeset %s (%s %s): committed by %s %s (%s)' % \
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
129 (node, zanversion, date.strftime ('%y%m%d-%H%M'), author, datestring, diffstat))
79
6d17630d1468 - update formatting on mod_hgpoll.py
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
130
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 for line in message.split ('\n'):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 bot.privmsg (replyto, ' ' + line)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 except hgapi.HgException as e:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134 result = HgPoll.decipher_hgapi_error (e)
79
6d17630d1468 - update formatting on mod_hgpoll.py
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
135
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 if result[0]:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 bot.privmsg (replyto, 'error: %s' % result[1])
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 else:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 bot.privmsg (replyto, 'error: %s' % `e`)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141 def cmd_hg (bot, args, **rest):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 repo = hgapi.Repo (args['repo'])
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 result = repo.hg_command (*args['command'])
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 self.privmsg (replyto, result)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 except hgapi.hgapi.HgException as e:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 result = HgPoll.decipher_hgapi_error (e)
79
6d17630d1468 - update formatting on mod_hgpoll.py
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
148
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149 if result[0]:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 self.privmsg (replyto, 'error: %s' % result[1])
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 else:
79
6d17630d1468 - update formatting on mod_hgpoll.py
Teemu Piippo <crimsondusk64@gmail.com>
parents: 76
diff changeset
152 self.privmsg (replyto, 'error: %s' % `e`)

mercurial