mod_hg.py

changeset 152
1b734faab67a
parent 151
e24793fae424
child 155
5a9b5065f53f
equal deleted inserted replaced
151:e24793fae424 152:1b734faab67a
51 'args': '<key>', 51 'args': '<key>',
52 'level': 'normal', 52 'level': 'normal',
53 }, 53 },
54 54
55 { 55 {
56 'name': 'hg',
57 'description': 'Executes a hg command',
58 'args': '<command...>',
59 'level': 'admin',
60 },
61
62 {
63 'name': 'resolves', 56 'name': 'resolves',
64 'description': '''Manually cause a ticket to be resolved by a changeset''', 57 'description': '''Manually cause a ticket to be resolved by a changeset''',
65 'args': '<ticket> <changeset>', 58 'args': '<ticket> <changeset>',
66 'level': 'admin', # TODO 59 'level': 'admin', # TODO
67 }, 60 },
135 if match: 128 if match:
136 return match.group (1) 129 return match.group (1)
137 130
138 def cmd_cset (bot, args, reply, **rest): 131 def cmd_cset (bot, args, reply, **rest):
139 node, repo = resolve_node (args['key']) 132 node, repo = resolve_node (args['key'])
140 133 commit = repo.get_commit_data (rev=node,
141 try: 134 node='node|short',
142 commit = repo.get_commit_data (rev=node, 135 message='desc',
143 node='node|short', 136 author='author',
144 message='desc', 137 diffstat='diffstat',
145 author='author', 138 time='date|hgdate',
146 diffstat='diffstat', 139 bookmarks='bookmarks',
147 time='date|hgdate', 140 latesttagdistance='latesttagdistance',
148 bookmarks='bookmarks', 141 latesttag='latesttag',
149 latesttagdistance='latesttagdistance', 142 email='author|email')
150 latesttag='latesttag',
151 email='author|email')
152 except Subprocess.CalledProcessError:
153 command_error ('''couldn't find changeset %s in %s''' % (node, repo.name))
154 143
155 del node 144 del node
156 commit['date'] = datetime.utcfromtimestamp (int (commit['time'].split (' ')[0])) 145 commit['date'] = datetime.utcfromtimestamp (int (commit['time'].split (' ')[0]))
157 commit['latesttagdistance'] = int (commit['latesttagdistance']) 146 commit['latesttagdistance'] = int (commit['latesttagdistance'])
158 commit['bookmarks'] = hgpoll.prettify_bookmarks (commit['bookmarks']) 147 commit['bookmarks'] = hgpoll.prettify_bookmarks (commit['bookmarks'])
205 for line in commit['message'].split ('\n'): 194 for line in commit['message'].split ('\n'):
206 reply (' ' + line) 195 reply (' ' + line)
207 196
208 reply ('url: %s/commits/%s' % (repo.url, commit['node'])) 197 reply ('url: %s/commits/%s' % (repo.url, commit['node']))
209 198
210 def cmd_hg (bot, args, reply, **rest):
211 try:
212 result = subprocess.check_output (['hg'] + args['command'])
213 reply (result)
214 except Exception as e:
215 command_error (str (e))
216
217 def cmd_resolves (bot, args, **rest): 199 def cmd_resolves (bot, args, **rest):
218 hgpoll.announce_ticket_resolved (args['ticket'], args['changeset']) 200 hgpoll.announce_ticket_resolved (args['ticket'], args['changeset'])

mercurial