hgweb.cgi
author Matt Harbison <matt_harbison@yahoo.com>
Tue, 07 Apr 2015 22:31:36 -0400
changeset 24653 83f6c4733ecc
parent 15475 85cba926cb59
child 26421 4b0fc75f9403
permissions -rwxr-xr-x
windows: allow readpipe() to actually read data out of the pipe It appears that the read() in readpipe() never actually ran before (in test-ssh.t anyway). A print of the size returned from os.fstat() is 0 for every single print output in test-ssh.t, so the data in the pipe ends up being read later instead of when it is available. This is the same problem as Linux, as mentioned in 331cbf088c4c. There are several places in the Windows SSH tests where the order of local output vs remote output differ from the other platforms. This only fixes one of those cases (and interstingly, not the one added in order to test 331cbf088c4c), so there is more investigation needed. However, without this patch, test-ssh.t also has this diff: --- c:/Users/Matt/Projects/hg/tests/test-ssh.t +++ c:/Users/Matt/Projects/hg/tests/test-ssh.t.err @@ -397,11 +397,11 @@ $ hg push --ssh "sh ../ssh.sh" pushing to ssh://user@dummy/*/remote (glob) searching for changes - remote: Permission denied - remote: abort: prechangegroup.hg-ssh hook failed - remote: Permission denied - remote: pushkey-abort: prepushkey.hg-ssh hook failed updating 6c0482d977a3 to public failed! + remote: Permission denied + remote: abort: prechangegroup.hg-ssh hook failed + remote: Permission denied + remote: pushkey-abort: prepushkey.hg-ssh hook failed [1] $ cd .. Output with this change was stable over 600+ runs of test-ssh.t. I initially tried a background thread to read the pipe[1], but this was simpler and the test results were exactly the same. I also tried SetNamedPipeHandleState(), but the PIPE_NOWAIT is for compatibility with LANMAN 2.0, not for async I/O (the results were identical though). [1] http://eyalarubas.com/python-subproc-nonblock.html
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
202
e875a0cf7f3a Call python via env in hgweb.cgi
mpm@selenic.com
parents: 159
diff changeset
     1
#!/usr/bin/env python
159
f9d8620ef469 Add example CGI script
mpm@selenic.com
parents:
diff changeset
     2
#
11000
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
     3
# An example hgweb CGI script, edit as necessary
11503
227b9f13db13 hgweb: add link to wiki
Martin Geisler <mg@lazybytes.net>
parents: 11000
diff changeset
     4
# See also http://mercurial.selenic.com/wiki/PublishingRepositories
159
f9d8620ef469 Add example CGI script
mpm@selenic.com
parents:
diff changeset
     5
11000
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
     6
# Path to repo or hgweb config to serve (see 'hg help hgweb')
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
     7
config = "/path/to/repo/or/config"
5244
79279b5583c6 cgi: sys.path.insert should be before importing mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5197
diff changeset
     8
15475
85cba926cb59 hgweb: add hint about finding library path with debuginstall
Matt Mackall <mpm@selenic.com>
parents: 11503
diff changeset
     9
# Uncomment and adjust if Mercurial is not installed system-wide
85cba926cb59 hgweb: add hint about finding library path with debuginstall
Matt Mackall <mpm@selenic.com>
parents: 11503
diff changeset
    10
# (consult "installed modules" path from 'hg debuginstall'):
11000
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
    11
#import sys; sys.path.insert(0, "/path/to/python/lib")
5197
55860a45bbf2 Enable demandimport only in scripts, not in importable modules (issue605)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3868
diff changeset
    12
6080
4baad19c4801 hgweb: disable cgitb by default
Maxim Dounin <mdounin@mdounin.ru>
parents: 5995
diff changeset
    13
# Uncomment to send python tracebacks to the browser if an error occurs:
11000
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
    14
#import cgitb; cgitb.enable()
391
5f65a108a559 hgweb: pull cgitb into CGI script example, where it can easily be disabled
mpm@selenic.com
parents: 202
diff changeset
    15
11000
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
    16
from mercurial import demandimport; demandimport.enable()
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
    17
from mercurial.hgweb import hgweb, wsgicgi
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
    18
application = hgweb(config)
6141
90e5c82a3859 Backed out changeset b913d3aacddc (see issue971/msg5317)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5995
diff changeset
    19
wsgicgi.launch(application)