- support bookmarks

Mon, 08 Dec 2014 23:27:43 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Mon, 08 Dec 2014 23:27:43 +0200
changeset 111
44d9aea72947
parent 110
b2770c43b752
child 112
cdafc1a0544e

- support bookmarks

hgpoll.py file | annotate | diff | comparison | revisions
mod_hgpoll.py file | annotate | diff | comparison | revisions
mod_util.py file | annotate | diff | comparison | revisions
--- a/hgpoll.py	Mon Dec 08 16:12:51 2014 -0500
+++ b/hgpoll.py	Mon Dec 08 23:27:43 2014 +0200
@@ -21,6 +21,9 @@
 		color = 0
 	return color
 
+def prettify_bookmarks (bookmarks):
+	return "\0036 [\002%s\002]" % bookmarks
+
 def make_commits_txt():
 	global g_needCommitsTxtRebuild
 
@@ -223,8 +226,8 @@
 		match = rex.match (line)
 		if match:
 			line = '%s|%s [color=#5F7]%s[/color][color=#F53]%s[/color]%s\n' \
-				% (match.group (1), match.group (2), match.group (3), match.group (4), match.group
-(5))
+				% (match.group (1), match.group (2), match.group (3),
+				match.group (4), match.group (5))
 
 			# Tracker doesn't seem to like empty color tags
 			line = line.replace ('[color=#5F7][/color]', '').replace ('[color=#F53][/color]', '')
@@ -349,7 +352,9 @@
 		print 'Processing new commit %s...' % commit_node
 
 		try:
-			commit_author = get_commit_data (zanrepo, commit_node, '{author}')
+			data = get_commit_data (zanrepo, commit_node, '{author}@@@@@@@@@@{bookmarks}').split ("@@@@@@@@@@")
+			commit_author = data[0]
+			commit_bookmarks = prettify_bookmarks (data[1])
 			commit_url = '%s/commits/%s' % (repo_url, commit_node)
 			commit_email = ''
 
@@ -367,8 +372,9 @@
 				for channel in irc_client.channels:
 					if not usesandbox or channel.get_value ('btprivate', False):
 						irc_client.privmsg (channel.get_value ('name'),
-							"\003%d%s\003: new commit\0035 %s\003 by\0032 %s\003: %s"
-							% (color_for_repo (repo_name), repo_name, commit_node, committer, commit_url))
+							"\003%d%s\003: new commit\0035 %s%s\003 by\0032 %s\003: %s"
+							% (color_for_repo (repo_name), repo_name, commit_node, commit_bookmarks,
+							committer, commit_url))
 
 						for line in commit_message.split ('\n'):
 							irc_client.privmsg (channel.get_value ('name'), line)
--- a/mod_hgpoll.py	Mon Dec 08 16:12:51 2014 -0500
+++ b/mod_hgpoll.py	Mon Dec 08 23:27:43 2014 +0200
@@ -51,7 +51,7 @@
 		datetime.strptime (args['key'], '%y%m%d-%H%M')
 		HgPoll.make_commits_txt()
 		commits_txt = open ('commits.txt', 'r')
-		
+
 		for line in commits_txt:
 			data = line.replace ('\n', '').split (' ')
 			if data[1] == args['key']:
@@ -62,16 +62,21 @@
 			return
 	except ValueError:
 		pass
-	
+
 	# The sandboxes contain all revisions in zandronum and zandronum-stable.
 	# Thus we only need to try find the revision in the sandbox repos.
 	try:
 		data = repo.hg_command ("log", "-r", node, "--template",
-			"{node|short}@@@@@@@{desc}@@@@@@@{author}@@@@@@@{diffstat}@@@@@@@{date|hgdate}")
+			"{node|short}@@@@@@@" +
+			"{desc}@@@@@@@" +
+			"{author}@@@@@@@" +
+			"{diffstat}@@@@@@@" +
+			"{date|hgdate}@@@@@@@" +
+			"{bookmarks}")
 	except hgapi.HgException:
 		bot.privmsg (replyto, 'couldn\'t find changeset %s' % (node))
 		return
-	
+
 	try:
 		data = data.split ('@@@@@@@')
 		node = data[0]
@@ -79,40 +84,44 @@
 		author = data[2]
 		diffstat = data[3]
 		date = datetime.utcfromtimestamp (int (data[4].split (' ')[0]))
+		bookmarks = data[5]
 		delta = datetime.utcnow() - date
 		datestring = ''
-		
+
+		if bookmarks:
+			bookmarks = HgPoll.prettify_bookmarks (bookmarks)
+
 		# Find out the Zandronum version of this changeset
 		repo.hg_command ('revert', '-r', node, 'src/version.h')
 		zanversion = '<unknown zandronum version>'
-		
+
 		with open ('zandronum-everything/src/version.h') as version_file:
 			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 version_file:
 				for rex in regexps:
 					match = rex.match (line)
 					if match != None:
 						zanversion = match.group (1)
 						break
-				
+
 				if match != None:
 					break
-			
-		
+
+
 		repo.hg_command ('revert', '--all')
-		
+
 		# Remove the email address from the author if possible
 		match = re.compile (r'^(.+) <([^>]+)>$.*').match (author)
 		if match:
 			author = match.group (1)
 			email = match.group (2)
-		
+
 		username = Config.find_developer_by_email (email)
-		
+
 		if username != '':
 			author = username
 
@@ -137,15 +146,15 @@
 				datestring = '%d day%s ago' % (delta.days, plural (delta.days))
 		else:
 			datestring = 'on %s' % (str (date))
-		
-		bot.privmsg (replyto, 'changeset\0035 %s (%s %s)\003: committed by\0032 %s\003 %s,\0032 %s' % \
-			(node, zanversion, date.strftime ('%y%m%d-%H%M'), author, datestring, diffstat))
-		
+
+		bot.privmsg (replyto, 'changeset\0035 %s%s\003 (%s %s)\003: committed by\0032 %s\003 %s,\0032 %s' % \
+			(node, bookmarks, zanversion, date.strftime ('%y%m%d-%H%M'), author, datestring, diffstat))
+
 		for line in message.split ('\n'):
 			bot.privmsg (replyto, '    ' + line)
 	except hgapi.HgException as e:
 		result = HgPoll.decipher_hgapi_error (e)
-		
+
 		if result[0]:
 			bot.privmsg (replyto, 'error: %s' % result[1])
 		else:
@@ -158,7 +167,7 @@
 		self.privmsg (replyto, result)
 	except hgapi.hgapi.HgException as e:
 		result = HgPoll.decipher_hgapi_error (e)
-		
+
 		if result[0]:
 			self.privmsg (replyto, 'error: %s' % result[1])
 		else:
--- a/mod_util.py	Mon Dec 08 16:12:51 2014 -0500
+++ b/mod_util.py	Mon Dec 08 23:27:43 2014 +0200
@@ -105,7 +105,7 @@
 		commandlist = commandlist[15:]
 
 	for part in partitioned:
-		bot.privmsg (replyto, 'Available commands: %s' % (", ".join (part)))
+		bot.privmsg (replyto, '\002Available commands\002: %s' % (", ".join (part)))
 
 def cmd_help (bot, replyto, ident, host, args, **rest):
 	cmd = ModuleCore.get_command_by_name (args['command'])

mercurial