##// END OF EJS Templates
hgcia: Handle URL like in notify (issue2406)...
Cédric Krier -
r14314:c322890b default
parent child Browse files
Show More
@@ -18,7 +18,7 b' configure it, set the following options '
18 # Append a diffstat to the log message (optional)
18 # Append a diffstat to the log message (optional)
19 #diffstat = False
19 #diffstat = False
20 # Template to use for log messages (optional)
20 # Template to use for log messages (optional)
21 #template = {desc}\\n{baseurl}/rev/{node}-- {diffstat}
21 #template = {desc}\\n{baseurl}{webroot}/rev/{node}-- {diffstat}
22 # Style to use (optional)
22 # Style to use (optional)
23 #style = foo
23 #style = foo
24 # The URL of the CIA notification service (optional)
24 # The URL of the CIA notification service (optional)
@@ -28,6 +28,8 b' configure it, set the following options '
28 #url = http://cia.vc/
28 #url = http://cia.vc/
29 # print message instead of sending it (optional)
29 # print message instead of sending it (optional)
30 #test = False
30 #test = False
31 # number of slashes to strip for url paths
32 #strip = 0
31
33
32 [hooks]
34 [hooks]
33 # one of these:
35 # one of these:
@@ -66,6 +68,8 b' class ciamsg(object):'
66 self.cia = cia
68 self.cia = cia
67 self.ctx = ctx
69 self.ctx = ctx
68 self.url = self.cia.url
70 self.url = self.cia.url
71 if self.url:
72 self.url += self.cia.root
69
73
70 def fileelem(self, path, uri, action):
74 def fileelem(self, path, uri, action):
71 if uri:
75 if uri:
@@ -120,7 +124,9 b' class ciamsg(object):'
120 diffstat = self.cia.diffstat and self.diffstat() or ''
124 diffstat = self.cia.diffstat and self.diffstat() or ''
121 self.cia.ui.pushbuffer()
125 self.cia.ui.pushbuffer()
122 self.cia.templater.show(self.ctx, changes=self.ctx.changeset(),
126 self.cia.templater.show(self.ctx, changes=self.ctx.changeset(),
123 url=self.cia.url, diffstat=diffstat)
127 baseurl=self.cia.ui.config('web', 'baseurl'),
128 url=self.url, diffstat=diffstat,
129 webroot=self.cia.root)
124 return self.cia.ui.popbuffer()
130 return self.cia.ui.popbuffer()
125
131
126 def xml(self):
132 def xml(self):
@@ -184,6 +190,8 b' class hgcia(object):'
184 self.emailfrom = self.ui.config('email', 'from')
190 self.emailfrom = self.ui.config('email', 'from')
185 self.dryrun = self.ui.configbool('cia', 'test')
191 self.dryrun = self.ui.configbool('cia', 'test')
186 self.url = self.ui.config('web', 'baseurl')
192 self.url = self.ui.config('web', 'baseurl')
193 self.stripcount = int(self.ui.config('cia', 'strip', 0))
194 self.root = self.strip(self.repo.root)
187
195
188 style = self.ui.config('cia', 'style')
196 style = self.ui.config('cia', 'style')
189 template = self.ui.config('cia', 'template')
197 template = self.ui.config('cia', 'template')
@@ -195,6 +203,19 b' class hgcia(object):'
195 t.use_template(template)
203 t.use_template(template)
196 self.templater = t
204 self.templater = t
197
205
206 def strip(self, path):
207 '''strip leading slashes from local path, turn into web-safe path.'''
208
209 path = util.pconvert(path)
210 count = self.stripcount
211 while count > 0:
212 c = path.find('/')
213 if c == -1:
214 break
215 path = path[c + 1:]
216 count -= 1
217 return path
218
198 def sendrpc(self, msg):
219 def sendrpc(self, msg):
199 srv = xmlrpclib.Server(self.ciaurl)
220 srv = xmlrpclib.Server(self.ciaurl)
200 res = srv.hub.deliver(msg)
221 res = srv.hub.deliver(msg)
@@ -7,6 +7,9 b' Test the CIA extension'
7 > [hooks]
7 > [hooks]
8 > changegroup.cia = python:hgext.hgcia.hook
8 > changegroup.cia = python:hgext.hgcia.hook
9 >
9 >
10 > [web]
11 > baseurl = http://hgserver/
12 >
10 > [cia]
13 > [cia]
11 > user = testuser
14 > user = testuser
12 > project = testproject
15 > project = testproject
@@ -43,8 +46,8 b' Test the CIA extension'
43 <author>test</author>
46 <author>test</author>
44 <version>0:e63c23eaa88a</version>
47 <version>0:e63c23eaa88a</version>
45 <log>foo</log>
48 <log>foo</log>
46
49 <url>http://hgserver/$TESTTMP/cia/rev/e63c23eaa88a</url>
47 <files><file action="add">foo</file></files>
50 <files><file uri="http://hgserver/$TESTTMP/cia/file/e63c23eaa88a/foo" action="add">foo</file></files>
48 </commit>
51 </commit>
49 </body>
52 </body>
50 <timestamp>0</timestamp>
53 <timestamp>0</timestamp>
General Comments 0
You need to be logged in to leave comments. Login now