Mercurial > hg
changeset 1182:24d553b598e8
Merge with http://hannibal.lr-s.tudelft.nl/~vincent/fcgi/mercurial/fcgi/
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Wed, 31 Aug 2005 21:07:36 +0200 |
parents | 8acf62f579d8 (diff) 4f5001f5b4c3 (current diff) |
children | d9e85a75dbda 2ae9c319e6fe |
files | mercurial/hgweb.py |
diffstat | 13 files changed, 244 insertions(+), 73 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/mercurial.el Tue Aug 30 21:58:44 2005 +0200 +++ b/contrib/mercurial.el Wed Aug 31 21:07:36 2005 +0200 @@ -283,13 +283,13 @@ (replace-regexp-in-string regexp newtext str nil literal))) (defsubst hg-strip (str) - "Strip leading and trailing white space from a string." - (hg-replace-in-string (hg-replace-in-string str "[ \t\r\n]+$" "") - "^[ \t\r\n]+" "")) + "Strip leading and trailing blank lines from a string." + (hg-replace-in-string (hg-replace-in-string str "[\r\n][ \t\r\n]*\\'" "") + "\\`[ \t\r\n]*[\r\n]" "")) (defsubst hg-chomp (str) "Strip trailing newlines from a string." - (hg-replace-in-string str "[\r\n]+$" "")) + (hg-replace-in-string str "[\r\n]+\'" "")) (defun hg-run-command (command &rest args) "Run the shell command COMMAND, returning (EXIT-CODE . COMMAND-OUTPUT). @@ -469,12 +469,11 @@ (set-buffer hg-prev-buffer)) (let ((rev (or default "tip"))) (if current-prefix-arg - (let ((revs (split-string (hg-chomp - (hg-run0 "-q" "log" "-r" - (format "-%d" - hg-rev-completion-limit) - "-r" "tip")) - "[\n:]"))) + (let ((revs (split-string + (hg-chomp + (hg-run0 "-q" "log" "-r" + (format "-%d:tip" hg-rev-completion-limit))) + "[\n:]"))) (dolist (line (split-string (hg-chomp (hg-run0 "tags")) "\n")) (setq revs (cons (car (split-string line "\\s-")) revs))) (completing-read (format "Revision%s (%s): " @@ -650,7 +649,7 @@ Help overview (what you are reading) G C-c h h hg-help-overview Tell Mercurial to manage a file G C-c h a hg-add -Commit changes to current file only L C-x v n hg-commit +Commit changes to current file only L C-x v n hg-commit-start Undo changes to file since commit L C-x v u hg-revert-buffer Diff file vs last checkin L C-x v = hg-diff @@ -660,10 +659,10 @@ Diff repo vs last checkin G C-c h = hg-diff-repo View status of files in repo G C-c h s hg-status -Commit all changes G C-c h c hg-commit +Commit all changes G C-c h c hg-commit-start Undo all changes since last commit G C-c h U hg-revert -View repo change history G C-c h l hg-log +View repo change history G C-c h l hg-log-repo See changes that can be pulled G C-c h , hg-incoming Pull changes G C-c h < hg-pull @@ -966,9 +965,10 @@ (format "Mercurial: Log of rev %s of %s" rev1 a-path) (format "Mercurial: Log from rev %s to %s of %s" r1 r2 a-path))) - (if (> (length path) (length (hg-root path))) - (call-process (hg-binary) nil t nil "log" "-r" r1 "-r" r2 path) - (call-process (hg-binary) nil t nil "log" "-r" r1 "-r" r2)) + (let ((revs (format "%s:%s" r1 r2))) + (if (> (length path) (length (hg-root path))) + (call-process (hg-binary) nil t nil "log" "-r" revs path) + (call-process (hg-binary) nil t nil "log" "-r" revs))) (hg-log-mode)))) (defun hg-log-repo (path &optional rev1 rev2)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/tcsh_completion Wed Aug 31 21:07:36 2005 +0200 @@ -0,0 +1,40 @@ +# +# tcsh completion for Mercurial +# +# This file has been auto-generated by tcsh_completion_build.sh for +# Mercurial Distributed SCM (version a33a7a543803) +# +# Copyright (C) 2005 TK Soh. +# +# This is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# + +complete hg \ + 'n/--cwd/d/' 'n/-R/d/' 'n/--repository/d/' \ + 'C/-/( -R --repository \ + --cwd \ + -y --noninteractive \ + -q --quiet \ + -v --verbose \ + --debug \ + --traceback \ + --time \ + --profile \ + --version \ + -h --help)/' \ + 'p/1/(add addremove annotate cat clone \ + commit ci copy debugcheckstate debugconfig \ + debugdata debugindex debugindexdot debugrename debugstate \ + debugwalk diff export forget grep \ + heads help identify id import \ + patch incoming in init locate \ + log history manifest outgoing out \ + parents paths pull push rawcommit \ + recover remove rm revert root \ + serve status tag tags tip \ + undo update up checkout co \ + verify version)/' +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/tcsh_completion_build.sh Wed Aug 31 21:07:36 2005 +0200 @@ -0,0 +1,73 @@ +#!/bin/sh + +# +# tcsh_completion_build.sh - script to generate tcsh completion +# +# +# Copyright (C) 2005 TK Soh. +# +# This is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# +# Description +# ----------- +# This script generates a tcsh source file to support completion +# of Mercurial commands and options. +# +# Instruction: +# ----------- +# Run this script to generate the tcsh source file, and source +# the file to add command completion support for Mercurial. +# +# tcsh% tcsh_completion.sh FILE +# tcsh% source FILE +# +# If FILE is not specified, tcsh_completion will be generated. +# +# Bugs: +# ---- +# 1. command specific options are not supported +# 2. hg commands must be specified immediately after 'hg'. +# + +tcsh_file=${1-tcsh_completion} + +hg_commands=`hg --debug help | \ + sed -e '1,/^list of commands:/d' \ + -e '/^global options:/,$d' \ + -e '/^ [^ ]/!d; s/[,:]//g;' | \ + xargs -n5 | \ + sed -e '$!s/$/ \\\\/g; 2,$s/^ */ /g'` + +hg_global_options=`hg -v help | \ + sed -e '1,/global/d;/^ *-/!d; s/ [^- ].*//' | \ + sed -e 's/ *$//; $!s/$/ \\\\/g; 2,$s/^ */ /g'` + +hg_version=`hg version | sed -e '1q'` + +script_name=`basename $0` + +cat > $tcsh_file <<END +# +# tcsh completion for Mercurial +# +# This file has been auto-generated by $script_name for +# $hg_version +# +# Copyright (C) 2005 TK Soh. +# +# This is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# + +complete hg \\ + 'n/--cwd/d/' 'n/-R/d/' 'n/--repository/d/' \\ + 'C/-/($hg_global_options)/' \\ + 'p/1/($hg_commands)/' + +END
--- a/doc/hgrc.5.txt Tue Aug 30 21:58:44 2005 +0200 +++ b/doc/hgrc.5.txt Wed Aug 31 21:07:36 2005 +0200 @@ -64,14 +64,14 @@ hooks:: Commands that get automatically executed by various actions such as starting or finishing a commit. + changegroup;; + Run after a changegroup has been added via push or pull. + commit;; + Run after a changeset has been created. Passed the ID of the newly + created changeset. precommit;; Run before starting a commit. Exit status 0 allows the commit to proceed. Non-zero status will cause the commit to fail. - commit;; - Run after a changeset has been created. Passed the ID of the newly - created changeset. - changegroup;; - Run after a changegroup has been added via push or pull. http_proxy:: Used to access web-based Mercurial repositories through a HTTP @@ -79,13 +79,13 @@ host;; Host name and (optional) port of the proxy server, for example "myproxy:8000". - user;; - Optional. User name to authenticate with at the proxy server. - passwd;; - Optional. Password to authenticate with at the proxy server. no;; Optional. Comma-separated list of host names that should bypass the proxy. + passwd;; + Optional. Password to authenticate with at the proxy server. + user;; + Optional. User name to authenticate with at the proxy server. paths:: Assigns symbolic names to repositories. The left side is the @@ -105,50 +105,53 @@ Default is "hgmerge". quiet;; Reduce the amount of output printed. True or False. Default is False. + remotecmd;; + remote command to use for clone/push/pull operations. Default is 'hg'. + ssh;; + command to use for SSH connections. Default is 'ssh'. username;; The committer of a changeset created when running "commit". Typically a person's name and email address, e.g. "Fred Widget <fred@example.com>". Default is $EMAIL or username@hostname. verbose;; Increase the amount of output printed. True or False. Default is False. - ssh;; - command to use for SSH connections. Default is 'ssh'. - remotecmd;; - remote command to use for clone/push/pull operations. Default is 'hg'. web:: Web interface configuration. - name;; - Repository name to use in the web interface. Default is current - working directory. - address;; - Interface address to bind to. Default is all. - port;; - Port to listen on. Default is 8000. - ipv6;; - Whether to use IPv6. Default is false. accesslog;; Where to output the access log. Default is stdout. - errorlog;; - Where to output the error log. Default is stderr. - templates;; - Where to find the HTML templates. Default is install path. - style;; - Which template map style to use. - maxchanges;; - Maximum number of changes to list on the changelog. Default is 10. - maxfiles;; - Maximum number of files to list per changeset. Default is 10. + address;; + Interface address to bind to. Default is all. + allowbz2;; + Whether to allow .tar.bz2 downloading of repo revisions. Default is false. + allowgz;; + Whether to allow .tar.gz downloading of repo revisions. Default is false. allowpull;; Whether to allow pulling from the repository. Default is true. allowzip;; Whether to allow .zip downloading of repo revisions. Default is false. This feature creates temporary files. - allowgz;; - Whether to allow .tar.gz downloading of repo revisions. Default is false. - allowbz2;; - Whether to allow .tar.bz2 downloading of repo revisions. Default is false. + description;; + Textual description of the repository's purpose or contents. + Default is "unknown". + errorlog;; + Where to output the error log. Default is stderr. + ipv6;; + Whether to use IPv6. Default is false. + name;; + Repository name to use in the web interface. Default is current + working directory. + maxchanges;; + Maximum number of changes to list on the changelog. Default is 10. + maxfiles;; + Maximum number of files to list per changeset. Default is 10. + port;; + Port to listen on. Default is 8000. + style;; + Which template map style to use. + templates;; + Where to find the HTML templates. Default is install path. AUTHOR
--- a/mercurial/commands.py Tue Aug 30 21:58:44 2005 +0200 +++ b/mercurial/commands.py Wed Aug 31 21:07:36 2005 +0200 @@ -1386,7 +1386,10 @@ if opts[o]: ui.setconfig("web", o, opts[o]) - httpd = hgweb.create_server(repo) + try: + httpd = hgweb.create_server(repo) + except socket.error, inst: + raise util.Abort('cannot start server: ' + inst.args[1]) if ui.verbose: addr, port = httpd.socket.getsockname()
--- a/mercurial/hgweb.py Tue Aug 30 21:58:44 2005 +0200 +++ b/mercurial/hgweb.py Wed Aug 31 21:07:36 2005 +0200 @@ -6,7 +6,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, cgi, time, re, socket, sys, zlib +import os, cgi, time, re, socket, sys, zlib, errno import mdiff from hg import * from ui import * @@ -77,8 +77,8 @@ self.out.write(thing) except TypeError: self.out.write(str(thing)) - except socket.error, x: - if x[0] != errno.ECONNRESET: + except socket.error, inst: + if inst[0] != errno.ECONNRESET: raise def header(self, headers=[('Content-type','text/html')]): @@ -178,8 +178,7 @@ self.repo = repo self.mtime = -1 - self.reponame = name or self.repo.ui.config("web", "name", - self.repo.root) + self.reponame = name self.archives = 'zip', 'gz', 'bz2' def refresh(self): @@ -663,10 +662,10 @@ files.sort() if type == 'zip': - import zipfile + import zipfile, tempfile + tmp = tempfile.mkstemp()[1] try: - tmp = tempfile.mkstemp()[1] zf = zipfile.ZipFile(tmp, "w", zipfile.ZIP_DEFLATED) for f in files: @@ -730,6 +729,9 @@ if "?" in uri: uri = uri.split("?")[0] url = "http://%s%s%s" % (req.env["SERVER_NAME"], port, uri) + if not self.reponame: + self.reponame = (self.repo.ui.config("web", "name") + or uri.strip('/') or self.repo.root) self.t = templater(m, common_filters, {"url": url, @@ -867,7 +869,7 @@ try: self.do_hgweb() except socket.error, inst: - if inst.args[0] != 32: + if inst[0] != errno.EPIPE: raise def do_GET(self): @@ -956,7 +958,10 @@ parity = 0 for name, path in self.repos: u = ui() - u.readconfig(file(os.path.join(path, '.hg', 'hgrc'))) + try: + u.readconfig(file(os.path.join(path, '.hg', 'hgrc'))) + except IOError: + pass get = u.config url = ('/'.join([req.env["REQUEST_URI"].split('?')[0], name])
--- a/mercurial/util.py Tue Aug 30 21:58:44 2005 +0200 +++ b/mercurial/util.py Wed Aug 31 21:07:36 2005 +0200 @@ -342,8 +342,6 @@ def explain_exit(code): """return a 2-tuple (desc, code) describing a process's status""" - if os.name == 'nt': # os.WIFxx is not supported on windows - return "aborted with error." , -1 if os.WIFEXITED(code): val = os.WEXITSTATUS(code) return "exited with status %d" % val, val
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-archive Wed Aug 31 21:07:36 2005 +0200 @@ -0,0 +1,37 @@ +#!/bin/sh + +mkdir test +cd test +hg init +echo foo>foo +hg addremove +hg commit -m 1 +echo bar>bar +hg addremove +hg commit -m 2 +mkdir baz +echo bletch>baz/bletch +hg addremove +hg commit -m 3 +echo "name = test-archive" >> .hg/hgrc +echo "allowzip = true" >> .hg/hgrc +echo "allowgz = true" >> .hg/hgrc +echo "allowbz2 = true" >> .hg/hgrc +hg serve -p 20059 > /dev/null & +sleep 1 # wait for server to be started + +TIP=`hg id -v | cut -f1 -d' '` +QTIP=`hg id -q` +cat > getarchive.py <<EOF +import sys, urllib2 +node, archive = sys.argv[1:] +f = urllib2.urlopen('http://127.0.0.1:20059/?cmd=archive;node=%s;type=%s' + % (node, archive)) +sys.stdout.write(f.read()) +EOF +http_proxy= python getarchive.py "$TIP" gz | tar tzf - | sed "s/$QTIP/TIP/" +http_proxy= python getarchive.py "$TIP" bz2 | tar tjf - | sed "s/$QTIP/TIP/" +http_proxy= python getarchive.py "$TIP" zip > archive.zip +unzip -t archive.zip | sed "s/$QTIP/TIP/" + +kill $!
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-archive.out Wed Aug 31 21:07:36 2005 +0200 @@ -0,0 +1,15 @@ +adding foo +adding bar +adding baz/bletch +test-archive-TIP/bar +test-archive-TIP/baz/bletch +test-archive-TIP/foo +test-archive-TIP/bar +test-archive-TIP/baz/bletch +test-archive-TIP/foo +Archive: archive.zip + testing: test-archive-TIP/bar OK + testing: test-archive-TIP/baz/bletch OK + testing: test-archive-TIP/foo OK +No errors detected in compressed data of archive.zip. +killed!
--- a/tests/test-copy2 Tue Aug 30 21:58:44 2005 +0200 +++ b/tests/test-copy2 Wed Aug 31 21:07:36 2005 +0200 @@ -8,11 +8,11 @@ echo "# should show copy" cp foo bar hg copy foo bar -hg debugstate|grep ^copy +hg debugstate|grep '^copy' echo "# shouldn't show copy" hg commit -m2 -d"0 0" -hg debugstate|grep ^copy +hg debugstate|grep '^copy' echo "# should match" hg debugindex .hg/data/foo.i @@ -28,7 +28,7 @@ cp foo bar hg copy foo bar echo "# should show copy" -hg debugstate|grep ^copy +hg debugstate|grep '^copy' hg commit -m3 -d"0 0" echo "# should show no parents for tip" @@ -38,6 +38,6 @@ hg debugrename bar echo "# should show no copies" -hg debugstate|grep ^copy +hg debugstate|grep '^copy' exit 0
--- a/tests/test-grep Tue Aug 30 21:58:44 2005 +0200 +++ b/tests/test-grep Wed Aug 31 21:07:36 2005 +0200 @@ -18,5 +18,6 @@ mv port1 port hg commit -m 4 -u spam -d '4 0' hg grep port port +echo 'FIXME: history is wrong here' hg grep -enu port port hg grep import port
--- a/tests/test-ssh Tue Aug 30 21:58:44 2005 +0200 +++ b/tests/test-ssh Wed Aug 31 21:07:36 2005 +0200 @@ -13,7 +13,7 @@ fi # check that we're in the right directory -if \! [ -x dummyssh ] ; then +if [ ! -x dummyssh ] ; then exit -1 fi
--- a/tests/test-ssh.out Tue Aug 30 21:58:44 2005 +0200 +++ b/tests/test-ssh.out Wed Aug 31 21:07:36 2005 +0200 @@ -5,7 +5,6 @@ adding manifests adding file changes added 1 changesets with 1 changes to 1 files -remote: ./dummyssh: line 11: !: command not found # verify checking changesets checking manifests @@ -16,13 +15,11 @@ default = ssh://user@dummy/remote pulling from ssh://user@dummy/remote searching for changes -remote: ../dummyssh: line 11: !: command not found no changes found # local change # updating rc # find outgoing searching for changes -remote: ../dummyssh: line 11: !: command not found changeset: 1:536411b157b4 tag: tip user: test @@ -31,7 +28,6 @@ # push pushing to ssh://user@dummy/remote -remote: ../dummyssh: line 11: !: command not found searching for changes remote: adding changesets remote: adding manifests