Merge with crew.
authorThomas Arendsen Hein <thomas@intevation.de>
Fri, 30 Jun 2006 22:09:43 +0200
changeset 2545 cff57cb5631e
parent 2544 0ab63318bc36 (diff)
parent 2525 c49dc6f38a19 (current diff)
child 2546 8cb894370514
Merge with crew.
--- a/Makefile
+++ b/Makefile
@@ -37,12 +37,20 @@ clean:
 	rm -f MANIFEST mercurial/__version__.py mercurial/*.so tests/*.err
 	$(MAKE) -C doc clean
 
-install: all
+install: install-bin install-doc
+
+install-bin: build
 	$(PYTHON) setup.py install --prefix="$(PREFIX)" --force
+
+install-doc: doc
 	cd doc && $(MAKE) $(MFLAGS) install
 
-install-home: all
+install-home: install-home-bin install-home-doc
+
+install-home-bin: build
 	$(PYTHON) setup.py install --home="$(HOME)" --force
+
+install-home-doc: doc
 	cd doc && $(MAKE) $(MFLAGS) PREFIX="$(HOME)" install
 
 dist:	tests dist-notests
@@ -57,5 +65,5 @@ test-%:
 	cd tests && $(PYTHON) run-tests.py $@
 
 
-.PHONY: help all local build doc clean install install-home dist dist-notests tests
-
+.PHONY: help all local build doc clean install install-bin install-doc \
+	install-home install-home-bin install-home-doc dist dist-notests tests
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1083,6 +1083,7 @@ def init(ui, repo, **opts):
     return 0
 
 def commit(ui, repo, *pats, **opts):
+    """commit changes in the queue repository"""
     q = repomap[repo]
     r = q.qrepo()
     if not r: raise util.Abort('no queue repository')
@@ -1264,7 +1265,7 @@ cmdtable = {
          'hg qimport [-e] [-n NAME] [-f] FILE...'),
     "^qinit":
         (init,
-         [('c', 'create-repo', None, 'create patch repository')],
+         [('c', 'create-repo', None, 'create queue repository')],
          'hg qinit [-c]'),
     "qnew":
         (new,
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -38,7 +38,7 @@ static uint32_t htonl(uint32_t x)
 #else
 #include <sys/types.h>
 #include <arpa/inet.h>
-#include <stdint.h>
+#include <inttypes.h>
 #endif
 
 struct line {
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3034,7 +3034,7 @@ table = {
           ('', 'remotecmd', '',
            _('specify hg command to run on the remote side'))],
          _('hg incoming [-p] [-n] [-M] [-r REV]...'
-           '[--bundle FILENAME] [SOURCE]')),
+           ' [--bundle FILENAME] [SOURCE]')),
     "^init": (init, [], _('hg init [DEST]')),
     "locate":
         (locate,
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -650,13 +650,28 @@ class hgweb(object):
             raise Exception("suspicious path")
         return p
 
-    def run(self, req):
+    def run(self):
+        if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."):
+            raise RuntimeError("This function is only intended to be called while running as a CGI script.")
+        import mercurial.hgweb.wsgicgi as wsgicgi
+        from request import wsgiapplication
+        def make_web_app():
+            return self
+        wsgicgi.launch(wsgiapplication(make_web_app))
+
+    def run_wsgi(self, req):
         def header(**map):
             header_file = cStringIO.StringIO(''.join(self.t("header", **map)))
             msg = mimetools.Message(header_file, 0)
             req.header(msg.items())
             yield header_file.read()
 
+        def rawfileheader(**map):
+            req.header([('Content-type', map['mimetype']),
+                        ('Content-disposition', 'filename=%s' % map['file']),
+                        ('Content-length', str(len(map['raw'])))])
+            yield ''
+
         def footer(**map):
             yield self.t("footer",
                          motd=self.repo.ui.config("web", "motd", ""),
@@ -714,6 +729,7 @@ class hgweb(object):
                                                "repo": self.reponame,
                                                "header": header,
                                                "footer": footer,
+                                               "rawfileheader": rawfileheader,
                                                })
 
         if not req.form.has_key('cmd'):
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -46,7 +46,16 @@ class hgwebdir(object):
                         self.repos.append((name.lstrip(os.sep), repo))
             self.repos.sort()
 
-    def run(self, req):
+    def run(self):
+        if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."):
+            raise RuntimeError("This function is only intended to be called while running as a CGI script.")
+        import mercurial.hgweb.wsgicgi as wsgicgi
+        from request import wsgiapplication
+        def make_web_app():
+            return self
+        wsgicgi.launch(wsgiapplication(make_web_app))
+
+    def run_wsgi(self, req):
         def header(**map):
             header_file = cStringIO.StringIO(''.join(tmpl("header", **map)))
             msg = mimetools.Message(header_file, 0)
@@ -124,7 +133,7 @@ class hgwebdir(object):
             real = dict(self.repos).get(virtual)
             if real:
                 try:
-                    hgweb(real).run(req)
+                    hgweb(real).run_wsgi(req)
                 except IOError, inst:
                     req.write(tmpl("error", error=inst.strerror))
                 except hg.RepoError, inst:
--- a/mercurial/hgweb/request.py
+++ b/mercurial/hgweb/request.py
@@ -48,7 +48,7 @@ class _wsgirequest(object):
         self.form = cgi.parse(self.inp, self.env, keep_blank_values=1)
         self.start_response = start_response
         self.headers = []
-        destination.run(self)
+        destination.run_wsgi(self)
 
     def __iter__(self):
         return iter([])
--- a/mercurial/mpatch.c
+++ b/mercurial/mpatch.c
@@ -43,7 +43,7 @@ static uint32_t ntohl(uint32_t x)
 /* not windows */
 # include <sys/types.h>
 # include <arpa/inet.h>
