| 237 hgns = Config.get_node ('hg') |
237 hgns = Config.get_node ('hg') |
| 238 |
238 |
| 239 if not hgns.get_value ('track', default=True): |
239 if not hgns.get_value ('track', default=True): |
| 240 return |
240 return |
| 241 |
241 |
| |
242 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable' |
| |
243 repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk' |
| |
244 zanrepo = hgapi.Repo (repo_name) |
| |
245 commit_data = [] |
| |
246 delimeter = '@@@@@@@@@@' |
| |
247 print 'Checking %s for updates' % repo_name |
| |
248 |
| |
249 try: |
| |
250 data = zanrepo.hg_command ('incoming', '--quiet', '--template', |
| |
251 '{node|short} {desc}' + delimeter) |
| |
252 except hgapi.hgapi.HgException as e: |
| |
253 deciphered = decipher_hgapi_error (e) |
| |
254 |
| |
255 if deciphered[0] and len(deciphered[1]) > 0: |
| |
256 Irc.broadcast ("error while using hg import on %s: %s" % (repo_name, deciphered[1])) |
| |
257 |
| |
258 return |
| |
259 except Exception as e: |
| |
260 Irc.broadcast ("%s" % `e`) |
| |
261 return |
| |
262 |
| |
263 for line in data.split (delimeter): |
| |
264 if line == '': |
| |
265 continue |
| |
266 |
| |
267 rex = re.compile (r'([^ ]+) (.+)') |
| |
268 match = rex.match (line) |
| |
269 failed = False |
| |
270 |
| |
271 if not match: |
| |
272 Irc.broadcast ('malformed hg data: %s' % line) |
| |
273 continue |
| |
274 |
| |
275 commit_node = match.group (1) |
| |
276 commit_message = match.group (2) |
| |
277 commit_data.append ([commit_node, commit_message]) |
| |
278 |
| |
279 process_new_commits (repo_name, commit_data) |
| |
280 |
| |
281 def process_new_commits (repo_name, commit_data): |
| 242 usestable = repo_name == 'zandronum-stable' |
282 usestable = repo_name == 'zandronum-stable' |
| 243 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable' |
283 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable' |
| 244 repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk' |
284 repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk' |
| 245 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name) |
285 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name) |
| 246 num_commits = 0 |
286 num_commits = 0 |
| 247 zanrepo = hgapi.Repo (repo_name) |
287 zanrepo = hgapi.Repo (repo_name) |
| 248 commit_data = [] |
|
| 249 delimeter = '@@@@@@@@@@' |
|
| 250 print 'Checking %s for updates' % repo_name |
|
| 251 |
|
| 252 try: |
|
| 253 data = zanrepo.hg_command ('incoming', '--quiet', '--template', |
|
| 254 '{node|short} {desc}' + delimeter) |
|
| 255 except hgapi.hgapi.HgException as e: |
|
| 256 deciphered = decipher_hgapi_error (e) |
|
| 257 |
|
| 258 if deciphered[0] and len(deciphered[1]) > 0: |
|
| 259 Irc.broadcast ("error while using hg import on %s: %s" % (repo_name, deciphered[1])) |
|
| 260 |
|
| 261 return |
|
| 262 except Exception as e: |
|
| 263 Irc.broadcast ("%s" % `e`) |
|
| 264 return |
|
| 265 |
|
| 266 for line in data.split (delimeter): |
|
| 267 if line == '': |
|
| 268 continue |
|
| 269 |
|
| 270 rex = re.compile (r'([^ ]+) (.+)') |
|
| 271 match = rex.match (line) |
|
| 272 failed = False |
|
| 273 |
|
| 274 if not match: |
|
| 275 Irc.broadcast ('malformed hg data: %s' % line) |
|
| 276 continue |
|
| 277 |
|
| 278 commit_node = match.group (1) |
|
| 279 commit_message = match.group (2) |
|
| 280 commit_data.append ([commit_node, commit_message]) |
|
| 281 |
|
| 282 process_new_commits (repo_name, commit_data) |
|
| 283 |
|
| 284 def process_new_commits (repo_name, commit_data): |
|
| 285 Irc.broadcast ('%d new commits on %s' % (len (commit_data), repo_name)) |
288 Irc.broadcast ('%d new commits on %s' % (len (commit_data), repo_name)) |
| 286 |
289 |
| 287 if len (commit_data) > 0: |
290 if len (commit_data) > 0: |
| 288 pull_args = []; |
291 pull_args = []; |
| 289 |
292 |