mod_hgpoll.py

changeset 80
0f6bfd359a7f
parent 79
6d17630d1468
child 82
c6e853703ca8
equal deleted inserted replaced
79:6d17630d1468 80:0f6bfd359a7f
58 pass 58 pass
59 59
60 # The sandboxes contain all revisions in zandronum and zandronum-stable. 60 # The sandboxes contain all revisions in zandronum and zandronum-stable.
61 # Thus we only need to try find the revision in the sandbox repos. 61 # Thus we only need to try find the revision in the sandbox repos.
62 try: 62 try:
63 repo.hg_command ("log", "-r", node, "--template", " ") 63 data = repo.hg_command ("log", "-r", node, "--template",
64 "{node|short}@@@@@@@{desc}@@@@@@@{author}@@@@@@@{diffstat}@@@@@@@{date|hgdate}")
64 except hgapi.HgException: 65 except hgapi.HgException:
65 bot.privmsg (replyto, 'couldn\'t find changeset %s' % (node)) 66 bot.privmsg (replyto, 'couldn\'t find changeset %s' % (node))
66 return 67 return
67 68
68 try: 69 try:
69 data = repo.hg_command ("log", "-r", node, "--template",
70 "{node|short}@@@@@@@{desc}@@@@@@@{author}@@@@@@@{diffstat}@@@@@@@{date|hgdate}")
71 data = data.split ('@@@@@@@') 70 data = data.split ('@@@@@@@')
72
73 node = data[0] 71 node = data[0]
74 message = data[1] 72 message = data[1]
75 author = data[2] 73 author = data[2]
76 diffstat = data[3] 74 diffstat = data[3]
77 date = datetime.utcfromtimestamp (int (data[4].split (' ')[0])) 75 date = datetime.utcfromtimestamp (int (data[4].split (' ')[0]))
78 delta = datetime.now() - date 76 delta = datetime.now() - date
79 datestring = '' 77 datestring = ''
78
79 # Find out the Zandronum version of this changeset
80 repo.hg_command ('revert', '-r', node, 'src/version.h')
81 zanversion = '<unknown zandronum version>'
82
83 with open ('zandronum-everything/src/version.h') as version_file:
84 regexps = [ \
85 re.compile (r'#define\s+GAMEVER_STRING\s+"([^"]+)"'), \
86 re.compile (r'#define\s+DOTVERSIONSTR_NOREV\s+"([^"]+)"'), \
87 re.compile (r'#define\s+DOTVERSIONSTR\s+"([^"]+)"')]
88
89 for line in version_file:
90 for rex in regexps:
91 match = rex.match (line)
92 if match != None:
93 zanversion = match.group (1)
94 break
95
96 if match != None:
97 break
98
99
100 repo.hg_command ('revert', '--all')
80 101
81 # Remove the email address from the author if possible 102 # Remove the email address from the author if possible
82 match = re.compile (r'^(.+) <([^>]+)>$.*').match (author) 103 match = re.compile (r'^(.+) <([^>]+)>$.*').match (author)
83 if match: 104 if match:
84 author = match.group (1) 105 author = match.group (1)
102 else: 123 else:
103 datestring = '%d day%s ago' % (delta.days, plural (delta.days)) 124 datestring = '%d day%s ago' % (delta.days, plural (delta.days))
104 else: 125 else:
105 datestring = 'on %s' % (str (date)) 126 datestring = 'on %s' % (str (date))
106 127
107 bot.privmsg (replyto, 'changeset %s (%s): committed by %s %s (%s)' % \ 128 bot.privmsg (replyto, 'changeset %s (%s %s): committed by %s %s (%s)' % \
108 (node, date.strftime ('%y%m%d-%H%M'), author, datestring, diffstat)) 129 (node, zanversion, date.strftime ('%y%m%d-%H%M'), author, datestring, diffstat))
109 130
110 for line in message.split ('\n'): 131 for line in message.split ('\n'):
111 bot.privmsg (replyto, ' ' + line) 132 bot.privmsg (replyto, ' ' + line)
112 except hgapi.HgException as e: 133 except hgapi.HgException as e:
113 result = HgPoll.decipher_hgapi_error (e) 134 result = HgPoll.decipher_hgapi_error (e)

mercurial