-# include <stdint.h>
+# include <inttypes.h>
 #endif
 
 static char mpatch_doc[] = "Efficient binary patching.";
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -202,7 +202,7 @@ def fill(text, width):
     if para_re is None:
         para_re = re.compile('(\n\n|\n\\s*[-*]\\s*)', re.M)
         space_re = re.compile(r'  +')
-        
+
     def findparas():
         start = 0
         while True:
--- a/templates/map-raw
+++ b/templates/map-raw
@@ -8,7 +8,7 @@ diffline = '#line#'
 changesetparent = '# Parent #node#'
 changesetchild = '# Child #node#'
 filenodelink = ''
-filerevision = 'Content-Type: #mimetype#\nContent-Disposition: filename=#file#\n\n#raw#'
+filerevision = '#rawfileheader##raw#'
 fileline = '#line#'
 diffblock = '#lines#'
 filediff = filediff-raw.tmpl
new file mode 100755
--- /dev/null
+++ b/tests/get-with-headers.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+__doc__ = """This does HTTP get requests given a host:port and path and returns
+a subset of the headers plus the body of the result."""
+
+import httplib, sys
+headers = [h.lower() for h in sys.argv[3:]]
+conn = httplib.HTTPConnection(sys.argv[1])
+conn.request("GET", sys.argv[2])
+response = conn.getresponse()
+print response.status, response.reason
+for h in headers:
+    if response.getheader(h, None) is not None:
+        print "%s: %s" % (h, response.getheader(h))
+print
+sys.stdout.write(response.read())
--- a/tests/test-globalopts
+++ b/tests/test-globalopts
@@ -62,7 +62,7 @@ echo %% --time
 hg --cwd a --time tip 2>&1 | grep '^Time:' | sed 's/[0-9][0-9]*/x/g'
 
 echo %% --version
-hg --version -q | sed 's/version \([a-f0-9+]*\|unknown\)/version xxx/'
+hg --version -q | sed 's/version [^)]*/version xxx/'
 
 echo %% -h/--help
 hg -h
