mod_hgpoll.py

changeset 112
cdafc1a0544e
parent 111
44d9aea72947
child 113
08e9b1c1b324
equal deleted inserted replaced
111:44d9aea72947 112:cdafc1a0544e
64 pass 64 pass
65 65
66 # The sandboxes contain all revisions in zandronum and zandronum-stable. 66 # The sandboxes contain all revisions in zandronum and zandronum-stable.
67 # Thus we only need to try find the revision in the sandbox repos. 67 # Thus we only need to try find the revision in the sandbox repos.
68 try: 68 try:
69 data = repo.hg_command ("log", "-r", node, "--template", 69 data = repo.hg_command ("log", "-l1", "-r", node, "--template",
70 "{node|short}@@@@@@@" + 70 "{node|short}@@@@@@@" +
71 "{desc}@@@@@@@" + 71 "{desc}@@@@@@@" +
72 "{author}@@@@@@@" + 72 "{author}@@@@@@@" +
73 "{diffstat}@@@@@@@" + 73 "{diffstat}@@@@@@@" +
74 "{date|hgdate}@@@@@@@" + 74 "{date|hgdate}@@@@@@@" +
75 "{bookmarks}") 75 "{bookmarks}@@@@@@@" +
76 "{latesttagdistance}@@@@@@@" +
77 "{latesttag}")
76 except hgapi.HgException: 78 except hgapi.HgException:
77 bot.privmsg (replyto, 'couldn\'t find changeset %s' % (node)) 79 bot.privmsg (replyto, 'couldn\'t find changeset %s' % (node))
78 return 80 return
79 81
80 try: 82 try:
83 message = data[1] 85 message = data[1]
84 author = data[2] 86 author = data[2]
85 diffstat = data[3] 87 diffstat = data[3]
86 date = datetime.utcfromtimestamp (int (data[4].split (' ')[0])) 88 date = datetime.utcfromtimestamp (int (data[4].split (' ')[0]))
87 bookmarks = data[5] 89 bookmarks = data[5]
90 latesttagdistance = int( data[6] )
91 latesttag = data[7]
88 delta = datetime.utcnow() - date 92 delta = datetime.utcnow() - date
89 datestring = '' 93 datestring = ''
90 94
91 if bookmarks: 95 if bookmarks:
92 bookmarks = HgPoll.prettify_bookmarks (bookmarks) 96 bookmarks = HgPoll.prettify_bookmarks (bookmarks)
145 else: 149 else:
146 datestring = '%d day%s ago' % (delta.days, plural (delta.days)) 150 datestring = '%d day%s ago' % (delta.days, plural (delta.days))
147 else: 151 else:
148 datestring = 'on %s' % (str (date)) 152 datestring = 'on %s' % (str (date))
149 153
150 bot.privmsg (replyto, 'changeset\0035 %s%s\003 (%s %s)\003: committed by\0032 %s\003 %s,\0032 %s' % \ 154 versionstring = ""
151 (node, bookmarks, zanversion, date.strftime ('%y%m%d-%H%M'), author, datestring, diffstat)) 155 if latesttagdistance != 0:
156 versionstring = '%s %s, %d hops from %s' % (zanversion, date.strftime ('%y%m%d-%H%M'), latesttagdistance, latesttag)
157 else:
158 versionstring = latesttag
159
160 bot.privmsg (replyto, 'changeset\0035 %s%s\003 (%s)\003: committed by\0032 %s\003 %s,\0032 %s' % \
161 (node, bookmarks, versionstring, author, datestring, diffstat))
152 162
153 for line in message.split ('\n'): 163 for line in message.split ('\n'):
154 bot.privmsg (replyto, ' ' + line) 164 bot.privmsg (replyto, ' ' + line)
155 except hgapi.HgException as e: 165 except hgapi.HgException as e:
156 result = HgPoll.decipher_hgapi_error (e) 166 result = HgPoll.decipher_hgapi_error (e)

mercurial