hg: hgwebfs extension, ignore /net.alt
This commit is contained in:
parent
7064a591ff
commit
51f8743f76
2 changed files with 75 additions and 1 deletions
|
@ -6,7 +6,7 @@ syntax: regexp
|
||||||
^sys/lib/python/.*\.(pyo|pyc|exe)$
|
^sys/lib/python/.*\.(pyo|pyc|exe)$
|
||||||
^sys/log/
|
^sys/log/
|
||||||
^sys/man/(searchindex|[1-8]/INDEX.*)$
|
^sys/man/(searchindex|[1-8]/INDEX.*)$
|
||||||
^(dev|fd|net|srv|shr|env|root|boot|mnt|n|bin|usr|cfg|cron|mail|tmp)/
|
^(dev|fd|net.*|srv|shr|env|root|boot|mnt|n|bin|usr|cfg|cron|mail|tmp)/
|
||||||
^(386|68000|68020|alpha|amd64|arm|power|power64|sparc|sparc64)/(bin|lib)/
|
^(386|68000|68020|alpha|amd64|arm|power|power64|sparc|sparc64)/(bin|lib)/
|
||||||
^386/(9(pc|boot).*|pbs|mbr|init)
|
^386/(9(pc|boot).*|pbs|mbr|init)
|
||||||
^acme/bin/(386|68000|68020|alpha|amd64|arm|power|power64|sparc|sparc64)/
|
^acme/bin/(386|68000|68020|alpha|amd64|arm|power|power64|sparc|sparc64)/
|
||||||
|
|
74
sys/lib/python/hgext/hgwebfs.py
Normal file
74
sys/lib/python/hgext/hgwebfs.py
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
''' webfs support '''
|
||||||
|
|
||||||
|
import mercurial.url
|
||||||
|
import re
|
||||||
|
|
||||||
|
class Webconn:
|
||||||
|
def __init__(self, mnt, req):
|
||||||
|
ctl = open(mnt+'/clone', 'r+', 0)
|
||||||
|
try:
|
||||||
|
self.url = req.get_full_url()
|
||||||
|
self.dir = mnt+'/'+ctl.readline().rstrip('\n')
|
||||||
|
ctl.seek(0)
|
||||||
|
ctl.write('url '+self.url)
|
||||||
|
m = ''
|
||||||
|
for h,v in req.headers:
|
||||||
|
m += h+': '+v+'\r\n'
|
||||||
|
if len(m) > 0:
|
||||||
|
m = 'headers '+m
|
||||||
|
print m
|
||||||
|
ctl.seek(0)
|
||||||
|
ctl.write(m)
|
||||||
|
if req.has_data():
|
||||||
|
data = req.get_data()
|
||||||
|
post = open(self.dir+'/postdata', 'w', 0);
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
buf = data.read(4096)
|
||||||
|
if len(buf) == 0:
|
||||||
|
break
|
||||||
|
post.write(buf)
|
||||||
|
finally:
|
||||||
|
post.close()
|
||||||
|
self.body = open(self.dir+'/body', 'r', 0)
|
||||||
|
finally:
|
||||||
|
ctl.close()
|
||||||
|
|
||||||
|
def read(self, amt=4096):
|
||||||
|
return self.body.read(amt);
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.body.close()
|
||||||
|
self.body = None
|
||||||
|
self.dir = None
|
||||||
|
|
||||||
|
def geturl(self):
|
||||||
|
return self.url
|
||||||
|
|
||||||
|
def getheader(self, key):
|
||||||
|
name = re.sub(r'[^a-z]+', '', key.lower())
|
||||||
|
try:
|
||||||
|
f = open(self.dir+'/'+name, 'r', 0)
|
||||||
|
try:
|
||||||
|
hdr = f.read()
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
return hdr
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
class Webopener:
|
||||||
|
def __init__(self):
|
||||||
|
self.handlers = []
|
||||||
|
|
||||||
|
def open(self, req, data=None):
|
||||||
|
return Webconn('/mnt/web', req)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def webopener(ui, authinfo=None):
|
||||||
|
return Webopener();
|
||||||
|
|
||||||
|
mercurial.url.opener = webopener
|
Loading…
Add table
Add a link
Reference in a new issue