--- a/tests/test-http-proxy
+++ b/tests/test-http-proxy
@@ -26,5 +26,5 @@ http_proxy=http://user:passwd@localhost:
 echo %% bad host:port for proxy
 http_proxy=localhost:20061 hg clone --config http_proxy.always=True http://localhost:20059/ f
 
-kill $(cat proxy.pid a/hg.pid)
+kill `cat proxy.pid a/hg.pid`
 exit 0
--- a/tests/test-hup
+++ b/tests/test-hup
@@ -7,7 +7,7 @@ hg serve --stdio < p &
 P=$!
 (echo lock; echo addchangegroup; sleep 5) > p &
 Q=$!
-sleep 1
+sleep 3
 kill -HUP $P
 wait
 ls .hg
new file mode 100755
--- /dev/null
+++ b/tests/test-oldcgi
@@ -0,0 +1,100 @@
+#!/bin/sh
+
+hg init test
+
+cat >hgweb.cgi <<HGWEB
+#!/usr/bin/env python
+#
+# An example CGI script to use hgweb, edit as necessary
+
+import cgitb, os, sys
+cgitb.enable()
+
+# sys.path.insert(0, "/path/to/python/lib") # if not a system-wide install
+from mercurial import hgweb
+
+h = hgweb.hgweb("test", "Empty test repository")
+h.run()
+HGWEB
+chmod 755 hgweb.cgi
+
+cat >hgweb.config <<HGWEBDIRCONF
+[paths]
+test = test
+HGWEBDIRCONF
+
+cat >hgwebdir.cgi <<HGWEBDIR
+#!/usr/bin/env python
+#
+# An example CGI script to export multiple hgweb repos, edit as necessary
+
+import cgitb, sys
+cgitb.enable()
+
+# sys.path.insert(0, "/path/to/python/lib") # if not a system-wide install
+from mercurial import hgweb
+
+# The config file looks like this.  You can have paths to individual
+# repos, collections of repos in a directory tree, or both.
+#
+# [paths]
+# virtual/path = /real/path
+# virtual/path = /real/path
+#
+# [collections]
+# /prefix/to/strip/off = /root/of/tree/full/of/repos
+#
+# collections example: say directory tree /foo contains repos /foo/bar,
+# /foo/quux/baz.  Give this config section:
+#   [collections]
+#   /foo = /foo
+# Then repos will list as bar and quux/baz.
+
+# Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
+# or use a dictionary with entries like 'virtual/path': '/real/path'
+
+h = hgweb.hgwebdir("hgweb.config")
+h.run()
+HGWEBDIR
+chmod 755 hgwebdir.cgi
+
+DOCUMENT_ROOT="/var/www/hg"; export DOCUMENT_ROOT
+GATEWAY_INTERFACE="CGI/1.1"; export GATEWAY_INTERFACE
+HTTP_ACCEPT="text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; export HTTP_ACCEPT
+HTTP_ACCEPT_CHARSET="ISO-8859-1,utf-8;q=0.7,*;q=0.7"; export HTTP_ACCEPT_CHARSET
+HTTP_ACCEPT_ENCODING="gzip,deflate"; export HTTP_ACCEPT_ENCODING
+HTTP_ACCEPT_LANGUAGE="en-us,en;q=0.5"; export HTTP_ACCEPT_LANGUAGE
+HTTP_CACHE_CONTROL="max-age=0"; export HTTP_CACHE_CONTROL
+HTTP_CONNECTION="keep-alive"; export HTTP_CONNECTION
+HTTP_HOST="hg.omnifarious.org"; export HTTP_HOST
+HTTP_KEEP_ALIVE="300"; export HTTP_KEEP_ALIVE
+HTTP_USER_AGENT="Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.4) Gecko/20060608 Ubuntu/dapper-security Firefox/1.5.0.4"; export HTTP_USER_AGENT
+PATH_INFO="/"; export PATH_INFO
+PATH_TRANSLATED="/var/www/hg/index.html"; export PATH_TRANSLATED
+QUERY_STRING=""; export QUERY_STRING
+REMOTE_ADDR="127.0.0.2"; export REMOTE_ADDR
+REMOTE_PORT="44703"; export REMOTE_PORT
+REQUEST_METHOD="GET"; export REQUEST_METHOD
+REQUEST_URI="/test/"; export REQUEST_URI
+SCRIPT_FILENAME="/home/hopper/hg_public/test.cgi"; export SCRIPT_FILENAME
+SCRIPT_NAME="/test"; export SCRIPT_NAME
+SCRIPT_URI="http://hg.omnifarious.org/test/"; export SCRIPT_URI
+SCRIPT_URL="/test/"; export SCRIPT_URL
+SERVER_ADDR="127.0.0.1"; export SERVER_ADDR
+SERVER_ADMIN="eric@localhost"; export SERVER_ADMIN
+SERVER_NAME="hg.omnifarious.org"; export SERVER_NAME
+SERVER_PORT="80"; export SERVER_PORT
+SERVER_PROTOCOL="HTTP/1.1"; export SERVER_PROTOCOL
+SERVER_SIGNATURE="<address>Apache/2.0.53 (Fedora) Server at hg.omnifarious.org Port 80</address>\; export SERVER_SIGNATURE
+"
+SERVER_SOFTWARE="Apache/2.0.53 (Fedora)"; export SERVER_SOFTWARE
+./hgweb.cgi >page1 2>&1 ; echo $?
+./hgwebdir.cgi >page2 2>&1 ; echo $?
+PATH_INFO="/test/"
+PATH_TRANSLATED="/var/something/test.cgi"
+REQUEST_URI="/test/test/"
+SCRIPT_URI="http://hg.omnifarious.org/test/test/"
+SCRIPT_URL="/test/test/"
+./hgwebdir.cgi >page3 2>&1 ; echo $?
+fgrep -i error page1 page2 page3 && exit 1
+exit 0
new file mode 100644
--- /dev/null
+++ b/tests/test-oldcgi.out
@@ -0,0 +1,3 @@
+0
+0
+0
--- a/tests/test-pull-pull-corruption2
+++ b/tests/test-pull-pull-corruption2
@@ -20,5 +20,6 @@ hg -R version2 pull source1 &
 sleep 1
 
 hg clone --pull -U version2 corrupted
