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)