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