+wait
 hg -R corrupted verify
 hg -R version2 verify
new file mode 100755
--- /dev/null
+++ b/tests/test-webraw
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+hg init test
+cd test
+cat >sometext.txt <<ENDSOME
+This is just some random text
+that will go inside the file and take a few lines.
+It is very boring to read, but computers don't
+care about things like that.
+ENDSOME
+hg add sometext.txt
+hg commit -d "1 0" -m "Just some text"
+hg serve -p 20059 -A access.log -E error.log -d --pid-file=hg.pid
+("$TESTDIR/get-with-headers.py" localhost:20059 '/?f=f165dc289438;file=sometext.txt;style=raw' content-type content-length content-disposition) >getoutput.txt &
+
+sleep 5
+kill `cat hg.pid`
+sleep 1 # wait for server to scream and die
+cat getoutput.txt
+cat access.log error.log | sed 's/^\([^[]*\[\)[^]]*\(\].*\)$/\1date\2/g'
new file mode 100644
--- /dev/null
+++ b/tests/test-webraw.out
@@ -0,0 +1,10 @@
+200 Script output follows
+content-type: text/plain
+content-length: 157
+content-disposition: filename=sometext.txt
+
+This is just some random text
+that will go inside the file and take a few lines.
+It is very boring to read, but computers don't
+care about things like that.
+localhost - - [date] "GET /?f=f165dc289438;file=sometext.txt;style=raw HTTP/1.1" 200 -