Thu, 15 Jan 2015 19:06:14 +0200
- added bridging functionality
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 | 5 | import bt as Bt |
6 | from configfile import Config | |
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
7 | from modulecore import command_error |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | ModuleData = { |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | 'commands': |
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 | { |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | 'name': 'checkhg', |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | 'description': 'Polls the zandronum repositories for updates', |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | 'args': None, |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | 'level': 'admin', |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | }, |
117
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
18 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | { |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | 'name': 'cset', |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | '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
|
22 | 'args': '<key>', |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | 'level': 'normal', |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | }, |
117
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
25 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | { |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | 'name': 'hg', |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | 'description': 'Executes a hg command', |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | 'args': '<repo> <command...>', |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | 'level': 'admin', |
87 | 31 | }, |
117
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
32 | |
87 | 33 | { |
34 | 'name': 'resolves', | |
35 | 'description': 'Manually cause a ticket to be resolved by a changeset', | |
36 | 'args': '<ticket> <changeset>', | |
117
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
37 | 'level': 'admin', # TODO |
87 | 38 | }, |
117
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
39 | |
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
40 | { |
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
41 | 'name': 'compress', |
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
42 | 'description': 'Compresses a head on the sandbox repositories.', |
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
43 | 'args': '<changeset>', |
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
44 | 'level': 'admin', # TODO |
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
45 | } |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | ] |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | } |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | |
76 | 49 | def plural (a): |
50 | return '' if a == 1 else 's' | |
51 | ||
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | def cmd_checkhg (bot, **rest): |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | HgPoll.force_poll() |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | |
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
55 | def cmd_cset (bot, args, reply, **rest): |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | repo = Repo ('zandronum-everything') |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | data = "" |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | node = args['key'] |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | # 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
|
61 | try: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | datetime.strptime (args['key'], '%y%m%d-%H%M') |
76 | 63 | HgPoll.make_commits_txt() |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | commits_txt = open ('commits.txt', 'r') |
111 | 65 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | for line in commits_txt: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | data = line.replace ('\n', '').split (' ') |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | if data[1] == args['key']: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | node = data[0] |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | break |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | else: |
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
72 | command_error ('couldn\'t find changeset for date %s' % args['key']) |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | return |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | except ValueError: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | pass |
111 | 76 | |
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
77 | # zandronum-everything contains all zandronum changesets, so look for changesets in that. |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | try: |
112 | 79 | data = repo.hg_command ("log", "-l1", "-r", node, "--template", |
111 | 80 | "{node|short}@@@@@@@" + |
81 | "{desc}@@@@@@@" + | |
82 | "{author}@@@@@@@" + | |
83 | "{diffstat}@@@@@@@" + | |
84 | "{date|hgdate}@@@@@@@" + | |
112 | 85 | "{bookmarks}@@@@@@@" + |
86 | "{latesttagdistance}@@@@@@@" + | |
87 | "{latesttag}") | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | except hgapi.HgException: |
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
89 | command_error ('couldn\'t find changeset %s' % (node)) |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | return |
111 | 91 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | try: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | data = data.split ('@@@@@@@') |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | node = data[0] |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | message = data[1] |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | author = data[2] |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | diffstat = data[3] |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | date = datetime.utcfromtimestamp (int (data[4].split (' ')[0])) |
111 | 99 | bookmarks = data[5] |
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
100 | latesttagdistance = int (data[6]) |
112 | 101 | latesttag = data[7] |
82
c6e853703ca8
- fixed bad age message in .cset
Teemu Piippo <crimsondusk64@gmail.com>
parents:
80
diff
changeset
|
102 | delta = datetime.utcnow() - date |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | datestring = '' |
111 | 104 | |
105 | if bookmarks: | |
106 | bookmarks = HgPoll.prettify_bookmarks (bookmarks) | |
107 | ||
80
0f6bfd359a7f
- .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents:
79
diff
changeset
|
108 | # 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
|
109 | 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
|
110 | zanversion = '<unknown zandronum version>' |
111 | 111 | |
80
0f6bfd359a7f
- .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents:
79
diff
changeset
|
112 | 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
|
113 | regexps = [ \ |
0f6bfd359a7f
- .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents:
79
diff
changeset
|
114 | 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
|
115 | 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
|
116 | re.compile (r'#define\s+DOTVERSIONSTR\s+"([^"]+)"')] |
111 | 117 | |
80
0f6bfd359a7f
- .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents:
79
diff
changeset
|
118 | for line in version_file: |
0f6bfd359a7f
- .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents:
79
diff
changeset
|
119 | for rex in regexps: |
0f6bfd359a7f
- .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents:
79
diff
changeset
|
120 | match = rex.match (line) |
0f6bfd359a7f
- .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents:
79
diff
changeset
|
121 | if match != None: |
0f6bfd359a7f
- .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents:
79
diff
changeset
|
122 | zanversion = match.group (1) |
0f6bfd359a7f
- .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents:
79
diff
changeset
|
123 | break |
111 | 124 | |
80
0f6bfd359a7f
- .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents:
79
diff
changeset
|
125 | if match != None: |
0f6bfd359a7f
- .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents:
79
diff
changeset
|
126 | break |
111 | 127 | |
128 | ||
80
0f6bfd359a7f
- .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents:
79
diff
changeset
|
129 | repo.hg_command ('revert', '--all') |
111 | 130 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | # 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
|
132 | match = re.compile (r'^(.+) <([^>]+)>$.*').match (author) |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | if match: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | author = match.group (1) |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | email = match.group (2) |
111 | 136 | |
76 | 137 | username = Config.find_developer_by_email (email) |
111 | 138 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | if username != '': |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | author = username |
110 | 141 | |
142 | # Try prettify the diffstat | |
143 | rex = re.compile (r'^([0-9]+): \+([0-9]+)/-([0-9]+)$') | |
144 | match = rex.match (diffstat) | |
145 | ||
146 | if match: | |
147 | diffstat = "%s\003:\0033 +%s\003/\0034-%s\003" % (match.group (1), match.group (2), match.group (3)) | |
148 | ||
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | if delta.days < 4: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | if delta.days == 0: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | if delta.seconds < 60: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | datestring = 'just now' |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | elif delta.seconds < 3600: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | minutes = delta.seconds / 60 |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | datestring = '%d minute%s ago' % (minutes, plural (minutes)) |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | else: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | hours = delta.seconds / 3600 |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | datestring = '%d hour%s ago' % (hours, plural (hours)) |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | else: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | 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
|
161 | else: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | datestring = 'on %s' % (str (date)) |
111 | 163 | |
112 | 164 | versionstring = "" |
165 | if latesttagdistance != 0: | |
166 | versionstring = '%s %s, %d hops from %s' % (zanversion, date.strftime ('%y%m%d-%H%M'), latesttagdistance, latesttag) | |
167 | else: | |
168 | versionstring = latesttag | |
169 | ||
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
170 | reply ('changeset\0035 %s%s\003 (%s)\003: committed by\0032 %s\003 %s,\0032 %s' % \ |
112 | 171 | (node, bookmarks, versionstring, author, datestring, diffstat)) |
111 | 172 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | for line in message.split ('\n'): |
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
174 | reply (' ' + line) |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | except hgapi.HgException as e: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
176 | result = HgPoll.decipher_hgapi_error (e) |
111 | 177 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | if result[0]: |
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
179 | command_error (result[1]) |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
180 | else: |
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
181 | command_error (`e`) |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | |
117
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
183 | def cmd_hg (bot, args, reply, **rest): |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | try: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | repo = hgapi.Repo (args['repo']) |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
186 | result = repo.hg_command (*args['command']) |
117
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
187 | reply (result) |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | except hgapi.hgapi.HgException as e: |
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | result = HgPoll.decipher_hgapi_error (e) |
111 | 190 | |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | if result[0]: |
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
192 | command_error (result[1]) |
72
2266d6d73de3
- commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | else: |
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
194 | command_error (`e`) |
87 | 195 | |
117
6c0609395889
- added a confirm system, probably useful in the future
Teemu Piippo <crimsondusk64@gmail.com>
parents:
116
diff
changeset
|
196 | def cmd_resolves (bot, args, **rest): |
87 | 197 | try: |
198 | HgPoll.announce_ticket_resolved (args['ticket'], args['changeset']) | |
199 | except Exception as e: | |
113
08e9b1c1b324
- added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents:
112
diff
changeset
|
200 | command_error (str (e)) |