mod_hgpoll.py

Wed, 31 Dec 2014 15:49:11 -0500

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Wed, 31 Dec 2014 15:49:11 -0500
changeset 114
0d1fd111cb22
parent 113
08e9b1c1b324
permissions
-rw-r--r--

- .idgames now works with the page system

72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 from hgapi import hgapi, Repo
73
d67cc4fbc3f1 - modularization complete!!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
2 from datetime import datetime
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 import hgpoll as HgPoll
74
9f14fb6995ff - added a missing import..
Teemu Piippo <crimsondusk64@gmail.com>
parents: 73
diff changeset
4 import re
76
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
5 import bt as Bt
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
6 from configfile import Config
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
7 from modulecore import command_error
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 ModuleData = {
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 'commands':
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 [
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 {
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 'name': 'checkhg',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 'description': 'Polls the zandronum repositories for updates',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 'args': None,
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 'level': 'admin',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 },
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 {
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 'name': 'cset',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 'description': 'Yields changeset information (use a hash or date as key)',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 'args': '<key>',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 'level': 'normal',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 },
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 {
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 'name': 'hg',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 'description': 'Executes a hg command',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 'args': '<repo> <command...>',
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 'level': 'admin',
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
29 },
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
30 {
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
31 'name': 'resolves',
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
32 'description': 'Manually cause a ticket to be resolved by a changeset',
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
33 'args': '<ticket> <changeset>',
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
34 'level': 'admin',
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
35 },
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 ]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 }
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38
76
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
39 def plural (a):
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
40 return '' if a == 1 else 's'
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
41
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 def cmd_checkhg (bot, **rest):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 HgPoll.force_poll()
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
45 def cmd_cset (bot, args, reply, **rest):
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 repo = Repo ('zandronum-everything')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 data = ""
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 node = args['key']
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 # Possibly we're passed a date version instead. Try find the node for this.
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 datetime.strptime (args['key'], '%y%m%d-%H%M')
76
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
53 HgPoll.make_commits_txt()
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 commits_txt = open ('commits.txt', 'r')
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
55
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 for line in commits_txt:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 data = line.replace ('\n', '').split (' ')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 if data[1] == args['key']:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 node = data[0]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 break
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 else:
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
62 command_error ('couldn\'t find changeset for date %s' % args['key'])
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 return
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 except ValueError:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 pass
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
66
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
67 # zandronum-everything contains all zandronum changesets, so look for changesets in that.
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 try:
112
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
69 data = repo.hg_command ("log", "-l1", "-r", node, "--template",
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
70 "{node|short}@@@@@@@" +
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
71 "{desc}@@@@@@@" +
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
72 "{author}@@@@@@@" +
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
73 "{diffstat}@@@@@@@" +
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
74 "{date|hgdate}@@@@@@@" +
112
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
75 "{bookmarks}@@@@@@@" +
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
76 "{latesttagdistance}@@@@@@@" +
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
77 "{latesttag}")
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 except hgapi.HgException:
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
79 command_error ('couldn\'t find changeset %s' % (node))
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80 return
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
81
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 data = data.split ('@@@@@@@')
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 node = data[0]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 message = data[1]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 author = data[2]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 diffstat = data[3]
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 date = datetime.utcfromtimestamp (int (data[4].split (' ')[0]))
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
89 bookmarks = data[5]
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
90 latesttagdistance = int (data[6])
112
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
91 latesttag = data[7]
82
c6e853703ca8 - fixed bad age message in .cset
Teemu Piippo <crimsondusk64@gmail.com>
parents: 80
diff changeset
92 delta = datetime.utcnow() - date
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 datestring = ''
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
94
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
95 if bookmarks:
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
96 bookmarks = HgPoll.prettify_bookmarks (bookmarks)
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
97
80
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
98 # Find out the Zandronum version of this changeset
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
99 repo.hg_command ('revert', '-r', node, 'src/version.h')
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
100 zanversion = '<unknown zandronum version>'
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
101
80
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
102 with open ('zandronum-everything/src/version.h') as version_file:
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
103 regexps = [ \
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
104 re.compile (r'#define\s+GAMEVER_STRING\s+"([^"]+)"'), \
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
105 re.compile (r'#define\s+DOTVERSIONSTR_NOREV\s+"([^"]+)"'), \
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
106 re.compile (r'#define\s+DOTVERSIONSTR\s+"([^"]+)"')]
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
107
80
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
108 for line in version_file:
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
109 for rex in regexps:
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
110 match = rex.match (line)
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
111 if match != None:
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
112 zanversion = match.group (1)
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
113 break
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
114
80
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
115 if match != None:
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
116 break
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
117
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
118
80
0f6bfd359a7f - .cset now looks up the appropriate skulltag/zandronum version
Teemu Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
119 repo.hg_command ('revert', '--all')
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
120
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 # Remove the email address from the author if possible
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 match = re.compile (r'^(.+) <([^>]+)>$.*').match (author)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 if match:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 author = match.group (1)
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 email = match.group (2)
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
126
76
a2fe9ba3041a - various fixes
Teemu Piippo <crimsondusk64@gmail.com>
parents: 75
diff changeset
127 username = Config.find_developer_by_email (email)
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
128
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 if username != '':
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 author = username
110
b2770c43b752 - now in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
131
b2770c43b752 - now in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
132 # Try prettify the diffstat
b2770c43b752 - now in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
133 rex = re.compile (r'^([0-9]+): \+([0-9]+)/-([0-9]+)$')
b2770c43b752 - now in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
134 match = rex.match (diffstat)
b2770c43b752 - now in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
135
b2770c43b752 - now in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
136 if match:
b2770c43b752 - now in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
137 diffstat = "%s\003:\0033 +%s\003/\0034-%s\003" % (match.group (1), match.group (2), match.group (3))
b2770c43b752 - now in color!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 87
diff changeset
138
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 if delta.days < 4:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 if delta.days == 0:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141 if delta.seconds < 60:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 datestring = 'just now'
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 elif delta.seconds < 3600:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 minutes = delta.seconds / 60
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 datestring = '%d minute%s ago' % (minutes, plural (minutes))
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 else:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 hours = delta.seconds / 3600
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 datestring = '%d hour%s ago' % (hours, plural (hours))
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149 else:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 datestring = '%d day%s ago' % (delta.days, plural (delta.days))
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 else:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 datestring = 'on %s' % (str (date))
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
153
112
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
154 versionstring = ""
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
155 if latesttagdistance != 0:
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
156 versionstring = '%s %s, %d hops from %s' % (zanversion, date.strftime ('%y%m%d-%H%M'), latesttagdistance, latesttag)
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
157 else:
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
158 versionstring = latesttag
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
159
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
160 reply ('changeset\0035 %s%s\003 (%s)\003: committed by\0032 %s\003 %s,\0032 %s' % \
112
cdafc1a0544e - stuff!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 111
diff changeset
161 (node, bookmarks, versionstring, author, datestring, diffstat))
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
162
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163 for line in message.split ('\n'):
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
164 reply (' ' + line)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 except hgapi.HgException as e:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166 result = HgPoll.decipher_hgapi_error (e)
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
167
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 if result[0]:
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
169 command_error (result[1])
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170 else:
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
171 command_error (`e`)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
173 def cmd_hg (bot, args, **rest):
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
174 try:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175 repo = hgapi.Repo (args['repo'])
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 result = repo.hg_command (*args['command'])
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
177 reply (replyto, result)
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178 except hgapi.hgapi.HgException as e:
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179 result = HgPoll.decipher_hgapi_error (e)
111
44d9aea72947 - support bookmarks
Teemu Piippo <crimsondusk64@gmail.com>
parents: 110
diff changeset
180
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 if result[0]:
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
182 command_error (result[1])
72
2266d6d73de3 - commit work done on splitting bt/hg
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
183 else:
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
184 command_error (`e`)
87
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
185
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
186 def cmd_resolves (bot, args, replyto, **rest):
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
187 try:
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
188 HgPoll.announce_ticket_resolved (args['ticket'], args['changeset'])
9e757b602586 - added .resolves
Teemu Piippo <crimsondusk64@gmail.com>
parents: 82
diff changeset
189 except Exception as e:
113
08e9b1c1b324 - added page system to prevent commands from printing too much output
Teemu Piippo <crimsondusk64@gmail.com>
parents: 112
diff changeset
190 command_error (str (e))

mercurial