Patch draft

Edouard Gomez ed.gomez at free.fr
Fri May 11 22:51:24 UTC 2007


# HG changeset patch
# User Edouard Gomez <ed.gomez at free.fr>
# Date 1178923290 -7200
# Node ID 29ebe8220d361d48e712f9ec17c9ac9b50e32fab
# Parent  ba22e867cb23fb11f83c37705743e050afd66a6a
Fix inconsistency for the stream_out capability in hgweb

During some experiments of mine, the uncompressed cloning could not
be enabled for hgweb.cgi nor hgwebdir.cgi though the server claimed
to be stream_out capable.

The only solution was to enable it using the user's .hgrc file.
This solution is not acceptable when publishing the repos through
an HTTP server because the CGI runs as a www dedicated user whose's
home hgrc file may not be accessible to users publishing their repos
through their userdir.

For such cases we could end up with this typical debug output:
hg --debug clone --uncompressed http://server/hg/project
destination directory: project
sending capabilities command
capabilities: lookup changegroupsubset stream=1
unbundle=HG10GZ,HG10BZ,HG10UN
sending stream_out command
abort: operation forbidden by server

The error lies in the fact the hgweb object defines new accessors
to the repo configuration that trust things by default (untrusted=True)
but the streamclone:stream_out function uses the usual accessors to the
repo.ui object, which do not trust by default (untrusted=False)

Fix this inconsistency, adding a new parameter to the stream_out function.
hgweb then forces a "trust by default" behavior.

diff -r ba22e867cb23 -r 29ebe8220d36 mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Mon May 07 21:44:11 2007 +0900
+++ b/mercurial/hgweb/hgweb_mod.py	Sat May 12 00:41:30 2007 +0200
@@ -1170,4 +1170,4 @@ class hgweb(object):
 
     def do_stream_out(self, req):
         req.httphdr("application/mercurial-0.1")
-        streamclone.stream_out(self.repo, req)
+        streamclone.stream_out(self.repo, req, untrusted=True)
diff -r ba22e867cb23 -r 29ebe8220d36 mercurial/streamclone.py
--- a/mercurial/streamclone.py	Mon May 07 21:44:11 2007 +0900
+++ b/mercurial/streamclone.py	Sat May 12 00:41:30 2007 +0200
@@ -56,11 +56,11 @@ def walkrepo(root):
 #
 #   server writes out raw file data.
 
-def stream_out(repo, fileobj):
+def stream_out(repo, fileobj, untrusted=False):
     '''stream out all metadata files in repository.
     writes to file-like object, must support write() and optional flush().'''
 
-    if not repo.ui.configbool('server', 'uncompressed'):
+    if not repo.ui.configbool('server', 'uncompressed', untrusted=untrusted):
         fileobj.write('1\n')
         return
 

-- 
Edouard Gomez




More information about the Mercurial-devel mailing list