106 command_error ('''couldn't find changeset %s''' % node) |
106 command_error ('''couldn't find changeset %s''' % node) |
107 |
107 |
108 reponame = noderepos[0] |
108 reponame = noderepos[0] |
109 |
109 |
110 return (node, reponame) |
110 return (node, reponame) |
|
111 |
|
112 def get_version_string (reponame, node): |
|
113 try: |
|
114 data = subprocess.check_output (['hg', '--cwd', reponame, 'cat', |
|
115 '--rev', node, 'src/version.h']) |
|
116 |
|
117 regexps = [ \ |
|
118 re.compile (r'#define\s+GAMEVER_STRING\s+"([^"]+)"'), \ |
|
119 re.compile (r'#define\s+DOTVERSIONSTR_NOREV\s+"([^"]+)"'), \ |
|
120 re.compile (r'#define\s+DOTVERSIONSTR\s+"([^"]+)"')] |
|
121 except subprocess.CalledProcessError: |
|
122 try: |
|
123 data = subprocess.check_output (['hg', '--cwd', reponame, 'cat', |
|
124 '--rev', node, 'src/core/versiondefs.h']) |
|
125 regexps = [re.compile (r'#define\s+VERSION_STRING\s+"([^"]+)"')] |
|
126 except subprocess.CalledProcessError: |
|
127 return '' |
|
128 |
|
129 for line in data.splitlines(): |
|
130 for rex in regexps: |
|
131 match = rex.match (line) |
|
132 |
|
133 if match: |
|
134 return match.group (1) |
111 |
135 |
112 def cmd_cset (bot, args, reply, **rest): |
136 def cmd_cset (bot, args, reply, **rest): |
113 data = "" |
137 data = "" |
114 node, reponame = resolve_node (args['key']) |
138 node, reponame = resolve_node (args['key']) |
115 repourl = HgPoll.get_repo_info (reponame).get_value ('url') |
139 repourl = HgPoll.get_repo_info (reponame).get_value ('url') |
144 datestring = '' |
168 datestring = '' |
145 |
169 |
146 if bookmarks: |
170 if bookmarks: |
147 bookmarks = HgPoll.prettify_bookmarks (bookmarks) |
171 bookmarks = HgPoll.prettify_bookmarks (bookmarks) |
148 |
172 |
149 # Find out the Zandronum version of this changeset |
173 # Find out the version string of this changeset |
150 data = subprocess.check_output (['hg', '--cwd', reponame, 'cat', '--rev', node, 'src/version.h']) |
174 versionstring = get_version_string (reponame, node) |
151 zanversion = '<unknown version>' |
|
152 |
|
153 try: |
|
154 regexps = [ \ |
|
155 re.compile (r'#define\s+GAMEVER_STRING\s+"([^"]+)"'), \ |
|
156 re.compile (r'#define\s+DOTVERSIONSTR_NOREV\s+"([^"]+)"'), \ |
|
157 re.compile (r'#define\s+DOTVERSIONSTR\s+"([^"]+)"')] |
|
158 |
|
159 for line in data.splitlines(): |
|
160 for rex in regexps: |
|
161 match = rex.match (line) |
|
162 if match != None: |
|
163 zanversion = match.group (1) |
|
164 break |
|
165 |
|
166 if match != None: |
|
167 break |
|
168 except IOError: |
|
169 pass |
|
170 |
175 |
171 subprocess.call (['hg', '--cwd', reponame, 'revert', '--all']) |
176 subprocess.call (['hg', '--cwd', reponame, 'revert', '--all']) |
172 username = Config.find_developer_by_email (email) |
177 username = Config.find_developer_by_email (email) |
173 |
178 |
174 if username != '': |
179 if username != '': |
193 else: |
198 else: |
194 datestring = '%d day%s ago' % (delta.days, plural (delta.days)) |
199 datestring = '%d day%s ago' % (delta.days, plural (delta.days)) |
195 else: |
200 else: |
196 datestring = 'on %s' % (str (date)) |
201 datestring = 'on %s' % (str (date)) |
197 |
202 |
198 versionstring = "" |
|
199 if latesttagdistance != 0: |
203 if latesttagdistance != 0: |
200 versionstring = '%s %s, %d hops from %s' % (zanversion, date.strftime ('%y%m%d-%H%M'), |
204 versionblurb = "" |
|
205 |
|
206 if versionstring: |
|
207 versionblurb = versionstring + ' ' |
|
208 |
|
209 versionblurb += '%s, %d hops from %s' % (date.strftime ('%y%m%d-%H%M'), |
201 latesttagdistance, latesttag) |
210 latesttagdistance, latesttag) |
202 else: |
211 else: |
203 versionstring = latesttag |
212 versionblurb = latesttag |
204 |
213 |
205 reply ('changeset\0035 %s%s\003 (%s)\003: committed by\0032 %s\003 %s,\0032 %s' % \ |
214 reply ('changeset\0035 %s%s\003 (%s)\003: committed by\0032 %s\003 %s,\0032 %s' % \ |
206 (node, bookmarks, versionstring, author, datestring, diffstat)) |
215 (node, bookmarks, versionblurb, author, datestring, diffstat)) |
207 |
216 |
208 for line in message.split ('\n'): |
217 for line in message.split ('\n'): |
209 reply (' ' + line) |
218 reply (' ' + line) |
210 |
219 |
211 reply ('url: %s/commits/%s' % (repourl, node)) |
220 reply ('url: %s/commits/%s' % (repourl, node)) |