Show More
@@ -92,7 +92,7 b' class hgweb(object):' | |||||
92 | if cmd in perms and not self.check_perm(req, perms[cmd]): |
|
92 | if cmd in perms and not self.check_perm(req, perms[cmd]): | |
93 | return |
|
93 | return | |
94 | method = getattr(protocol, cmd) |
|
94 | method = getattr(protocol, cmd) | |
95 | method(self, req) |
|
95 | method(self.repo, req) | |
96 | return |
|
96 | return | |
97 |
|
97 | |||
98 | # work with CGI variables to create coherent structure |
|
98 | # work with CGI variables to create coherent structure |
@@ -21,9 +21,9 b' from common import HTTP_OK, HTTP_NOT_FOU' | |||||
21 |
|
21 | |||
22 | HGTYPE = 'application/mercurial-0.1' |
|
22 | HGTYPE = 'application/mercurial-0.1' | |
23 |
|
23 | |||
24 |
def lookup( |
|
24 | def lookup(repo, req): | |
25 | try: |
|
25 | try: | |
26 |
r = hex( |
|
26 | r = hex(repo.lookup(req.form['key'][0])) | |
27 | success = 1 |
|
27 | success = 1 | |
28 | except Exception,inst: |
|
28 | except Exception,inst: | |
29 | r = str(inst) |
|
29 | r = str(inst) | |
@@ -32,34 +32,34 b' def lookup(web, req):' | |||||
32 | req.respond(HTTP_OK, HGTYPE, length=len(resp)) |
|
32 | req.respond(HTTP_OK, HGTYPE, length=len(resp)) | |
33 | req.write(resp) |
|
33 | req.write(resp) | |
34 |
|
34 | |||
35 |
def heads( |
|
35 | def heads(repo, req): | |
36 |
resp = " ".join(map(hex, |
|
36 | resp = " ".join(map(hex, repo.heads())) + "\n" | |
37 | req.respond(HTTP_OK, HGTYPE, length=len(resp)) |
|
37 | req.respond(HTTP_OK, HGTYPE, length=len(resp)) | |
38 | req.write(resp) |
|
38 | req.write(resp) | |
39 |
|
39 | |||
40 |
def branches( |
|
40 | def branches(repo, req): | |
41 | nodes = [] |
|
41 | nodes = [] | |
42 | if 'nodes' in req.form: |
|
42 | if 'nodes' in req.form: | |
43 | nodes = map(bin, req.form['nodes'][0].split(" ")) |
|
43 | nodes = map(bin, req.form['nodes'][0].split(" ")) | |
44 | resp = cStringIO.StringIO() |
|
44 | resp = cStringIO.StringIO() | |
45 |
for b in |
|
45 | for b in repo.branches(nodes): | |
46 | resp.write(" ".join(map(hex, b)) + "\n") |
|
46 | resp.write(" ".join(map(hex, b)) + "\n") | |
47 | resp = resp.getvalue() |
|
47 | resp = resp.getvalue() | |
48 | req.respond(HTTP_OK, HGTYPE, length=len(resp)) |
|
48 | req.respond(HTTP_OK, HGTYPE, length=len(resp)) | |
49 | req.write(resp) |
|
49 | req.write(resp) | |
50 |
|
50 | |||
51 |
def between( |
|
51 | def between(repo, req): | |
52 | if 'pairs' in req.form: |
|
52 | if 'pairs' in req.form: | |
53 | pairs = [map(bin, p.split("-")) |
|
53 | pairs = [map(bin, p.split("-")) | |
54 | for p in req.form['pairs'][0].split(" ")] |
|
54 | for p in req.form['pairs'][0].split(" ")] | |
55 | resp = cStringIO.StringIO() |
|
55 | resp = cStringIO.StringIO() | |
56 |
for b in |
|
56 | for b in repo.between(pairs): | |
57 | resp.write(" ".join(map(hex, b)) + "\n") |
|
57 | resp.write(" ".join(map(hex, b)) + "\n") | |
58 | resp = resp.getvalue() |
|
58 | resp = resp.getvalue() | |
59 | req.respond(HTTP_OK, HGTYPE, length=len(resp)) |
|
59 | req.respond(HTTP_OK, HGTYPE, length=len(resp)) | |
60 | req.write(resp) |
|
60 | req.write(resp) | |
61 |
|
61 | |||
62 |
def changegroup( |
|
62 | def changegroup(repo, req): | |
63 | req.respond(HTTP_OK, HGTYPE) |
|
63 | req.respond(HTTP_OK, HGTYPE) | |
64 | nodes = [] |
|
64 | nodes = [] | |
65 |
|
65 | |||
@@ -67,7 +67,7 b' def changegroup(web, req):' | |||||
67 | nodes = map(bin, req.form['roots'][0].split(" ")) |
|
67 | nodes = map(bin, req.form['roots'][0].split(" ")) | |
68 |
|
68 | |||
69 | z = zlib.compressobj() |
|
69 | z = zlib.compressobj() | |
70 |
f = |
|
70 | f = repo.changegroup(nodes, 'serve') | |
71 | while 1: |
|
71 | while 1: | |
72 | chunk = f.read(4096) |
|
72 | chunk = f.read(4096) | |
73 | if not chunk: |
|
73 | if not chunk: | |
@@ -76,7 +76,7 b' def changegroup(web, req):' | |||||
76 |
|
76 | |||
77 | req.write(z.flush()) |
|
77 | req.write(z.flush()) | |
78 |
|
78 | |||
79 |
def changegroupsubset( |
|
79 | def changegroupsubset(repo, req): | |
80 | req.respond(HTTP_OK, HGTYPE) |
|
80 | req.respond(HTTP_OK, HGTYPE) | |
81 | bases = [] |
|
81 | bases = [] | |
82 | heads = [] |
|
82 | heads = [] | |
@@ -87,7 +87,7 b' def changegroupsubset(web, req):' | |||||
87 | heads = [bin(x) for x in req.form['heads'][0].split(' ')] |
|
87 | heads = [bin(x) for x in req.form['heads'][0].split(' ')] | |
88 |
|
88 | |||
89 | z = zlib.compressobj() |
|
89 | z = zlib.compressobj() | |
90 |
f = |
|
90 | f = repo.changegroupsubset(bases, heads, 'serve') | |
91 | while 1: |
|
91 | while 1: | |
92 | chunk = f.read(4096) |
|
92 | chunk = f.read(4096) | |
93 | if not chunk: |
|
93 | if not chunk: | |
@@ -96,17 +96,17 b' def changegroupsubset(web, req):' | |||||
96 |
|
96 | |||
97 | req.write(z.flush()) |
|
97 | req.write(z.flush()) | |
98 |
|
98 | |||
99 |
def capabilities( |
|
99 | def capabilities(repo, req): | |
100 | caps = ['lookup', 'changegroupsubset'] |
|
100 | caps = ['lookup', 'changegroupsubset'] | |
101 |
if |
|
101 | if repo.ui.configbool('server', 'uncompressed', untrusted=True): | |
102 |
caps.append('stream=%d' % |
|
102 | caps.append('stream=%d' % repo.changelog.version) | |
103 | if changegroupmod.bundlepriority: |
|
103 | if changegroupmod.bundlepriority: | |
104 | caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority)) |
|
104 | caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority)) | |
105 | rsp = ' '.join(caps) |
|
105 | rsp = ' '.join(caps) | |
106 | req.respond(HTTP_OK, HGTYPE, length=len(rsp)) |
|
106 | req.respond(HTTP_OK, HGTYPE, length=len(rsp)) | |
107 | req.write(rsp) |
|
107 | req.write(rsp) | |
108 |
|
108 | |||
109 |
def unbundle( |
|
109 | def unbundle(repo, req): | |
110 |
|
110 | |||
111 | def bail(response, headers={}): |
|
111 | def bail(response, headers={}): | |
112 | length = int(req.env.get('CONTENT_LENGTH', 0)) |
|
112 | length = int(req.env.get('CONTENT_LENGTH', 0)) | |
@@ -125,7 +125,7 b' def unbundle(web, req):' | |||||
125 | their_heads = req.form['heads'][0].split(' ') |
|
125 | their_heads = req.form['heads'][0].split(' ') | |
126 |
|
126 | |||
127 | def check_heads(): |
|
127 | def check_heads(): | |
128 |
heads = map(hex, |
|
128 | heads = map(hex, repo.heads()) | |
129 | return their_heads == [hex('force')] or their_heads == heads |
|
129 | return their_heads == [hex('force')] or their_heads == heads | |
130 |
|
130 | |||
131 | # fail early if possible |
|
131 | # fail early if possible | |
@@ -146,7 +146,7 b' def unbundle(web, req):' | |||||
146 | fp.write(s) |
|
146 | fp.write(s) | |
147 |
|
147 | |||
148 | try: |
|
148 | try: | |
149 |
lock = |
|
149 | lock = repo.lock() | |
150 | try: |
|
150 | try: | |
151 | if not check_heads(): |
|
151 | if not check_heads(): | |
152 | req.write('0\n') |
|
152 | req.write('0\n') | |
@@ -170,7 +170,7 b' def unbundle(web, req):' | |||||
170 | url = 'remote:%s:%s' % (proto, |
|
170 | url = 'remote:%s:%s' % (proto, | |
171 | req.env.get('REMOTE_HOST', '')) |
|
171 | req.env.get('REMOTE_HOST', '')) | |
172 | try: |
|
172 | try: | |
173 |
ret = |
|
173 | ret = repo.addchangegroup(gen, 'serve', url) | |
174 | except util.Abort, inst: |
|
174 | except util.Abort, inst: | |
175 | sys.stdout.write("abort: %s\n" % inst) |
|
175 | sys.stdout.write("abort: %s\n" % inst) | |
176 | ret = 0 |
|
176 | ret = 0 | |
@@ -188,8 +188,8 b' def unbundle(web, req):' | |||||
188 | req.write('0\n') |
|
188 | req.write('0\n') | |
189 | filename = getattr(inst, 'filename', '') |
|
189 | filename = getattr(inst, 'filename', '') | |
190 | # Don't send our filesystem layout to the client |
|
190 | # Don't send our filesystem layout to the client | |
191 |
if filename.startswith( |
|
191 | if filename.startswith(repo.root): | |
192 |
filename = filename[len( |
|
192 | filename = filename[len(repo.root)+1:] | |
193 | else: |
|
193 | else: | |
194 | filename = '' |
|
194 | filename = '' | |
195 | error = getattr(inst, 'strerror', 'Unknown error') |
|
195 | error = getattr(inst, 'strerror', 'Unknown error') | |
@@ -203,6 +203,6 b' def unbundle(web, req):' | |||||
203 | fp.close() |
|
203 | fp.close() | |
204 | os.unlink(tempname) |
|
204 | os.unlink(tempname) | |
205 |
|
205 | |||
206 |
def stream_out( |
|
206 | def stream_out(repo, req): | |
207 | req.respond(HTTP_OK, HGTYPE) |
|
207 | req.respond(HTTP_OK, HGTYPE) | |
208 |
streamclone.stream_out( |
|
208 | streamclone.stream_out(repo, req, untrusted=True) |
General Comments 0
You need to be logged in to leave comments.
Login now