# HG changeset patch # User Teemu Piippo # Date 1438620357 -10800 # Node ID 588aff83bb870c5dd43d24cf73cf3cd875596737 # Parent b3d1b356e54455c9a4872a74297c8e4b444ecf50 - Encode messages in the hgpoll module so that joining them won't result in an error if they cannot be coded to ascii - Support for Doomseeker's VERSION_STRING in version string parsing diff -r b3d1b356e544 -r 588aff83bb87 hgpoll.py --- a/hgpoll.py Sun Aug 02 17:15:00 2015 +0300 +++ b/hgpoll.py Mon Aug 03 19:45:57 2015 +0300 @@ -439,6 +439,11 @@ Irc.broadcast ('Error while processing %s: %s' % (commit_node, e)) continue + # Encode messages + for messagelist in messages: + for i in range (0, len (messagelist)): + messagelist[i] = messagelist[i].decode ("utf-8", "ignore").encode("ascii", "ignore") + fullMessageLength = len (''.join (messages[2])) if fullMessageLength > 3000: diff -r b3d1b356e544 -r 588aff83bb87 mod_hg.py --- a/mod_hg.py Sun Aug 02 17:15:00 2015 +0300 +++ b/mod_hg.py Mon Aug 03 19:45:57 2015 +0300 @@ -109,6 +109,30 @@ return (node, reponame) +def get_version_string (reponame, node): + try: + data = subprocess.check_output (['hg', '--cwd', reponame, 'cat', + '--rev', node, 'src/version.h']) + + regexps = [ \ + re.compile (r'#define\s+GAMEVER_STRING\s+"([^"]+)"'), \ + re.compile (r'#define\s+DOTVERSIONSTR_NOREV\s+"([^"]+)"'), \ + re.compile (r'#define\s+DOTVERSIONSTR\s+"([^"]+)"')] + except subprocess.CalledProcessError: + try: + data = subprocess.check_output (['hg', '--cwd', reponame, 'cat', + '--rev', node, 'src/core/versiondefs.h']) + regexps = [re.compile (r'#define\s+VERSION_STRING\s+"([^"]+)"')] + except subprocess.CalledProcessError: + return '' + + for line in data.splitlines(): + for rex in regexps: + match = rex.match (line) + + if match: + return match.group (1) + def cmd_cset (bot, args, reply, **rest): data = "" node, reponame = resolve_node (args['key']) @@ -146,27 +170,8 @@ if bookmarks: bookmarks = HgPoll.prettify_bookmarks (bookmarks) - # Find out the Zandronum version of this changeset - data = subprocess.check_output (['hg', '--cwd', reponame, 'cat', '--rev', node, 'src/version.h']) - zanversion = '' - - try: - regexps = [ \ - re.compile (r'#define\s+GAMEVER_STRING\s+"([^"]+)"'), \ - re.compile (r'#define\s+DOTVERSIONSTR_NOREV\s+"([^"]+)"'), \ - re.compile (r'#define\s+DOTVERSIONSTR\s+"([^"]+)"')] - - for line in data.splitlines(): - for rex in regexps: - match = rex.match (line) - if match != None: - zanversion = match.group (1) - break - - if match != None: - break - except IOError: - pass + # Find out the version string of this changeset + versionstring = get_version_string (reponame, node) subprocess.call (['hg', '--cwd', reponame, 'revert', '--all']) username = Config.find_developer_by_email (email) @@ -195,15 +200,19 @@ else: datestring = 'on %s' % (str (date)) - versionstring = "" if latesttagdistance != 0: - versionstring = '%s %s, %d hops from %s' % (zanversion, date.strftime ('%y%m%d-%H%M'), + versionblurb = "" + + if versionstring: + versionblurb = versionstring + ' ' + + versionblurb += '%s, %d hops from %s' % (date.strftime ('%y%m%d-%H%M'), latesttagdistance, latesttag) else: - versionstring = latesttag + versionblurb = latesttag reply ('changeset\0035 %s%s\003 (%s)\003: committed by\0032 %s\003 %s,\0032 %s' % \ - (node, bookmarks, versionstring, author, datestring, diffstat)) + (node, bookmarks, versionblurb, author, datestring, diffstat)) for line in message.split ('\n'): reply (' ' + line)