diff --git a/contrib/dumprevlog b/contrib/dumprevlog new file mode 100644 --- /dev/null +++ b/contrib/dumprevlog @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# Dump revlogs as raw data stream +# $ find .hg/store/ -name "*.i" | xargs dumprevlog > repo.dump + +import sys +from mercurial import revlog, node + +for f in sys.argv[1:]: + r = revlog.revlog(open, f) + print "file:", f + for i in xrange(r.count()): + n = r.node(i) + p = r.parents(n) + d = r.revision(n) + print "node:", node.hex(n) + print "linkrev:", r.linkrev(n) + print "parents:", node.hex(p[0]), node.hex(p[1]) + print "length:", len(d) + print "-start-" + print d + print "-end-" diff --git a/contrib/mercurial.el b/contrib/mercurial.el --- a/contrib/mercurial.el +++ b/contrib/mercurial.el @@ -35,8 +35,10 @@ ;; This code has been developed under XEmacs 21.5, and may not work as ;; well under GNU Emacs (albeit tested under 21.4). Patches to ;; enhance the portability of this code, fix bugs, and add features -;; are most welcome. You can clone a Mercurial repository for this -;; package from http://www.serpentine.com/hg/hg-emacs +;; are most welcome. + +;; As of version 22.3, GNU Emacs's VC mode has direct support for +;; Mercurial, so this package may not prove as useful there. ;; Please send problem reports and suggestions to bos@serpentine.com. diff --git a/contrib/undumprevlog b/contrib/undumprevlog new file mode 100644 --- /dev/null +++ b/contrib/undumprevlog @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# Undump a dump from dumprevlog +# $ hg init +# $ undumprevlog < repo.dump + +import sys +from mercurial import revlog, node, util, transaction + +opener = util.opener('.', False) +tr = transaction.transaction(sys.stderr.write, opener, "undump.journal") +while 1: + l = sys.stdin.readline() + if not l: + break + if l.startswith("file:"): + f = l[6:-1] + r = revlog.revlog(opener, f) + print f + elif l.startswith("node:"): + n = node.bin(l[6:-1]) + elif l.startswith("linkrev:"): + lr = int(l[9:-1]) + elif l.startswith("parents:"): + p = l[9:-1].split() + p1 = node.bin(p[0]) + p2 = node.bin(p[1]) + elif l.startswith("length:"): + length = int(l[8:-1]) + sys.stdin.readline() # start marker + d = sys.stdin.read(length) + sys.stdin.readline() # end marker + r.addrevision(d, tr, lr, p1, p2) + +tr.close() diff --git a/doc/hg.1.txt b/doc/hg.1.txt --- a/doc/hg.1.txt +++ b/doc/hg.1.txt @@ -30,7 +30,7 @@ revision:: repository path:: either the pathname of a local repository or the URI of a remote - repository. There are two available URI protocols, http:// which is + repository. There are two available URI protocols, http:// which is fast and the static-http:// protocol which is much slower but does not require a special server on the web host. @@ -43,7 +43,7 @@ SPECIFYING SINGLE REVISIONS Mercurial accepts several notations for identifying individual revisions. - A plain integer is treated as a revision number. Negative + A plain integer is treated as a revision number. Negative integers are treated as offsets from the tip, with -1 denoting the tip. @@ -52,11 +52,11 @@ SPECIFYING SINGLE REVISIONS A hexadecimal string less than 40 characters long is treated as a unique revision identifier, and referred to as a short-form - identifier. A short-form identifier is only valid if it is the + identifier. A short-form identifier is only valid if it is the prefix of one full-length identifier. Any other string is treated as a tag name, which is a symbolic - name associated with a revision identifier. Tag names may not + name associated with a revision identifier. Tag names may not contain the ":" character. The reserved name "tip" is a special tag that always identifies @@ -78,16 +78,16 @@ SPECIFYING MULTIPLE REVISIONS separated by the ":" character. The syntax of range notation is [BEGIN]:[END], where BEGIN and END - are revision identifiers. Both BEGIN and END are optional. If - BEGIN is not specified, it defaults to revision number 0. If END - is not specified, it defaults to the tip. The range ":" thus + are revision identifiers. Both BEGIN and END are optional. If + BEGIN is not specified, it defaults to revision number 0. If END + is not specified, it defaults to the tip. The range ":" thus means "all revisions". If BEGIN is greater than END, revisions are treated in reverse order. - A range acts as a closed interval. This means that a range of 3:5 - gives 3, 4 and 5. Similarly, a range of 4:2 gives 4, 3, and 2. + A range acts as a closed interval. This means that a range of 3:5 + gives 3, 4 and 5. Similarly, a range of 4:2 gives 4, 3, and 2. FILES ----- @@ -103,7 +103,7 @@ FILES /etc/mercurial/hgrc, $HOME/.hgrc, .hg/hgrc:: This file contains defaults and configuration. Values in .hg/hgrc override those in $HOME/.hgrc, and these override settings made in the - global /etc/mercurial/hgrc configuration. See hgrc(5) for details of + global /etc/mercurial/hgrc configuration. See hgrc(5) for details of the contents and format of these files. Some commands (e.g. revert) produce backup files ending in .orig, if diff --git a/doc/hgignore.5.txt b/doc/hgignore.5.txt --- a/doc/hgignore.5.txt +++ b/doc/hgignore.5.txt @@ -17,25 +17,25 @@ DESCRIPTION ----------- Mercurial ignores every unmanaged file that matches any pattern in an -ignore file. The patterns in an ignore file do not apply to files -managed by Mercurial. To control Mercurial's handling of files that -it manages, see the hg(1) man page. Look for the "-I" and "-X" +ignore file. The patterns in an ignore file do not apply to files +managed by Mercurial. To control Mercurial's handling of files that +it manages, see the hg(1) man page. Look for the "-I" and "-X" options. In addition, a Mercurial configuration file can point to a set of -per-user or global ignore files. See the hgrc(5) man page for details -of how to configure these files. Look for the "ignore" entry in the +per-user or global ignore files. See the hgrc(5) man page for details +of how to configure these files. Look for the "ignore" entry in the "ui" section. SYNTAX ------ An ignore file is a plain text file consisting of a list of patterns, -with one pattern per line. Empty lines are skipped. The "#" +with one pattern per line. Empty lines are skipped. The "#" character is treated as a comment character, and the "\" character is treated as an escape character. -Mercurial supports several pattern syntaxes. The default syntax used +Mercurial supports several pattern syntaxes. The default syntax used is Python/Perl-style regular expressions. To change the syntax used, use a line of the following form: @@ -52,9 +52,9 @@ glob:: The chosen syntax stays in effect when parsing all patterns that follow, until another syntax is selected. -Neither glob nor regexp patterns are rooted. A glob-syntax pattern of +Neither glob nor regexp patterns are rooted. A glob-syntax pattern of the form "*.c" will match a file ending in ".c" in any directory, and -a regexp pattern of the form "\.c$" will do the same. To root a +a regexp pattern of the form "\.c$" will do the same. To root a regexp pattern, start it with "^". EXAMPLE diff --git a/doc/hgrc.5.txt b/doc/hgrc.5.txt --- a/doc/hgrc.5.txt +++ b/doc/hgrc.5.txt @@ -17,26 +17,26 @@ FILES Mercurial reads configuration data from several files, if they exist. The names of these files depend on the system on which Mercurial is -installed. *.rc files from a single directory are read in -alphabetical order, later ones overriding earlier ones. Where +installed. *.rc files from a single directory are read in +alphabetical order, later ones overriding earlier ones. Where multiple paths are given below, settings from later paths override earlier ones. (Unix) /etc/mercurial/hgrc.d/*.rc:: (Unix) /etc/mercurial/hgrc:: Per-installation configuration files, searched for in the - directory where Mercurial is installed. is the + directory where Mercurial is installed. is the parent directory of the hg executable (or symlink) being run. For example, if installed in /shared/tools/bin/hg, Mercurial will - look in /shared/tools/etc/mercurial/hgrc. Options in these files + look in /shared/tools/etc/mercurial/hgrc. Options in these files apply to all Mercurial commands executed by any user in any directory. (Unix) /etc/mercurial/hgrc.d/*.rc:: (Unix) /etc/mercurial/hgrc:: Per-system configuration files, for the system on which Mercurial - is running. Options in these files apply to all Mercurial - commands executed by any user in any directory. Options in these + is running. Options in these files apply to all Mercurial + commands executed by any user in any directory. Options in these files override per-installation options. (Windows) \Mercurial.ini:: @@ -45,7 +45,7 @@ earlier ones. or else:: (Windows) C:\Mercurial\Mercurial.ini:: Per-installation/system configuration files, for the system on - which Mercurial is running. Options in these files apply to all + which Mercurial is running. Options in these files apply to all Mercurial commands executed by any user in any directory. Registry keys contain PATH-like strings, every part of which must reference a Mercurial.ini file or be a directory where *.rc files @@ -59,16 +59,16 @@ earlier ones. Per-user configuration file(s), for the user running Mercurial. On Windows 9x, %HOME% is replaced by %APPDATA%. Options in these files apply to all Mercurial commands executed - by this user in any directory. Options in thes files override + by this user in any directory. Options in thes files override per-installation and per-system options. (Unix, Windows) /.hg/hgrc:: Per-repository configuration options that only apply in a - particular repository. This file is not version-controlled, and - will not get transferred during a "clone" operation. Options in + particular repository. This file is not version-controlled, and + will not get transferred during a "clone" operation. Options in this file override options in all other configuration files. On Unix, most of this file will be ignored if it doesn't belong - to a trusted user or to a trusted group. See the documentation + to a trusted user or to a trusted group. See the documentation for the trusted section below for more details. SYNTAX @@ -82,10 +82,10 @@ and followed by "name: value" entries; " green= eggs -Each line contains one entry. If the lines that follow are indented, +Each line contains one entry. If the lines that follow are indented, they are treated as continuations of that entry. -Leading whitespace is removed from values. Empty lines are skipped. +Leading whitespace is removed from values. Empty lines are skipped. The optional values can contain format strings which refer to other values in the same section, or values in a special DEFAULT section. @@ -107,12 +107,12 @@ decode/encode:: Filters consist of a filter pattern followed by a filter command. Filter patterns are globs by default, rooted at the repository - root. For example, to match any file ending in ".txt" in the root - directory only, use the pattern "*.txt". To match any file ending + root. For example, to match any file ending in ".txt" in the root + directory only, use the pattern "*.txt". To match any file ending in ".c" anywhere in the repository, use the pattern "**.c". The filter command can start with a specifier, either "pipe:" or - "tempfile:". If no specifier is given, "pipe:" is used by default. + "tempfile:". If no specifier is given, "pipe:" is used by default. A "pipe:" command must accept data on stdin and return the transformed data on stdout. @@ -129,9 +129,9 @@ decode/encode:: # can safely omit "pipe:", because it's the default) *.gz = gzip - A "tempfile:" command is a template. The string INFILE is replaced + A "tempfile:" command is a template. The string INFILE is replaced with the name of a temporary file that contains the data to be - filtered by the command. The string OUTFILE is replaced with the + filtered by the command. The string OUTFILE is replaced with the name of an empty temporary file, where the filtered data must be written by the command. @@ -192,22 +192,22 @@ diff:: email:: Settings for extensions that send email messages. from;; - Optional. Email address to use in "From" header and SMTP envelope + Optional. Email address to use in "From" header and SMTP envelope of outgoing messages. to;; - Optional. Comma-separated list of recipients' email addresses. + Optional. Comma-separated list of recipients' email addresses. cc;; - Optional. Comma-separated list of carbon copy recipients' + Optional. Comma-separated list of carbon copy recipients' email addresses. bcc;; - Optional. Comma-separated list of blind carbon copy - recipients' email addresses. Cannot be set interactively. + Optional. Comma-separated list of blind carbon copy + recipients' email addresses. Cannot be set interactively. method;; - Optional. Method to use to send email messages. If value is + Optional. Method to use to send email messages. If value is "smtp" (default), use SMTP (see section "[smtp]" for - configuration). Otherwise, use as name of program to run that + configuration). Otherwise, use as name of program to run that acts like sendmail (takes "-f" option for sender, list of - recipients on command line, message on stdin). Normally, setting + recipients on command line, message on stdin). Normally, setting this to "sendmail" or "/usr/sbin/sendmail" is enough to use sendmail to send messages. @@ -281,6 +281,7 @@ merge-tools:: myHtmlTool.priority = 1 Supported arguments: + priority;; The priority in which to evaluate this tool. Default: 0. @@ -297,10 +298,10 @@ merge-tools:: launching external tool. Default: True binary;; - This tool can merge binary files. Defaults to False, unless tool + This tool can merge binary files. Defaults to False, unless tool was selected by file pattern match. symlink;; - This tool can merge symlinks. Defaults to False, even if tool was + This tool can merge symlinks. Defaults to False, even if tool was selected by file pattern match. checkconflicts;; Check whether there are conflicts even though the tool reported @@ -313,18 +314,18 @@ merge-tools:: fixeol;; Attempt to fix up EOL changes caused by the merge tool. Default: False - gui:; + gui;; This tool requires a graphical interface to run. Default: False regkey;; Windows registry key which describes install location of this tool. Mercurial will search for this key first under HKEY_CURRENT_USER and - then under HKEY_LOCAL_MACHINE. Default: None + then under HKEY_LOCAL_MACHINE. Default: None regname;; - Name of value to read from specified registry key. Defaults to the + Name of value to read from specified registry key. Defaults to the unnamed (default) value. regappend;; String to append to the value read from the registry, typically the - executable name of the tool. Default: None + executable name of the tool. Default: None hooks:: Commands or Python functions that get automatically executed by @@ -342,24 +343,24 @@ hooks:: incoming.autobuild = /my/build/hook Most hooks are run with environment variables set that give added - useful information. For each hook below, the environment variables + useful information. For each hook below, the environment variables it is passed are listed with names of the form "$HG_foo". changegroup;; Run after a changegroup has been added via push, pull or - unbundle. ID of the first new changeset is in $HG_NODE. URL from + unbundle. ID of the first new changeset is in $HG_NODE. URL from which changes came is in $HG_URL. commit;; Run after a changeset has been created in the local repository. - ID of the newly created changeset is in $HG_NODE. Parent + ID of the newly created changeset is in $HG_NODE. Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2. incoming;; Run after a changeset has been pulled, pushed, or unbundled into - the local repository. The ID of the newly arrived changeset is in - $HG_NODE. URL that was source of changes came is in $HG_URL. + the local repository. The ID of the newly arrived changeset is in + $HG_NODE. URL that was source of changes came is in $HG_URL. outgoing;; - Run after sending changes from local repository to another. ID of - first changeset sent is in $HG_NODE. Source of operation is in + Run after sending changes from local repository to another. ID of + first changeset sent is in $HG_NODE. Source of operation is in $HG_SOURCE; see "preoutgoing" hook for description. post-;; Run after successful invocations of the associated command. The @@ -371,56 +372,56 @@ hooks:: the command doesn't execute and Mercurial returns the failure code. prechangegroup;; Run before a changegroup is added via push, pull or unbundle. - Exit status 0 allows the changegroup to proceed. Non-zero status - will cause the push, pull or unbundle to fail. URL from which + Exit status 0 allows the changegroup to proceed. Non-zero status + will cause the push, pull or unbundle to fail. URL from which changes will come is in $HG_URL. precommit;; - Run before starting a local commit. Exit status 0 allows the - commit to proceed. Non-zero status will cause the commit to fail. + Run before starting a local commit. Exit status 0 allows the + commit to proceed. Non-zero status will cause the commit to fail. Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2. preoutgoing;; Run before collecting changes to send from the local repository to - another. Non-zero status will cause failure. This lets you - prevent pull over http or ssh. Also prevents against local pull, + another. Non-zero status will cause failure. This lets you + prevent pull over http or ssh. Also prevents against local pull, push (outbound) or bundle commands, but not effective, since you - can just copy files instead then. Source of operation is in - $HG_SOURCE. If "serve", operation is happening on behalf of - remote ssh or http repository. If "push", "pull" or "bundle", + can just copy files instead then. Source of operation is in + $HG_SOURCE. If "serve", operation is happening on behalf of + remote ssh or http repository. If "push", "pull" or "bundle", operation is happening on behalf of repository on same system. pretag;; - Run before creating a tag. Exit status 0 allows the tag to be - created. Non-zero status will cause the tag to fail. ID of - changeset to tag is in $HG_NODE. Name of tag is in $HG_TAG. Tag + Run before creating a tag. Exit status 0 allows the tag to be + created. Non-zero status will cause the tag to fail. ID of + changeset to tag is in $HG_NODE. Name of tag is in $HG_TAG. Tag is local if $HG_LOCAL=1, in repo if $HG_LOCAL=0. pretxnchangegroup;; Run after a changegroup has been added via push, pull or unbundle, - but before the transaction has been committed. Changegroup is - visible to hook program. This lets you validate incoming changes - before accepting them. Passed the ID of the first new changeset - in $HG_NODE. Exit status 0 allows the transaction to commit. + but before the transaction has been committed. Changegroup is + visible to hook program. This lets you validate incoming changes + before accepting them. Passed the ID of the first new changeset + in $HG_NODE. Exit status 0 allows the transaction to commit. Non-zero status will cause the transaction to be rolled back and - the push, pull or unbundle will fail. URL that was source of + the push, pull or unbundle will fail. URL that was source of changes is in $HG_URL. pretxncommit;; Run after a changeset has been created but the transaction not yet - committed. Changeset is visible to hook program. This lets you - validate commit message and changes. Exit status 0 allows the - commit to proceed. Non-zero status will cause the transaction to - be rolled back. ID of changeset is in $HG_NODE. Parent changeset + committed. Changeset is visible to hook program. This lets you + validate commit message and changes. Exit status 0 allows the + commit to proceed. Non-zero status will cause the transaction to + be rolled back. ID of changeset is in $HG_NODE. Parent changeset IDs are in $HG_PARENT1 and $HG_PARENT2. preupdate;; - Run before updating the working directory. Exit status 0 allows - the update to proceed. Non-zero status will prevent the update. - Changeset ID of first new parent is in $HG_PARENT1. If merge, ID + Run before updating the working directory. Exit status 0 allows + the update to proceed. Non-zero status will prevent the update. + Changeset ID of first new parent is in $HG_PARENT1. If merge, ID of second new parent is in $HG_PARENT2. tag;; - Run after a tag is created. ID of tagged changeset is in - $HG_NODE. Name of tag is in $HG_TAG. Tag is local if + Run after a tag is created. ID of tagged changeset is in + $HG_NODE. Name of tag is in $HG_TAG. Tag is local if $HG_LOCAL=1, in repo if $HG_LOCAL=0. update;; - Run after updating the working directory. Changeset ID of first - new parent is in $HG_PARENT1. If merge, ID of second new parent - is in $HG_PARENT2. If update succeeded, $HG_ERROR=0. If update + Run after updating the working directory. Changeset ID of first + new parent is in $HG_PARENT1. If merge, ID of second new parent + is in $HG_PARENT2. If update succeeded, $HG_ERROR=0. If update failed (e.g. because conflicts not resolved), $HG_ERROR=1. Note: it is generally better to use standard hooks rather than the @@ -438,10 +439,10 @@ hooks:: hookname = python:modulename.submodule.callable - Python hooks are run within the Mercurial process. Each hook is + Python hooks are run within the Mercurial process. Each hook is called with at least three keyword arguments: a ui object (keyword "ui"), a repository object (keyword "repo"), and a "hooktype" - keyword that tells what kind of hook is used. Arguments listed as + keyword that tells what kind of hook is used. Arguments listed as environment variables above are passed as keyword arguments, with no "HG_" prefix, and names in lower case. @@ -455,68 +456,68 @@ http_proxy:: Host name and (optional) port of the proxy server, for example "myproxy:8000". no;; - Optional. Comma-separated list of host names that should bypass + Optional. Comma-separated list of host names that should bypass the proxy. passwd;; - Optional. Password to authenticate with at the proxy server. + Optional. Password to authenticate with at the proxy server. user;; - Optional. User name to authenticate with at the proxy server. + Optional. User name to authenticate with at the proxy server. smtp:: Configuration for extensions that need to send email messages. host;; Host name of mail server, e.g. "mail.example.com". port;; - Optional. Port to connect to on mail server. Default: 25. + Optional. Port to connect to on mail server. Default: 25. tls;; - Optional. Whether to connect to mail server using TLS. True or - False. Default: False. + Optional. Whether to connect to mail server using TLS. True or + False. Default: False. username;; - Optional. User name to authenticate to SMTP server with. + Optional. User name to authenticate to SMTP server with. If username is specified, password must also be specified. Default: none. password;; - Optional. Password to authenticate to SMTP server with. + Optional. Password to authenticate to SMTP server with. If username is specified, password must also be specified. Default: none. local_hostname;; - Optional. It's the hostname that the sender can use to identify itself + Optional. It's the hostname that the sender can use to identify itself to the MTA. paths:: - Assigns symbolic names to repositories. The left side is the + Assigns symbolic names to repositories. The left side is the symbolic name, and the right gives the directory or URL that is the - location of the repository. Default paths can be declared by + location of the repository. Default paths can be declared by setting the following entries. default;; Directory or URL to use when pulling if no source is specified. Default is set to repository from which the current repository was cloned. default-push;; - Optional. Directory or URL to use when pushing if no destination + Optional. Directory or URL to use when pushing if no destination is specified. server:: Controls generic server settings. uncompressed;; Whether to allow clients to clone a repo using the uncompressed - streaming protocol. This transfers about 40% more data than a + streaming protocol. This transfers about 40% more data than a regular clone, but uses less memory and CPU on both server and - client. Over a LAN (100Mbps or better) or a very fast WAN, an + client. Over a LAN (100Mbps or better) or a very fast WAN, an uncompressed streaming clone is a lot faster (~10x) than a regular - clone. Over most WAN connections (anything slower than about + clone. Over most WAN connections (anything slower than about 6Mbps), uncompressed streaming is slower, because of the extra - data transfer overhead. Default is False. + data transfer overhead. Default is False. trusted:: For security reasons, Mercurial will not use the settings in the .hg/hgrc file from a repository if it doesn't belong to a - trusted user or to a trusted group. The main exception is the + trusted user or to a trusted group. The main exception is the web interface, which automatically uses some safe settings, since it's common to serve repositories from different users. - This section specifies what users and groups are trusted. The - current user is always trusted. To trust everybody, list a user + This section specifies what users and groups are trusted. The + current user is always trusted. To trust everybody, list a user or a group with name "*". users;; @@ -532,12 +533,12 @@ ui:: the hg archive command or downloaded via hgweb. Default is true. debug;; - Print debugging information. True or False. Default is False. + Print debugging information. True or False. Default is False. editor;; - The editor to use during a commit. Default is $EDITOR or "vi". + The editor to use during a commit. Default is $EDITOR or "vi". fallbackencoding;; Encoding to try if it's not possible to decode the changelog using - UTF-8. Default is ISO-8859-1. + UTF-8. Default is ISO-8859-1. ignore;; A file to read per-user ignore patterns from. This file should be in the same format as a repository-wide .hgignore file. This option @@ -546,7 +547,7 @@ ui:: "ignore.other = ~/.hgignore2". For details of the ignore file format, see the hgignore(5) man page. interactive;; - Allow to prompt the user. True or False. Default is True. + Allow to prompt the user. True or False. Default is True. logtemplate;; Template string for commands that print changesets. merge;; @@ -563,18 +564,19 @@ ui:: fail to merge See the merge-tools section for more information on configuring tools. + patch;; command to use to apply patches. Look for 'gpatch' or 'patch' in PATH if unset. quiet;; - Reduce the amount of output printed. True or False. Default is False. + 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'. report_untrusted;; Warn if a .hg/hgrc file is ignored due to not being owned by a - trusted user or group. True or False. Default is True. + trusted user or group. True or False. Default is True. slash;; - Display paths using a slash ("/") as the path separator. This only + Display paths using a slash ("/") as the path separator. This only makes a difference on systems where the default path separator is not the slash character (e.g. Windows uses the backslash character ("\")). Default is False. @@ -582,7 +584,7 @@ ui:: command to use for SSH connections. Default is 'ssh'. strict;; Require exact command names, instead of allowing unambiguous - abbreviations. True or False. Default is False. + abbreviations. True or False. Default is False. style;; Name of style to use for command output. timeout;; @@ -591,12 +593,12 @@ ui:: username;; The committer of a changeset created when running "commit". Typically a person's name and email address, e.g. "Fred Widget - ". Default is $EMAIL or username@hostname. + ". Default is $EMAIL or username@hostname. If the username in hgrc is empty, it has to be specified manually or in a different hgrc file (e.g. $HOME/.hgrc, if the admin set "username =" in the system hgrc). verbose;; - Increase the amount of output printed. True or False. Default is False. + Increase the amount of output printed. True or False. Default is False. web:: @@ -617,9 +619,9 @@ web:: allowpull;; Whether to allow pulling from the repository. Default is true. allow_push;; - Whether to allow pushing to the repository. If empty or not set, - push is not allowed. If the special value "*", any remote user - can push, including unauthenticated users. Otherwise, the remote + Whether to allow pushing to the repository. If empty or not set, + push is not allowed. If the special value "*", any remote user + can push, including unauthenticated users. Otherwise, the remote user must have been authenticated, and the authenticated user name must be present in this list (separated by whitespace or ","). The contents of the allow_push list are examined after the @@ -635,11 +637,11 @@ web:: Name or email address of the person in charge of the repository. Defaults to ui.username or $EMAIL or "unknown" if unset or empty. deny_push;; - Whether to deny pushing to the repository. If empty or not set, - push is not denied. If the special value "*", all remote users - are denied push. Otherwise, unauthenticated users are all denied, + Whether to deny pushing to the repository. If empty or not set, + push is not denied. If the special value "*", all remote users + are denied push. Otherwise, unauthenticated users are all denied, and any authenticated user name present in this list (separated by - whitespace or ",") is also denied. The contents of the deny_push + whitespace or ",") is also denied. The contents of the deny_push list are examined before the allow_push list. description;; Textual description of the repository's purpose or contents. @@ -666,7 +668,7 @@ web:: Prefix path to serve from. Default is '' (server root). push_ssl;; Whether to require that inbound pushes be transported over SSL to - prevent password sniffing. Default is true. + prevent password sniffing. Default is true. staticurl;; Base URL to use for static files. If unset, static files (e.g. the hgicon.png favicon) will be served by the CGI script itself. diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -387,7 +387,7 @@ class svn_source(converter_source): try: for entry in get_log(self.url, [self.tags], start, self.startrev): origpaths, revnum, author, date, message = entry - copies = [(e.copyfrom_path, e.copyfrom_rev, p) for p,e + copies = [(e.copyfrom_path, e.copyfrom_rev, p) for p, e in origpaths.iteritems() if e.copyfrom_path] copies.sort() # Apply moves/copies from more specific to general diff --git a/hgext/highlight.py b/hgext/highlight.py --- a/hgext/highlight.py +++ b/hgext/highlight.py @@ -20,18 +20,13 @@ file should be re-generated by running # pygmentize -f html -S - -- Adam Hupp - - """ from mercurial import demandimport -demandimport.ignore.extend(['pkgutil', - 'pkg_resources', - '__main__',]) +demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__',]) -from mercurial.hgweb.hgweb_mod import hgweb +from mercurial.hgweb import webcommands, webutil from mercurial import util from mercurial.templatefilters import filters @@ -43,7 +38,8 @@ from pygments.formatters import HtmlForm SYNTAX_CSS = ('\n') -def pygmentize(self, tmpl, fctx, field): +def pygmentize(field, fctx, style, tmpl): + # append a to the syntax highlighting css old_header = ''.join(tmpl('header')) if SYNTAX_CSS not in old_header: @@ -54,7 +50,6 @@ def pygmentize(self, tmpl, fctx, field): if util.binary(text): return - style = self.config("web", "pygments_style", "colorful") # To get multi-line strings right, we can't format line-by-line try: lexer = guess_lexer_for_filename(fctx.path(), text, @@ -79,20 +74,21 @@ def pygmentize(self, tmpl, fctx, field): newl = oldl.replace('line|escape', 'line|colorize') tmpl.cache[field] = newl -def filerevision_highlight(self, tmpl, fctx): - pygmentize(self, tmpl, fctx, 'fileline') - - return realrevision(self, tmpl, fctx) +web_filerevision = webcommands._filerevision +web_annotate = webcommands.annotate -def fileannotate_highlight(self, tmpl, fctx): - pygmentize(self, tmpl, fctx, 'annotateline') +def filerevision_highlight(web, tmpl, fctx): + style = web.config('web', 'pygments_style', 'colorful') + pygmentize('fileline', fctx, style, tmpl) + return web_filerevision(web, tmpl, fctx) - return realannotate(self, tmpl, fctx) +def annotate_highlight(web, req, tmpl): + fctx = webutil.filectx(web.repo, req) + style = web.config('web', 'pygments_style', 'colorful') + pygmentize('annotateline', fctx, style, tmpl) + return web_annotate(web, req, tmpl) # monkeypatch in the new version -# should be safer than overriding the method in a derived class -# and then patching the class -realrevision = hgweb.filerevision -hgweb.filerevision = filerevision_highlight -realannotate = hgweb.fileannotate -hgweb.fileannotate = fileannotate_highlight + +webcommands._filerevision = filerevision_highlight +webcommands.annotate = annotate_highlight diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -108,6 +108,8 @@ kwtools = {'templater': None, 'hgcmd': N _patchfile_init = patch.patchfile.__init__ _patch_diff = patch.diff _dispatch_parse = dispatch._parse +_webcommands_changeset = webcommands.changeset +_webcommands_filediff = webcommands.filediff def _kwpatchfile_init(self, ui, fname, missing=False): '''Monkeypatch/wrap patch.patchfile.__init__ to avoid @@ -131,12 +133,12 @@ def _kw_diff(repo, node1=None, node2=Non def _kwweb_changeset(web, req, tmpl): '''Wraps webcommands.changeset turning off keyword expansion.''' kwtools['templater'].matcher = util.never - return web.changeset(tmpl, web.changectx(req)) + return _webcommands_changeset(web, req, tmpl) def _kwweb_filediff(web, req, tmpl): '''Wraps webcommands.filediff turning off keyword expansion.''' kwtools['templater'].matcher = util.never - return web.filediff(tmpl, web.filectx(req)) + return _webcommands_filediff(web, req, tmpl) def _kwdispatch_parse(ui, args): '''Monkeypatch dispatch._parse to obtain running hg command.''' @@ -145,6 +147,7 @@ def _kwdispatch_parse(ui, args): return cmd, func, args, options, cmdoptions # dispatch._parse is run before reposetup, so wrap it here +# all other actual monkey patching is done at end of reposetup dispatch._parse = _kwdispatch_parse diff --git a/hgext/pager.py b/hgext/pager.py --- a/hgext/pager.py +++ b/hgext/pager.py @@ -24,12 +24,37 @@ # # [pager] # quiet = True +# +# You can disable the pager for certain commands by adding them to the +# pager.ignore list: +# +# [pager] +# ignore = version, help, update +# +# You can also enable the pager only for certain commands using pager.attend: +# +# [pager] +# attend = log +# +# If pager.attend is present, pager.ignore will be ignored. +# +# To ignore global commands like 'hg version' or 'hg help', you have to specify them +# in the global .hgrc import sys, os, signal +from mercurial import dispatch def uisetup(ui): - p = ui.config("pager", "pager", os.environ.get("PAGER")) - if p and sys.stdout.isatty() and '--debugger' not in sys.argv: - if ui.configbool('pager', 'quiet'): - signal.signal(signal.SIGPIPE, signal.SIG_DFL) - sys.stderr = sys.stdout = os.popen(p, "wb") + def pagecmd(ui, options, cmd, cmdfunc): + p = ui.config("pager", "pager", os.environ.get("PAGER")) + if p and sys.stdout.isatty() and '--debugger' not in sys.argv: + attend = ui.configlist('pager', 'attend') + if (cmd in attend or + (cmd not in ui.configlist('pager', 'ignore') and not attend)): + sys.stderr = sys.stdout = os.popen(p, "wb") + if ui.configbool('pager', 'quiet'): + signal.signal(signal.SIGPIPE, signal.SIG_DFL) + return oldrun(ui, options, cmd, cmdfunc) + + oldrun = dispatch._runcommand + dispatch._runcommand = pagecmd diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -66,7 +66,8 @@ import os, errno, socket, tempfile import email.MIMEMultipart, email.MIMEText, email.MIMEBase -import email.Utils, email.Encoders +import email.Utils, email.Encoders, email.Generator +import cStringIO.StringIO from mercurial import cmdutil, commands, hg, mail, patch, util from mercurial.i18n import _ from mercurial.node import bin @@ -407,8 +408,9 @@ def patchbomb(ui, repo, *revs, **opts): fp = os.popen(os.environ['PAGER'], 'w') else: fp = ui + generator = email.Generator.Generator(fp, mangle_from_=False) try: - fp.write(m.as_string(0)) + generator.flatten(m, 0) fp.write('\n') except IOError, inst: if inst.errno != errno.EPIPE: @@ -418,9 +420,10 @@ def patchbomb(ui, repo, *revs, **opts): elif opts.get('mbox'): ui.status('Writing ', m['Subject'], ' ...\n') fp = open(opts.get('mbox'), 'In-Reply-To' in m and 'ab+' or 'wb+') + generator = email.Generator.Generator(fp, mangle_from_=True) date = util.datestr(start_time, '%a %b %d %H:%M:%S %Y') fp.write('From %s %s\n' % (sender_addr, date)) - fp.write(m.as_string(0)) + generator.flatten(m, 0) fp.write('\n\n') fp.close() else: @@ -429,7 +432,10 @@ def patchbomb(ui, repo, *revs, **opts): ui.status('Sending ', m['Subject'], ' ...\n') # Exim does not remove the Bcc field del m['Bcc'] - sendmail(sender, to + bcc + cc, m.as_string(0)) + fp = cStringIO.StringIO() + generator = email.Generator.Generator(fp, mangle_from_=False) + generator.flatten(m, 0) + sendmail(sender, to + bcc + cc, fp.getvalue()) cmdtable = { "email": diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -53,11 +53,11 @@ def addremove(ui, repo, *pats, **opts): New files are ignored if they match any of the patterns in .hgignore. As with add, these changes take effect at the next commit. - Use the -s option to detect renamed files. With a parameter > 0, + Use the -s option to detect renamed files. With a parameter > 0, this compares every removed file with every added file and records - those similar enough as renames. This option takes a percentage + those similar enough as renames. This option takes a percentage between 0 (disabled) and 100 (files must be identical) as its - parameter. Detecting renamed files this way can be expensive. + parameter. Detecting renamed files this way can be expensive. """ try: sim = float(opts.get('similarity') or 0) @@ -134,7 +134,7 @@ def archive(ui, repo, dest, **opts): By default, the revision used is the parent of the working directory; use "-r" to specify a different revision. - To specify the type of archive to create, use "-t". Valid + To specify the type of archive to create, use "-t". Valid types are: "files" (default): a directory full of files @@ -148,7 +148,7 @@ def archive(ui, repo, dest, **opts): using a format string; see "hg help export" for details. Each member added to an archive file has a directory prefix - prepended. Use "-p" to specify a format string for the prefix. + prepended. Use "-p" to specify a format string for the prefix. The default is the basename of the archive, with suffixes removed. ''' @@ -174,17 +174,17 @@ def archive(ui, repo, dest, **opts): def backout(ui, repo, node=None, rev=None, **opts): '''reverse effect of earlier changeset - Commit the backed out changes as a new changeset. The new + Commit the backed out changes as a new changeset. The new changeset is a child of the backed out changeset. If you back out a changeset other than the tip, a new head is - created. This head will be the new tip and you should merge this + created. This head will be the new tip and you should merge this backout changeset with another head (current one by default). The --merge option remembers the parent of the working directory before starting the backout, then merges the new head with that - changeset afterwards. This saves you from doing the merge by - hand. The result of this merge is not committed, as for a normal + changeset afterwards. This saves you from doing the merge by + hand. The result of this merge is not committed, as for a normal merge. See 'hg help dates' for a list of formats valid for -d/--date. @@ -369,7 +369,7 @@ def branches(ui, repo, active=False): """list repository named branches List the repository's named branches, indicating which ones are - inactive. If active is specified, only show active branches. + inactive. If active is specified, only show active branches. A branch is considered active if it contains unmerged heads. @@ -404,7 +404,7 @@ def bundle(ui, repo, fname, dest=None, * If no destination repository is specified the destination is assumed to have all the nodes specified by one or more --base - parameters. To create a bundle containing all changesets, use + parameters. To create a bundle containing all changesets, use --all (or --base null). The bundle file can then be transferred using conventional means and @@ -469,7 +469,7 @@ def cat(ui, repo, file1, *pats, **opts): or tip if no revision is checked out. Output may be to a file, in which case the name of the file is - given using a format string. The formatting rules are the same as + given using a format string. The formatting rules are the same as for the export command, with the following additions: %s basename of file being printed @@ -501,9 +501,9 @@ def clone(ui, source, dest=None, **opts) For efficiency, hardlinks are used for cloning whenever the source and destination are on the same filesystem (note this applies only - to the repository data, not to the checked out files). Some + to the repository data, not to the checked out files). Some filesystems, such as AFS, implement hardlinking incorrectly, but - do not report errors. In these cases, use the --pull option to + do not report errors. In these cases, use the --pull option to avoid hardlinking. You can safely clone repositories and checked out files using full @@ -571,12 +571,12 @@ def commit(ui, repo, *pats, **opts): def copy(ui, repo, *pats, **opts): """mark files as copied for the next commit - Mark dest as having copies of source files. If dest is a - directory, copies are put in that directory. If dest is a file, + Mark dest as having copies of source files. If dest is a + directory, copies are put in that directory. If dest is a file, there can only be one source. By default, this command copies the contents of files as they - stand in the working directory. If invoked with --after, the + stand in the working directory. If invoked with --after, the operation is recorded, but no copying is performed. This command takes effect in the next commit. To undo a copy @@ -963,7 +963,7 @@ def export(ui, repo, *changesets, **opts as it will compare the merge changeset against its first parent only. Output may be to a file, in which case the name of the file is - given using a format string. The formatting rules are as follows: + given using a format string. The formatting rules are as follows: %% literal "%" character %H changeset hash (40 bytes of hexadecimal) @@ -997,13 +997,13 @@ def grep(ui, repo, pattern, *pats, **opt Search revisions of files for a regular expression. - This command behaves differently than Unix grep. It only accepts - Python/Perl regexps. It searches repository history, not the - working directory. It always prints the revision number in which + This command behaves differently than Unix grep. It only accepts + Python/Perl regexps. It searches repository history, not the + working directory. It always prints the revision number in which a match appears. By default, grep only prints output for the first revision of a - file in which it finds a match. To get it to print every revision + file in which it finds a match. To get it to print every revision that contains a change in match status ("-" for a match that becomes a non-match, or "+" for a non-match that becomes a match), use the --all flag. @@ -1173,7 +1173,7 @@ def heads(ui, repo, *branchrevs, **opts) are the usual targets for update and merge operations. Branch heads are changesets that have a given branch tag, but have - no child changesets with that tag. They are usually where + no child changesets with that tag. They are usually where development on the given branch takes place. """ if opts['rev']: @@ -1466,15 +1466,15 @@ def import_(ui, repo, patch1, *patches, If there are outstanding changes in the working directory, import will abort unless given the -f flag. - You can import a patch straight from a mail message. Even patches + You can import a patch straight from a mail message. Even patches as attachments work (body part must be type text/plain or - text/x-patch to be used). From and Subject headers of email - message are used as default committer and commit message. All + text/x-patch to be used). From and Subject headers of email + message are used as default committer and commit message. All text/plain body parts before first diff are added to commit message. If the imported patch was generated by hg export, user and description - from patch override values from message headers and body. Values + from patch override values from message headers and body. Values given on command line with -m and -u override these. If --exact is specified, import will set the working directory @@ -1643,7 +1643,7 @@ def incoming(ui, repo, source="default", def init(ui, dest=".", **opts): """create a new repository in the given directory - Initialize a new repository in the given directory. If the given + Initialize a new repository in the given directory. If the given directory does not exist, it is created. If no directory is given, the current directory is used. @@ -1661,7 +1661,7 @@ def locate(ui, repo, *pats, **opts): Print all files under Mercurial control whose names match the given patterns. - This command searches the entire repository by default. To search + This command searches the entire repository by default. To search just the current directory and its subdirectories, use "--include .". @@ -1703,7 +1703,7 @@ def log(ui, repo, *pats, **opts): project. File history is shown without following rename or copy history of - files. Use -f/--follow with a file name to follow history across + files. Use -f/--follow with a file name to follow history across renames and copies. --follow without a file name will only show ancestors or descendants of the starting revision. --follow-first only follows the first parent of merge revisions. @@ -1862,7 +1862,7 @@ def merge(ui, repo, node=None, force=Non If no revision is specified, the working directory's parent is a head revision, and the repository contains exactly one other head, - the other head is merged with by default. Otherwise, an explicit + the other head is merged with by default. Otherwise, an explicit revision to merge with must be provided. """ @@ -1973,7 +1973,7 @@ def paths(ui, repo, search=None): definition of available names. Path names are defined in the [paths] section of /etc/mercurial/hgrc - and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too. + and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too. """ if search: for name, path in ui.configitems("paths"): @@ -2214,12 +2214,12 @@ def remove(ui, repo, *pats, **opts): def rename(ui, repo, *pats, **opts): """rename files; equivalent of copy + remove - Mark dest as copies of sources; mark sources for deletion. If - dest is a directory, copies are put in that directory. If dest is + Mark dest as copies of sources; mark sources for deletion. If + dest is a directory, copies are put in that directory. If dest is a file, there can only be one source. By default, this command copies the contents of files as they - stand in the working directory. If invoked with --after, the + stand in the working directory. If invoked with --after, the operation is recorded, but no copying is performed. This command takes effect in the next commit. To undo a rename @@ -2249,13 +2249,13 @@ def revert(ui, repo, *pats, **opts): back" some or all of an earlier change. See 'hg help dates' for a list of formats valid for -d/--date. - Revert modifies the working directory. It does not commit any - changes, or change the parent of the working directory. If you + Revert modifies the working directory. It does not commit any + changes, or change the parent of the working directory. If you revert to a revision other than the parent of the working directory, the reverted files will thus appear modified afterwards. - If a file has been deleted, it is restored. If the executable + If a file has been deleted, it is restored. If the executable mode of a file was changed, it is reset. If names are given, all files matching the names are reverted. @@ -2491,7 +2491,7 @@ def serve(ui, repo, **opts): Start a local HTTP repository browser and pull server. By default, the server logs accesses to stdout and errors to - stderr. Use the "-A" and "-E" options to log to files. + stderr. Use the "-A" and "-E" options to log to files. """ if opts["stdio"]: @@ -2530,8 +2530,17 @@ def serve(ui, repo, **opts): if port == ':80': port = '' - ui.status(_('listening at http://%s%s/%s (%s:%d)\n') % - (self.httpd.fqaddr, port, prefix, self.httpd.addr, self.httpd.port)) + bindaddr = self.httpd.addr + if bindaddr == '0.0.0.0': + bindaddr = '*' + elif ':' in bindaddr: # IPv6 + bindaddr = '[%s]' % bindaddr + + fqaddr = self.httpd.fqaddr + if ':' in fqaddr: + fqaddr = '[%s]' % fqaddr + ui.status(_('listening at http://%s%s/%s (bound to %s:%d)\n') % + (fqaddr, port, prefix, bindaddr, self.httpd.port)) def run(self): self.httpd.serve_forever() @@ -2543,10 +2552,10 @@ def serve(ui, repo, **opts): def status(ui, repo, *pats, **opts): """show changed files in the working directory - Show status of files in the repository. If names are given, only - files that match are shown. Files that are clean or ignored or + Show status of files in the repository. If names are given, only + files that match are shown. Files that are clean or ignored or source of a copy/move operation, are not listed unless -c (clean), - -i (ignored), -C (copies) or -A is given. Unless options described + -i (ignored), -C (copies) or -A is given. Unless options described with "show only ..." are given, the options -mardu are used. Option -q/--quiet hides untracked (unknown and ignored) files @@ -2646,7 +2655,7 @@ def tag(ui, repo, name1, *names, **opts) To facilitate version control, distribution, and merging of tags, they are stored as a file named ".hgtags" which is managed similarly to other project files and can be hand-edited if - necessary. The file '.hg/localtags' is used for local tags (not + necessary. The file '.hg/localtags' is used for local tags (not shared among repositories). See 'hg help dates' for a list of formats valid for -d/--date. diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -6,16 +6,15 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, mimetypes, re, mimetools, cStringIO -from mercurial.node import hex, nullid, short +import os, mimetypes +from mercurial.node import hex, nullid from mercurial.repo import RepoError -from mercurial import mdiff, ui, hg, util, archival, patch, hook +from mercurial import mdiff, ui, hg, util, patch, hook from mercurial import revlog, templater, templatefilters, changegroup -from common import get_mtime, style_map, paritygen, countgen, get_contact -from common import ErrorResponse +from common import get_mtime, style_map, paritygen, countgen, ErrorResponse from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR from request import wsgirequest -import webcommands, protocol +import webcommands, protocol, webutil shortcuts = { 'cl': [('cmd', ['changelog']), ('rev', None)], @@ -32,54 +31,6 @@ shortcuts = { 'static': [('cmd', ['static']), ('file', None)] } -def _up(p): - if p[0] != "/": - p = "/" + p - if p[-1] == "/": - p = p[:-1] - up = os.path.dirname(p) - if up == "/": - return "/" - return up + "/" - -def revnavgen(pos, pagelen, limit, nodefunc): - def seq(factor, limit=None): - if limit: - yield limit - if limit >= 20 and limit <= 40: - yield 50 - else: - yield 1 * factor - yield 3 * factor - for f in seq(factor * 10): - yield f - - def nav(**map): - l = [] - last = 0 - for f in seq(1, pagelen): - if f < pagelen or f <= last: - continue - if f > limit: - break - last = f - if pos + f < limit: - l.append(("+%d" % f, hex(nodefunc(pos + f).node()))) - if pos - f >= 0: - l.insert(0, ("-%d" % f, hex(nodefunc(pos - f).node()))) - - try: - yield {"label": "(0)", "node": hex(nodefunc('0').node())} - - for label, node in l: - yield {"label": label, "node": node} - - yield {"label": "tip", "node": "tip"} - except RepoError: - pass - - return nav - class hgweb(object): def __init__(self, repo, name=None): if isinstance(repo, str): @@ -226,17 +177,8 @@ class hgweb(object): try: tmpl = self.templater(req) - try: - ctype = tmpl('mimetype', encoding=self.encoding) - ctype = templater.stringify(ctype) - except KeyError: - # old templates with inline HTTP headers? - if 'mimetype' in tmpl: - raise - header = tmpl('header', encoding=self.encoding) - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - ctype = msg['content-type'] + ctype = tmpl('mimetype', encoding=self.encoding) + ctype = templater.stringify(ctype) if cmd == '': req.form['cmd'] = [tmpl.cache['default']] @@ -291,13 +233,7 @@ class hgweb(object): # some functions for the templater def header(**map): - header = tmpl('header', encoding=self.encoding, **map) - if 'mimetype' not in tmpl: - # old template with inline HTTP headers - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - header = header_file.read() - yield header + yield tmpl('header', encoding=self.encoding, **map) def footer(**map): yield tmpl("footer", **map) @@ -355,54 +291,6 @@ class hgweb(object): if len(files) > self.maxfiles: yield tmpl("fileellipses") - def siblings(self, siblings=[], hiderev=None, **args): - siblings = [s for s in siblings if s.node() != nullid] - if len(siblings) == 1 and siblings[0].rev() == hiderev: - return - for s in siblings: - d = {'node': hex(s.node()), 'rev': s.rev()} - if hasattr(s, 'path'): - d['file'] = s.path() - d.update(args) - yield d - - def renamelink(self, fl, node): - r = fl.renamed(node) - if r: - return [dict(file=r[0], node=hex(r[1]))] - return [] - - def nodetagsdict(self, node): - return [{"name": i} for i in self.repo.nodetags(node)] - - def nodebranchdict(self, ctx): - branches = [] - branch = ctx.branch() - # If this is an empty repo, ctx.node() == nullid, - # ctx.branch() == 'default', but branchtags() is - # an empty dict. Using dict.get avoids a traceback. - if self.repo.branchtags().get(branch) == ctx.node(): - branches.append({"name": branch}) - return branches - - def nodeinbranch(self, ctx): - branches = [] - branch = ctx.branch() - if branch != 'default' and self.repo.branchtags().get(branch) != ctx.node(): - branches.append({"name": branch}) - return branches - - def nodebranchnodefault(self, ctx): - branches = [] - branch = ctx.branch() - if branch != 'default': - branches.append({"name": branch}) - return branches - - def showtag(self, tmpl, t1, node=nullid, **args): - for t in self.repo.nodetags(node): - yield tmpl(t1, tag=t, **args) - def diff(self, tmpl, node1, node2, files): def filterfiles(filters, files): l = [x for x in files if x in filters] @@ -470,514 +358,12 @@ class hgweb(object): yield diffblock(mdiff.unidiff(to, date1, tn, date2, f, f, opts=diffopts), f, tn) - def changelog(self, tmpl, ctx, shortlog=False): - def changelist(limit=0,**map): - cl = self.repo.changelog - l = [] # build a list in forward order for efficiency - for i in xrange(start, end): - ctx = self.repo.changectx(i) - n = ctx.node() - showtags = self.showtag(tmpl, 'changelogtag', n) - - l.insert(0, {"parity": parity.next(), - "author": ctx.user(), - "parent": self.siblings(ctx.parents(), i - 1), - "child": self.siblings(ctx.children(), i + 1), - "changelogtag": showtags, - "desc": ctx.description(), - "date": ctx.date(), - "files": self.listfilediffs(tmpl, ctx.files(), n), - "rev": i, - "node": hex(n), - "tags": self.nodetagsdict(n), - "inbranch": self.nodeinbranch(ctx), - "branches": self.nodebranchdict(ctx)}) - - if limit > 0: - l = l[:limit] - - for e in l: - yield e - - maxchanges = shortlog and self.maxshortchanges or self.maxchanges - cl = self.repo.changelog - count = cl.count() - pos = ctx.rev() - start = max(0, pos - maxchanges + 1) - end = min(count, start + maxchanges) - pos = end - 1 - parity = paritygen(self.stripecount, offset=start-end) - - changenav = revnavgen(pos, maxchanges, count, self.repo.changectx) - - return tmpl(shortlog and 'shortlog' or 'changelog', - changenav=changenav, - node=hex(cl.tip()), - rev=pos, changesets=count, - entries=lambda **x: changelist(limit=0,**x), - latestentry=lambda **x: changelist(limit=1,**x), - archives=self.archivelist("tip")) - - def search(self, tmpl, query): - - def changelist(**map): - cl = self.repo.changelog - count = 0 - qw = query.lower().split() - - def revgen(): - for i in xrange(cl.count() - 1, 0, -100): - l = [] - for j in xrange(max(0, i - 100), i + 1): - ctx = self.repo.changectx(j) - l.append(ctx) - l.reverse() - for e in l: - yield e - - for ctx in revgen(): - miss = 0 - for q in qw: - if not (q in ctx.user().lower() or - q in ctx.description().lower() or - q in " ".join(ctx.files()).lower()): - miss = 1 - break - if miss: - continue - - count += 1 - n = ctx.node() - showtags = self.showtag(tmpl, 'changelogtag', n) - - yield tmpl('searchentry', - parity=parity.next(), - author=ctx.user(), - parent=self.siblings(ctx.parents()), - child=self.siblings(ctx.children()), - changelogtag=showtags, - desc=ctx.description(), - date=ctx.date(), - files=self.listfilediffs(tmpl, ctx.files(), n), - rev=ctx.rev(), - node=hex(n), - tags=self.nodetagsdict(n), - inbranch=self.nodeinbranch(ctx), - branches=self.nodebranchdict(ctx)) - - if count >= self.maxchanges: - break - - cl = self.repo.changelog - parity = paritygen(self.stripecount) - - return tmpl('search', - query=query, - node=hex(cl.tip()), - entries=changelist, - archives=self.archivelist("tip")) - - def changeset(self, tmpl, ctx): - n = ctx.node() - showtags = self.showtag(tmpl, 'changesettag', n) - parents = ctx.parents() - p1 = parents[0].node() - - files = [] - parity = paritygen(self.stripecount) - for f in ctx.files(): - files.append(tmpl("filenodelink", - node=hex(n), file=f, - parity=parity.next())) - - def diff(**map): - yield self.diff(tmpl, p1, n, None) - - return tmpl('changeset', - diff=diff, - rev=ctx.rev(), - node=hex(n), - parent=self.siblings(parents), - child=self.siblings(ctx.children()), - changesettag=showtags, - author=ctx.user(), - desc=ctx.description(), - date=ctx.date(), - files=files, - archives=self.archivelist(hex(n)), - tags=self.nodetagsdict(n), - branch=self.nodebranchnodefault(ctx), - inbranch=self.nodeinbranch(ctx), - branches=self.nodebranchdict(ctx)) - - def filelog(self, tmpl, fctx): - f = fctx.path() - fl = fctx.filelog() - count = fl.count() - pagelen = self.maxshortchanges - pos = fctx.filerev() - start = max(0, pos - pagelen + 1) - end = min(count, start + pagelen) - pos = end - 1 - parity = paritygen(self.stripecount, offset=start-end) - - def entries(limit=0, **map): - l = [] - - for i in xrange(start, end): - ctx = fctx.filectx(i) - n = fl.node(i) - - l.insert(0, {"parity": parity.next(), - "filerev": i, - "file": f, - "node": hex(ctx.node()), - "author": ctx.user(), - "date": ctx.date(), - "rename": self.renamelink(fl, n), - "parent": self.siblings(fctx.parents()), - "child": self.siblings(fctx.children()), - "desc": ctx.description()}) - - if limit > 0: - l = l[:limit] - - for e in l: - yield e - - nodefunc = lambda x: fctx.filectx(fileid=x) - nav = revnavgen(pos, pagelen, count, nodefunc) - return tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav, - entries=lambda **x: entries(limit=0, **x), - latestentry=lambda **x: entries(limit=1, **x)) - - def filerevision(self, tmpl, fctx): - f = fctx.path() - text = fctx.data() - fl = fctx.filelog() - n = fctx.filenode() - parity = paritygen(self.stripecount) - - if util.binary(text): - mt = mimetypes.guess_type(f)[0] or 'application/octet-stream' - text = '(binary:%s)' % mt - - def lines(): - for lineno, t in enumerate(text.splitlines(1)): - yield {"line": t, - "lineid": "l%d" % (lineno + 1), - "linenumber": "% 6d" % (lineno + 1), - "parity": parity.next()} - - return tmpl("filerevision", - file=f, - path=_up(f), - text=lines(), - rev=fctx.rev(), - node=hex(fctx.node()), - author=fctx.user(), - date=fctx.date(), - desc=fctx.description(), - branch=self.nodebranchnodefault(fctx), - parent=self.siblings(fctx.parents()), - child=self.siblings(fctx.children()), - rename=self.renamelink(fl, n), - permissions=fctx.manifest().flags(f)) - - def fileannotate(self, tmpl, fctx): - f = fctx.path() - n = fctx.filenode() - fl = fctx.filelog() - parity = paritygen(self.stripecount) - - def annotate(**map): - last = None - if util.binary(fctx.data()): - mt = (mimetypes.guess_type(fctx.path())[0] - or 'application/octet-stream') - lines = enumerate([((fctx.filectx(fctx.filerev()), 1), - '(binary:%s)' % mt)]) - else: - lines = enumerate(fctx.annotate(follow=True, linenumber=True)) - for lineno, ((f, targetline), l) in lines: - fnode = f.filenode() - name = self.repo.ui.shortuser(f.user()) - - if last != fnode: - last = fnode - - yield {"parity": parity.next(), - "node": hex(f.node()), - "rev": f.rev(), - "author": name, - "file": f.path(), - "targetline": targetline, - "line": l, - "lineid": "l%d" % (lineno + 1), - "linenumber": "% 6d" % (lineno + 1)} - - return tmpl("fileannotate", - file=f, - annotate=annotate, - path=_up(f), - rev=fctx.rev(), - node=hex(fctx.node()), - author=fctx.user(), - date=fctx.date(), - desc=fctx.description(), - rename=self.renamelink(fl, n), - branch=self.nodebranchnodefault(fctx), - parent=self.siblings(fctx.parents()), - child=self.siblings(fctx.children()), - permissions=fctx.manifest().flags(f)) - - def manifest(self, tmpl, ctx, path): - mf = ctx.manifest() - node = ctx.node() - - files = {} - parity = paritygen(self.stripecount) - - if path and path[-1] != "/": - path += "/" - l = len(path) - abspath = "/" + path - - for f, n in mf.items(): - if f[:l] != path: - continue - remain = f[l:] - if "/" in remain: - short = remain[:remain.index("/") + 1] # bleah - files[short] = (f, None) - else: - short = os.path.basename(remain) - files[short] = (f, n) - - if not files: - raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path) - - def filelist(**map): - fl = files.keys() - fl.sort() - for f in fl: - full, fnode = files[f] - if not fnode: - continue - - fctx = ctx.filectx(full) - yield {"file": full, - "parity": parity.next(), - "basename": f, - "date": fctx.changectx().date(), - "size": fctx.size(), - "permissions": mf.flags(full)} - - def dirlist(**map): - fl = files.keys() - fl.sort() - for f in fl: - full, fnode = files[f] - if fnode: - continue - - yield {"parity": parity.next(), - "path": "%s%s" % (abspath, f), - "basename": f[:-1]} - - return tmpl("manifest", - rev=ctx.rev(), - node=hex(node), - path=abspath, - up=_up(abspath), - upparity=parity.next(), - fentries=filelist, - dentries=dirlist, - archives=self.archivelist(hex(node)), - tags=self.nodetagsdict(node), - inbranch=self.nodeinbranch(ctx), - branches=self.nodebranchdict(ctx)) - - def tags(self, tmpl): - i = self.repo.tagslist() - i.reverse() - parity = paritygen(self.stripecount) - - def entries(notip=False,limit=0, **map): - count = 0 - for k, n in i: - if notip and k == "tip": - continue - if limit > 0 and count >= limit: - continue - count = count + 1 - yield {"parity": parity.next(), - "tag": k, - "date": self.repo.changectx(n).date(), - "node": hex(n)} - - return tmpl("tags", - node=hex(self.repo.changelog.tip()), - entries=lambda **x: entries(False,0, **x), - entriesnotip=lambda **x: entries(True,0, **x), - latestentry=lambda **x: entries(True,1, **x)) - - def summary(self, tmpl): - i = self.repo.tagslist() - i.reverse() - - def tagentries(**map): - parity = paritygen(self.stripecount) - count = 0 - for k, n in i: - if k == "tip": # skip tip - continue; - - count += 1 - if count > 10: # limit to 10 tags - break; - - yield tmpl("tagentry", - parity=parity.next(), - tag=k, - node=hex(n), - date=self.repo.changectx(n).date()) - - - def branches(**map): - parity = paritygen(self.stripecount) - - b = self.repo.branchtags() - l = [(-self.repo.changelog.rev(n), n, t) for t, n in b.items()] - l.sort() - - for r,n,t in l: - ctx = self.repo.changectx(n) - - yield {'parity': parity.next(), - 'branch': t, - 'node': hex(n), - 'date': ctx.date()} - - def changelist(**map): - parity = paritygen(self.stripecount, offset=start-end) - l = [] # build a list in forward order for efficiency - for i in xrange(start, end): - ctx = self.repo.changectx(i) - n = ctx.node() - hn = hex(n) - - l.insert(0, tmpl( - 'shortlogentry', - parity=parity.next(), - author=ctx.user(), - desc=ctx.description(), - date=ctx.date(), - rev=i, - node=hn, - tags=self.nodetagsdict(n), - inbranch=self.nodeinbranch(ctx), - branches=self.nodebranchdict(ctx))) - - yield l - - cl = self.repo.changelog - count = cl.count() - start = max(0, count - self.maxchanges) - end = min(count, start + self.maxchanges) - - return tmpl("summary", - desc=self.config("web", "description", "unknown"), - owner=get_contact(self.config) or "unknown", - lastchange=cl.read(cl.tip())[2], - tags=tagentries, - branches=branches, - shortlog=changelist, - node=hex(cl.tip()), - archives=self.archivelist("tip")) - - def filediff(self, tmpl, fctx): - n = fctx.node() - path = fctx.path() - parents = fctx.parents() - p1 = parents and parents[0].node() or nullid - - def diff(**map): - yield self.diff(tmpl, p1, n, [path]) - - return tmpl("filediff", - file=path, - node=hex(n), - rev=fctx.rev(), - branch=self.nodebranchnodefault(fctx), - parent=self.siblings(parents), - child=self.siblings(fctx.children()), - diff=diff) - archive_specs = { 'bz2': ('application/x-tar', 'tbz2', '.tar.bz2', None), 'gz': ('application/x-tar', 'tgz', '.tar.gz', None), 'zip': ('application/zip', 'zip', '.zip', None), } - def archive(self, tmpl, req, key, type_): - reponame = re.sub(r"\W+", "-", os.path.basename(self.reponame)) - cnode = self.repo.lookup(key) - arch_version = key - if cnode == key or key == 'tip': - arch_version = short(cnode) - name = "%s-%s" % (reponame, arch_version) - mimetype, artype, extension, encoding = self.archive_specs[type_] - headers = [ - ('Content-Type', mimetype), - ('Content-Disposition', 'attachment; filename=%s%s' % - (name, extension)) - ] - if encoding: - headers.append(('Content-Encoding', encoding)) - req.header(headers) - req.respond(HTTP_OK) - archival.archive(self.repo, req, cnode, artype, prefix=name) - - # add tags to things - # tags -> list of changesets corresponding to tags - # find tag, changeset, file - - def cleanpath(self, path): - path = path.lstrip('/') - return util.canonpath(self.repo.root, '', path) - - def changectx(self, req): - if 'node' in req.form: - changeid = req.form['node'][0] - elif 'manifest' in req.form: - changeid = req.form['manifest'][0] - else: - changeid = self.repo.changelog.count() - 1 - - try: - ctx = self.repo.changectx(changeid) - except RepoError: - man = self.repo.manifest - mn = man.lookup(changeid) - ctx = self.repo.changectx(man.linkrev(mn)) - - return ctx - - def filectx(self, req): - path = self.cleanpath(req.form['file'][0]) - if 'node' in req.form: - changeid = req.form['node'][0] - else: - changeid = req.form['filenode'][0] - try: - ctx = self.repo.changectx(changeid) - fctx = ctx.filectx(path) - except RepoError: - fctx = self.repo.filectx(path, fileid=changeid) - - return fctx - def check_perm(self, req, op, default): '''check permission for operation based on user auth. return true if op allowed, else false. diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -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, mimetools, cStringIO +import os from mercurial.i18n import gettext as _ from mercurial.repo import RepoError from mercurial import ui, hg, util, templater, templatefilters @@ -81,17 +81,8 @@ class hgwebdir(object): virtual = req.env.get("PATH_INFO", "").strip('/') tmpl = self.templater(req) - try: - ctype = tmpl('mimetype', encoding=util._encoding) - ctype = templater.stringify(ctype) - except KeyError: - # old templates with inline HTTP headers? - if 'mimetype' in tmpl: - raise - header = tmpl('header', encoding=util._encoding) - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - ctype = msg['content-type'] + ctype = tmpl('mimetype', encoding=util._encoding) + ctype = templater.stringify(ctype) # a static file if virtual.startswith('static/') or 'static' in req.form: @@ -255,13 +246,7 @@ class hgwebdir(object): def templater(self, req): def header(**map): - header = tmpl('header', encoding=util._encoding, **map) - if 'mimetype' not in tmpl: - # old template with inline HTTP headers - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - header = header_file.read() - yield header + yield tmpl('header', encoding=util._encoding, **map) def footer(**map): yield tmpl("footer", **map) diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py --- a/mercurial/hgweb/server.py +++ b/mercurial/hgweb/server.py @@ -268,12 +268,7 @@ def create_server(ui, repo): self.addr, self.port = self.socket.getsockname()[0:2] self.prefix = prefix - self.fqaddr = socket.getfqdn(address) - try: - socket.getaddrbyhost(self.fqaddr) - except: - fqaddr = address class IPv6HTTPServer(MercurialHTTPServer): address_family = getattr(socket, 'AF_INET6', None) diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -5,10 +5,14 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, mimetypes -from mercurial import revlog, util +import os, mimetypes, re +import webutil +from mercurial import revlog, archival +from mercurial.node import short, hex, nullid +from mercurial.util import binary from mercurial.repo import RepoError -from common import staticfile, ErrorResponse, HTTP_OK, HTTP_NOT_FOUND +from common import paritygen, staticfile, get_contact, ErrorResponse +from common import HTTP_OK, HTTP_NOT_FOUND # __all__ is populated with the allowed commands. Be sure to add to it if # you're adding a new command, or the new command won't work. @@ -26,17 +30,17 @@ def log(web, req, tmpl): return changelog(web, req, tmpl) def rawfile(web, req, tmpl): - path = web.cleanpath(req.form.get('file', [''])[0]) + path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0]) if not path: - content = web.manifest(tmpl, web.changectx(req), path) + content = manifest(web, req, tmpl) req.respond(HTTP_OK, web.ctype) return content try: - fctx = web.filectx(req) + fctx = webutil.filectx(web.repo, req) except revlog.LookupError, inst: try: - content = web.manifest(tmpl, web.changectx(req), path) + content = manifest(web, req, tmpl) req.respond(HTTP_OK, web.ctype) return content except ErrorResponse: @@ -45,28 +49,120 @@ def rawfile(web, req, tmpl): path = fctx.path() text = fctx.data() mt = mimetypes.guess_type(path)[0] - if mt is None or util.binary(text): + if mt is None or binary(text): mt = mt or 'application/octet-stream' req.respond(HTTP_OK, mt, path, len(text)) return [text] +def _filerevision(web, tmpl, fctx): + f = fctx.path() + text = fctx.data() + fl = fctx.filelog() + n = fctx.filenode() + parity = paritygen(web.stripecount) + + if binary(text): + mt = mimetypes.guess_type(f)[0] or 'application/octet-stream' + text = '(binary:%s)' % mt + + def lines(): + for lineno, t in enumerate(text.splitlines(1)): + yield {"line": t, + "lineid": "l%d" % (lineno + 1), + "linenumber": "% 6d" % (lineno + 1), + "parity": parity.next()} + + return tmpl("filerevision", + file=f, + path=webutil.up(f), + text=lines(), + rev=fctx.rev(), + node=hex(fctx.node()), + author=fctx.user(), + date=fctx.date(), + desc=fctx.description(), + branch=webutil.nodebranchnodefault(fctx), + parent=webutil.siblings(fctx.parents()), + child=webutil.siblings(fctx.children()), + rename=webutil.renamelink(fctx), + permissions=fctx.manifest().flags(f)) + def file(web, req, tmpl): - path = web.cleanpath(req.form.get('file', [''])[0]) + path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0]) if path: try: - return web.filerevision(tmpl, web.filectx(req)) + return _filerevision(web, tmpl, webutil.filectx(web.repo, req)) except revlog.LookupError, inst: pass try: - return web.manifest(tmpl, web.changectx(req), path) + return manifest(web, req, tmpl) except ErrorResponse: raise inst +def _search(web, tmpl, query): + + def changelist(**map): + cl = web.repo.changelog + count = 0 + qw = query.lower().split() + + def revgen(): + for i in xrange(cl.count() - 1, 0, -100): + l = [] + for j in xrange(max(0, i - 100), i + 1): + ctx = web.repo.changectx(j) + l.append(ctx) + l.reverse() + for e in l: + yield e + + for ctx in revgen(): + miss = 0 + for q in qw: + if not (q in ctx.user().lower() or + q in ctx.description().lower() or + q in " ".join(ctx.files()).lower()): + miss = 1 + break + if miss: + continue + + count = 1 + n = ctx.node() + showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) + + yield tmpl('searchentry', + parity=parity.next(), + author=ctx.user(), + parent=webutil.siblings(ctx.parents()), + child=webutil.siblings(ctx.children()), + changelogtag=showtags, + desc=ctx.description(), + date=ctx.date(), + files=web.listfilediffs(tmpl, ctx.files(), n), + rev=ctx.rev(), + node=hex(n), + tags=webutil.nodetagsdict(web.repo, n), + inbranch=webutil.nodeinbranch(web.repo, ctx), + branches=webutil.nodebranchdict(web.repo, ctx)) + + if count >= web.maxchanges: + break + + cl = web.repo.changelog + parity = paritygen(web.stripecount) + + return tmpl('search', + query=query, + node=hex(cl.tip()), + entries=changelist, + archives=web.archivelist("tip")) + def changelog(web, req, tmpl, shortlog = False): if 'node' in req.form: - ctx = web.changectx(req) + ctx = webutil.changectx(web.repo, req) else: if 'rev' in req.form: hi = req.form['rev'][0] @@ -75,47 +171,400 @@ def changelog(web, req, tmpl, shortlog = try: ctx = web.repo.changectx(hi) except RepoError: - return web.search(tmpl, hi) # XXX redirect to 404 page? + return _search(web, tmpl, hi) # XXX redirect to 404 page? + + def changelist(limit=0, **map): + cl = web.repo.changelog + l = [] # build a list in forward order for efficiency + for i in xrange(start, end): + ctx = web.repo.changectx(i) + n = ctx.node() + showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) + + l.insert(0, {"parity": parity.next(), + "author": ctx.user(), + "parent": webutil.siblings(ctx.parents(), i - 1), + "child": webutil.siblings(ctx.children(), i + 1), + "changelogtag": showtags, + "desc": ctx.description(), + "date": ctx.date(), + "files": web.listfilediffs(tmpl, ctx.files(), n), + "rev": i, + "node": hex(n), + "tags": webutil.nodetagsdict(web.repo, n), + "inbranch": webutil.nodeinbranch(web.repo, ctx), + "branches": webutil.nodebranchdict(web.repo, ctx) + }) - return web.changelog(tmpl, ctx, shortlog = shortlog) + if limit > 0: + l = l[:limit] + + for e in l: + yield e + + maxchanges = shortlog and web.maxshortchanges or web.maxchanges + cl = web.repo.changelog + count = cl.count() + pos = ctx.rev() + start = max(0, pos - maxchanges + 1) + end = min(count, start + maxchanges) + pos = end - 1 + parity = paritygen(web.stripecount, offset=start-end) + + changenav = webutil.revnavgen(pos, maxchanges, count, web.repo.changectx) + + return tmpl(shortlog and 'shortlog' or 'changelog', + changenav=changenav, + node=hex(ctx.node()), + rev=pos, changesets=count, + entries=lambda **x: changelist(limit=0,**x), + latestentry=lambda **x: changelist(limit=1,**x), + archives=web.archivelist("tip")) def shortlog(web, req, tmpl): return changelog(web, req, tmpl, shortlog = True) def changeset(web, req, tmpl): - return web.changeset(tmpl, web.changectx(req)) + ctx = webutil.changectx(web.repo, req) + n = ctx.node() + showtags = webutil.showtag(web.repo, tmpl, 'changesettag', n) + parents = ctx.parents() + p1 = parents[0].node() + + files = [] + parity = paritygen(web.stripecount) + for f in ctx.files(): + files.append(tmpl("filenodelink", + node=hex(n), file=f, + parity=parity.next())) + + diffs = web.diff(tmpl, p1, n, None) + return tmpl('changeset', + diff=diffs, + rev=ctx.rev(), + node=hex(n), + parent=webutil.siblings(parents), + child=webutil.siblings(ctx.children()), + changesettag=showtags, + author=ctx.user(), + desc=ctx.description(), + date=ctx.date(), + files=files, + archives=web.archivelist(hex(n)), + tags=webutil.nodetagsdict(web.repo, n), + branch=webutil.nodebranchnodefault(ctx), + inbranch=webutil.nodeinbranch(web.repo, ctx), + branches=webutil.nodebranchdict(web.repo, ctx)) rev = changeset def manifest(web, req, tmpl): - return web.manifest(tmpl, web.changectx(req), - web.cleanpath(req.form['path'][0])) + ctx = webutil.changectx(web.repo, req) + path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0]) + mf = ctx.manifest() + node = ctx.node() + + files = {} + parity = paritygen(web.stripecount) + + if path and path[-1] != "/": + path += "/" + l = len(path) + abspath = "/" + path + + for f, n in mf.items(): + if f[:l] != path: + continue + remain = f[l:] + if "/" in remain: + short = remain[:remain.index("/") + 1] # bleah + files[short] = (f, None) + else: + short = os.path.basename(remain) + files[short] = (f, n) + + if not files: + raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path) + + def filelist(**map): + fl = files.keys() + fl.sort() + for f in fl: + full, fnode = files[f] + if not fnode: + continue + + fctx = ctx.filectx(full) + yield {"file": full, + "parity": parity.next(), + "basename": f, + "date": fctx.changectx().date(), + "size": fctx.size(), + "permissions": mf.flags(full)} + + def dirlist(**map): + fl = files.keys() + fl.sort() + for f in fl: + full, fnode = files[f] + if fnode: + continue + + yield {"parity": parity.next(), + "path": "%s%s" % (abspath, f), + "basename": f[:-1]} + + return tmpl("manifest", + rev=ctx.rev(), + node=hex(node), + path=abspath, + up=webutil.up(abspath), + upparity=parity.next(), + fentries=filelist, + dentries=dirlist, + archives=web.archivelist(hex(node)), + tags=webutil.nodetagsdict(web.repo, node), + inbranch=webutil.nodeinbranch(web.repo, ctx), + branches=webutil.nodebranchdict(web.repo, ctx)) def tags(web, req, tmpl): - return web.tags(tmpl) + i = web.repo.tagslist() + i.reverse() + parity = paritygen(web.stripecount) + + def entries(notip=False,limit=0, **map): + count = 0 + for k, n in i: + if notip and k == "tip": + continue + if limit > 0 and count >= limit: + continue + count = count + 1 + yield {"parity": parity.next(), + "tag": k, + "date": web.repo.changectx(n).date(), + "node": hex(n)} + + return tmpl("tags", + node=hex(web.repo.changelog.tip()), + entries=lambda **x: entries(False,0, **x), + entriesnotip=lambda **x: entries(True,0, **x), + latestentry=lambda **x: entries(True,1, **x)) def summary(web, req, tmpl): - return web.summary(tmpl) + i = web.repo.tagslist() + i.reverse() + + def tagentries(**map): + parity = paritygen(web.stripecount) + count = 0 + for k, n in i: + if k == "tip": # skip tip + continue + + count = 1 + if count > 10: # limit to 10 tags + break + + yield tmpl("tagentry", + parity=parity.next(), + tag=k, + node=hex(n), + date=web.repo.changectx(n).date()) + + def branches(**map): + parity = paritygen(web.stripecount) + + b = web.repo.branchtags() + l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.items()] + l.sort() + + for r,n,t in l: + ctx = web.repo.changectx(n) + yield {'parity': parity.next(), + 'branch': t, + 'node': hex(n), + 'date': ctx.date()} + + def changelist(**map): + parity = paritygen(web.stripecount, offset=start-end) + l = [] # build a list in forward order for efficiency + for i in xrange(start, end): + ctx = web.repo.changectx(i) + n = ctx.node() + hn = hex(n) + + l.insert(0, tmpl( + 'shortlogentry', + parity=parity.next(), + author=ctx.user(), + desc=ctx.description(), + date=ctx.date(), + rev=i, + node=hn, + tags=webutil.nodetagsdict(web.repo, n), + inbranch=webutil.nodeinbranch(web.repo, ctx), + branches=webutil.nodebranchdict(web.repo, ctx))) + + yield l + + cl = web.repo.changelog + count = cl.count() + start = max(0, count - web.maxchanges) + end = min(count, start + web.maxchanges) + + return tmpl("summary", + desc=web.config("web", "description", "unknown"), + owner=get_contact(web.config) or "unknown", + lastchange=cl.read(cl.tip())[2], + tags=tagentries, + branches=branches, + shortlog=changelist, + node=hex(cl.tip()), + archives=web.archivelist("tip")) def filediff(web, req, tmpl): - return web.filediff(tmpl, web.filectx(req)) + fctx = webutil.filectx(web.repo, req) + n = fctx.node() + path = fctx.path() + parents = fctx.parents() + p1 = parents and parents[0].node() or nullid + + diffs = web.diff(tmpl, p1, n, [path]) + return tmpl("filediff", + file=path, + node=hex(n), + rev=fctx.rev(), + date=fctx.date(), + desc=fctx.description(), + author=fctx.user(), + rename=webutil.renamelink(fctx), + branch=webutil.nodebranchnodefault(fctx), + parent=webutil.siblings(parents), + child=webutil.siblings(fctx.children()), + diff=diffs) diff = filediff def annotate(web, req, tmpl): - return web.fileannotate(tmpl, web.filectx(req)) + fctx = webutil.filectx(web.repo, req) + f = fctx.path() + n = fctx.filenode() + fl = fctx.filelog() + parity = paritygen(web.stripecount) + + def annotate(**map): + last = None + if binary(fctx.data()): + mt = (mimetypes.guess_type(fctx.path())[0] + or 'application/octet-stream') + lines = enumerate([((fctx.filectx(fctx.filerev()), 1), + '(binary:%s)' % mt)]) + else: + lines = enumerate(fctx.annotate(follow=True, linenumber=True)) + for lineno, ((f, targetline), l) in lines: + fnode = f.filenode() + name = web.repo.ui.shortuser(f.user()) + + if last != fnode: + last = fnode + + yield {"parity": parity.next(), + "node": hex(f.node()), + "rev": f.rev(), + "author": name, + "file": f.path(), + "targetline": targetline, + "line": l, + "lineid": "l%d" % (lineno + 1), + "linenumber": "% 6d" % (lineno + 1)} + + return tmpl("fileannotate", + file=f, + annotate=annotate, + path=webutil.up(f), + rev=fctx.rev(), + node=hex(fctx.node()), + author=fctx.user(), + date=fctx.date(), + desc=fctx.description(), + rename=webutil.renamelink(fctx), + branch=webutil.nodebranchnodefault(fctx), + parent=webutil.siblings(fctx.parents()), + child=webutil.siblings(fctx.children()), + permissions=fctx.manifest().flags(f)) def filelog(web, req, tmpl): - return web.filelog(tmpl, web.filectx(req)) + fctx = webutil.filectx(web.repo, req) + f = fctx.path() + fl = fctx.filelog() + count = fl.count() + pagelen = web.maxshortchanges + pos = fctx.filerev() + start = max(0, pos - pagelen + 1) + end = min(count, start + pagelen) + pos = end - 1 + parity = paritygen(web.stripecount, offset=start-end) + + def entries(limit=0, **map): + l = [] + + for i in xrange(start, end): + ctx = fctx.filectx(i) + n = fl.node(i) + + l.insert(0, {"parity": parity.next(), + "filerev": i, + "file": f, + "node": hex(ctx.node()), + "author": ctx.user(), + "date": ctx.date(), + "rename": webutil.renamelink(fctx), + "parent": webutil.siblings(fctx.parents()), + "child": webutil.siblings(fctx.children()), + "desc": ctx.description()}) + + if limit > 0: + l = l[:limit] + + for e in l: + yield e + + nodefunc = lambda x: fctx.filectx(fileid=x) + nav = webutil.revnavgen(pos, pagelen, count, nodefunc) + return tmpl("filelog", file=f, node=hex(fctx.node()), nav=nav, + entries=lambda **x: entries(limit=0, **x), + latestentry=lambda **x: entries(limit=1, **x)) + def archive(web, req, tmpl): type_ = req.form['type'][0] allowed = web.configlist("web", "allow_archive") - if (type_ in web.archives and (type_ in allowed or + key = req.form['node'][0] + + if not (type_ in web.archives and (type_ in allowed or web.configbool("web", "allow" + type_, False))): - web.archive(tmpl, req, req.form['node'][0], type_) - return [] - raise ErrorResponse(HTTP_NOT_FOUND, 'unsupported archive type: %s' % type_) + msg = 'Unsupported archive type: %s' % type_ + raise ErrorResponse(HTTP_NOT_FOUND, msg) + + reponame = re.sub(r"\W+", "-", os.path.basename(web.reponame)) + cnode = web.repo.lookup(key) + arch_version = key + if cnode == key or key == 'tip': + arch_version = short(cnode) + name = "%s-%s" % (reponame, arch_version) + mimetype, artype, extension, encoding = web.archive_specs[type_] + headers = [ + ('Content-Type', mimetype), + ('Content-Disposition', 'attachment; filename=%s%s' % (name, extension)) + ] + if encoding: + headers.append(('Content-Encoding', encoding)) + req.header(headers) + req.respond(HTTP_OK) + archival.archive(web.repo, req, cnode, artype, prefix=name) + return [] + def static(web, req, tmpl): fname = req.form['file'][0] diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py new file mode 100644 --- /dev/null +++ b/mercurial/hgweb/webutil.py @@ -0,0 +1,143 @@ +# hgweb/webutil.py - utility library for the web interface. +# +# Copyright 21 May 2005 - (c) 2005 Jake Edge +# Copyright 2005-2007 Matt Mackall +# +# This software may be used and distributed according to the terms +# of the GNU General Public License, incorporated herein by reference. + +import os +from mercurial.node import hex, nullid +from mercurial.repo import RepoError +from mercurial import util + +def up(p): + if p[0] != "/": + p = "/" + p + if p[-1] == "/": + p = p[:-1] + up = os.path.dirname(p) + if up == "/": + return "/" + return up + "/" + +def revnavgen(pos, pagelen, limit, nodefunc): + def seq(factor, limit=None): + if limit: + yield limit + if limit >= 20 and limit <= 40: + yield 50 + else: + yield 1 * factor + yield 3 * factor + for f in seq(factor * 10): + yield f + + def nav(**map): + l = [] + last = 0 + for f in seq(1, pagelen): + if f < pagelen or f <= last: + continue + if f > limit: + break + last = f + if pos + f < limit: + l.append(("+%d" % f, hex(nodefunc(pos + f).node()))) + if pos - f >= 0: + l.insert(0, ("-%d" % f, hex(nodefunc(pos - f).node()))) + + try: + yield {"label": "(0)", "node": hex(nodefunc('0').node())} + + for label, node in l: + yield {"label": label, "node": node} + + yield {"label": "tip", "node": "tip"} + except RepoError: + pass + + return nav + +def siblings(siblings=[], hiderev=None, **args): + siblings = [s for s in siblings if s.node() != nullid] + if len(siblings) == 1 and siblings[0].rev() == hiderev: + return + for s in siblings: + d = {'node': hex(s.node()), 'rev': s.rev()} + if hasattr(s, 'path'): + d['file'] = s.path() + d.update(args) + yield d + +def renamelink(fctx): + r = fctx.renamed() + if r: + return [dict(file=r[0], node=hex(r[1]))] + return [] + +def nodetagsdict(repo, node): + return [{"name": i} for i in repo.nodetags(node)] + +def nodebranchdict(repo, ctx): + branches = [] + branch = ctx.branch() + # If this is an empty repo, ctx.node() == nullid, + # ctx.branch() == 'default', but branchtags() is + # an empty dict. Using dict.get avoids a traceback. + if repo.branchtags().get(branch) == ctx.node(): + branches.append({"name": branch}) + return branches + +def nodeinbranch(repo, ctx): + branches = [] + branch = ctx.branch() + if branch != 'default' and repo.branchtags().get(branch) != ctx.node(): + branches.append({"name": branch}) + return branches + +def nodebranchnodefault(ctx): + branches = [] + branch = ctx.branch() + if branch != 'default': + branches.append({"name": branch}) + return branches + +def showtag(repo, tmpl, t1, node=nullid, **args): + for t in repo.nodetags(node): + yield tmpl(t1, tag=t, **args) + +def cleanpath(repo, path): + path = path.lstrip('/') + return util.canonpath(repo.root, '', path) + +def changectx(repo, req): + if 'node' in req.form: + changeid = req.form['node'][0] + elif 'manifest' in req.form: + changeid = req.form['manifest'][0] + else: + changeid = repo.changelog.count() - 1 + + try: + ctx = repo.changectx(changeid) + except RepoError: + man = repo.manifest + mn = man.lookup(changeid) + ctx = repo.changectx(man.linkrev(mn)) + + return ctx + +def filectx(repo, req): + path = cleanpath(repo, req.form['file'][0]) + if 'node' in req.form: + changeid = req.form['node'][0] + else: + changeid = req.form['filenode'][0] + try: + ctx = repo.changectx(changeid) + fctx = ctx.filectx(path) + except RepoError: + fctx = repo.filectx(path, fileid=changeid) + + return fctx diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -8,7 +8,7 @@ from node import bin, hex, nullid from revlog import revlog, RevlogError from i18n import _ -import array, struct, mdiff +import array, struct, mdiff, parsers class manifestdict(dict): def __init__(self, mapping=None, flags=None): @@ -39,14 +39,7 @@ class manifest(revlog): def parse(self, lines): mfdict = manifestdict() - fdict = mfdict._flags - for l in lines.splitlines(): - f, n = l.split('\0') - if len(n) > 40: - fdict[f] = n[40:] - mfdict[f] = bin(n[:40]) - else: - mfdict[f] = bin(n) + parsers.parse_manifest(mfdict, mfdict._flags, lines) return mfdict def readdelta(self, node): diff --git a/mercurial/parsers.c b/mercurial/parsers.c new file mode 100644 --- /dev/null +++ b/mercurial/parsers.c @@ -0,0 +1,169 @@ +/* + parsers.c - efficient content parsing + + Copyright 2008 Matt Mackall and others + + This software may be used and distributed according to the terms of + the GNU General Public License, incorporated herein by reference. +*/ + +#include +#include +#include + +static int hexdigit(char c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + + if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + + if (c >= 'a' && c <= 'f') + return c - 'a' + 10; + + return -1; +} + +/* + * Turn a hex-encoded string into binary. + */ +static PyObject *unhexlify(const char *str, int len) +{ + PyObject *ret = NULL; + const char *c; + char *d; + + if (len % 2) { + PyErr_SetString(PyExc_ValueError, + "input is not even in length"); + goto bail; + } + + ret = PyString_FromStringAndSize(NULL, len / 2); + if (!ret) + goto bail; + + d = PyString_AsString(ret); + if (!d) + goto bail; + + for (c = str; c < str + len;) { + int hi = hexdigit(*c++); + int lo = hexdigit(*c++); + + if (hi == -1 || lo == -1) { + PyErr_SetString(PyExc_ValueError, + "input contains non-hex character"); + goto bail; + } + + *d++ = (hi << 4) | lo; + } + + goto done; + +bail: + Py_XDECREF(ret); + ret = NULL; +done: + return ret; +} + +/* + * This code assumes that a manifest is stitched together with newline + * ('\n') characters. + */ +static PyObject *parse_manifest(PyObject *self, PyObject *args) +{ + PyObject *mfdict, *fdict; + char *str, *cur, *start, *zero; + int len; + + if (!PyArg_ParseTuple(args, "O!O!s#:parse_manifest", + &PyDict_Type, &mfdict, + &PyDict_Type, &fdict, + &str, &len)) + goto quit; + + for (start = cur = str, zero = NULL; cur < str + len; cur++) { + PyObject *file = NULL, *node = NULL; + PyObject *flags = NULL; + int nlen; + + if (!*cur) { + zero = cur; + continue; + } + else if (*cur != '\n') + continue; + + if (!zero) { + PyErr_SetString(PyExc_ValueError, + "manifest entry has no separator"); + goto quit; + } + + file = PyString_FromStringAndSize(start, zero - start); + if (!file) + goto bail; + + nlen = cur - zero - 1; + + node = unhexlify(zero + 1, nlen > 40 ? 40 : nlen); + if (!node) + goto bail; + + if (nlen > 40) { + PyObject *flags; + + flags = PyString_FromStringAndSize(zero + 41, + nlen - 40); + if (!flags) + goto bail; + + if (PyDict_SetItem(fdict, file, flags) == -1) + goto bail; + } + + if (PyDict_SetItem(mfdict, file, node) == -1) + goto bail; + + start = cur + 1; + zero = NULL; + + Py_XDECREF(flags); + Py_XDECREF(node); + Py_XDECREF(file); + continue; + bail: + Py_XDECREF(flags); + Py_XDECREF(node); + Py_XDECREF(file); + goto quit; + } + + if (len > 0 && *(cur - 1) != '\n') { + PyErr_SetString(PyExc_ValueError, + "manifest contains trailing garbage"); + goto quit; + } + + Py_INCREF(Py_None); + return Py_None; + +quit: + return NULL; +} + +static char parsers_doc[] = "Efficient content parsing."; + +static PyMethodDef methods[] = { + {"parse_manifest", parse_manifest, METH_VARARGS, "parse a manifest\n"}, + {NULL, NULL} +}; + +PyMODINIT_FUNC initparsers(void) +{ + Py_InitModule3("parsers", methods, parsers_doc); +} diff --git a/mercurial/repair.py b/mercurial/repair.py --- a/mercurial/repair.py +++ b/mercurial/repair.py @@ -72,7 +72,6 @@ def _collectextranodes(repo, files, link def strip(ui, repo, node, backup="all"): cl = repo.changelog # TODO delete the undo files, and handle undo of merge sets - pp = cl.parents(node) striprev = cl.rev(node) # Some revisions with rev > striprev may not be descendants of striprev. diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -114,7 +114,7 @@ class templater(object): v = v(**map) if format: if not hasattr(v, '__iter__'): - raise SyntaxError(_("Error expanding '%s%s'") + raise SyntaxError(_("Error expanding '%s%%%s'") % (key, format)) lm = map.copy() for i in v: diff --git a/mercurial/transaction.py b/mercurial/transaction.py --- a/mercurial/transaction.py +++ b/mercurial/transaction.py @@ -96,9 +96,13 @@ def rollback(opener, file): files = {} for l in open(file).readlines(): f, o = l.split('\0') - files[f] = o + files[f] = int(o) for f in files: o = files[f] - opener(f, "a").truncate(int(o)) + if o: + opener(f, "a").truncate(int(o)) + else: + fn = opener(f).name + os.unlink(fn) os.unlink(file) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -88,10 +88,11 @@ mercurial.version.remember_version(versi cmdclass = {'install_data': install_package_data} ext_modules=[ - Extension('mercurial.mpatch', ['mercurial/mpatch.c']), + Extension('mercurial.base85', ['mercurial/base85.c']), Extension('mercurial.bdiff', ['mercurial/bdiff.c']), - Extension('mercurial.base85', ['mercurial/base85.c']), - Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']) + Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c']), + Extension('mercurial.mpatch', ['mercurial/mpatch.c']), + Extension('mercurial.parsers', ['mercurial/parsers.c']), ] packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert'] diff --git a/templates/coal/changeset.tmpl b/templates/coal/changeset.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/changeset.tmpl @@ -0,0 +1,71 @@ +{header} +{repo|escape}: {node|short} + + +
+ + +
+ +

{repo|escape}

+

changeset {rev}:{node|short} {changesettag}

+ + + +
{desc|strip|escape|addbreaks}
+ + + + + + + + + + + + + + + + + + + + + +
author{author|obfuscate}
date{date|date} ({date|age} ago)
parents{parent%changesetparent}
children{child%changesetchild}
files{files}
+ + +
+ + + + + +
LineDiff
+{diff} +
+
+{footer} + + diff --git a/templates/coal/error.tmpl b/templates/coal/error.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/error.tmpl @@ -0,0 +1,39 @@ +{header} +{repo|escape}: error + + + +
+ + +
+ +

{repo|escape}

+

error

+ + + +
+

+An error occurred while processing your request: +

+

+{error|escape} +

+
+
+
+ +{footer} diff --git a/templates/coal/fileannotate.tmpl b/templates/coal/fileannotate.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/fileannotate.tmpl @@ -0,0 +1,76 @@ +{header} +{repo|escape}: {file|escape} annotate + + + +
+ + +
+

{repo|escape}

+

Annotate {file|escape} @ {diff}:{node|short}

+ + + +
{desc|strip|escape|addbreaks}
+ + + + + + + + + + + + + + + + + + +{changesettag} +
author{author|obfuscate}
date{date|date} ({date|age} ago)
parents{parent%filerevparent}
children{child%filerevchild}
+ +
+ +
+ + + + + + +{annotate%annotateline} +
RevLineSource
+
+
+
+ +{footer} diff --git a/templates/coal/filediff.tmpl b/templates/coal/filediff.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/filediff.tmpl @@ -0,0 +1,74 @@ +{header} +{repo|escape}: {file|escape} diff + + + +
+ + +
+

{repo|escape}

+

diff {file|escape} @ {rev}:{node|short}

+ + + +
{desc|strip|escape|addbreaks}
+ + + + + + + + + + + + + + + + + + +{changesettag} +
author{author|obfuscate}
date{date|date} ({date|age} ago)
parents{parent%filerevparent}
children{child%filerevchild}
+ +
+ + + + + +
LineDiff
+{diff} + + + + +{footer} + + diff --git a/templates/coal/filelog.tmpl b/templates/coal/filelog.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/filelog.tmpl @@ -0,0 +1,58 @@ +{header} +{repo|escape}: {file|escape} history + + + + + + +
+ + +
+ +

{repo|escape}

+

log {file|escape}

+ + +{sessionvars%hiddenformentry} +

+ + + + +
+ + +{entries%filelogentry} +
Age + Author + Description +
+ +
+
+ +{footer} diff --git a/templates/coal/filelogentry.tmpl b/templates/coal/filelogentry.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/filelogentry.tmpl @@ -0,0 +1,5 @@ + + {date|age} + {author|person} + {desc|strip|firstline|escape} + diff --git a/templates/coal/filerevision.tmpl b/templates/coal/filerevision.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/filerevision.tmpl @@ -0,0 +1,73 @@ +{header} +{repo|escape}: {node|short} {file|escape} + + + +
+ + +
+ +

{repo|escape}

+

view {file|escape} @ {rev}:{node|short}

+ + + +
{desc|strip|escape|addbreaks}
+ + + + + + + + + + + + + + + + + + +{changesettag} +
author{author|obfuscate}
date{date|date} ({date|age} ago)
parents{parent%filerevparent}
children{child%filerevchild}
+ +
+ + + + + +{text%fileline} +
LineSource
+
+
+
+ +{footer} diff --git a/templates/coal/footer.tmpl b/templates/coal/footer.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/footer.tmpl @@ -0,0 +1,4 @@ +{motd} + + + diff --git a/templates/coal/header.tmpl b/templates/coal/header.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/header.tmpl @@ -0,0 +1,7 @@ + + + + + + + diff --git a/templates/coal/index.tmpl b/templates/coal/index.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/index.tmpl @@ -0,0 +1,19 @@ +{header} +Mercurial repositories index + + + +

Mercurial Repositories

+ + + + + + + + + + {entries%indexentry} +
NameDescriptionContactLast change 
+ +{footer} diff --git a/templates/coal/manifest.tmpl b/templates/coal/manifest.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/manifest.tmpl @@ -0,0 +1,53 @@ +{header} +{repo|escape}: {node|short} {path|escape} + + + +
+ + +
+ +

{repo|escape}

+

directory {path|escape} @ {rev}:{node|short} {tags%changelogtag}

+ + + + + + + + + + + + +{dentries%direntry} +{fentries%fileentry} +
permissionsdatesizename
drwxr-xr-x + + + [up] +
+
+
+{footer} diff --git a/templates/coal/map b/templates/coal/map new file mode 100644 --- /dev/null +++ b/templates/coal/map @@ -0,0 +1,69 @@ +default = 'shortlog' + +mimetype = 'text/html; charset={encoding}' +header = header.tmpl +footer = footer.tmpl +search = search.tmpl + +changelog = shortlog.tmpl +shortlog = shortlog.tmpl +shortlogentry = shortlogentry.tmpl + +naventry = '{label|escape} ' +navshortentry = '{label|escape} ' +filenaventry = '{label|escape} ' +filedifflink = '{file|escape} ' +filenodelink = '{file|escape} ' +fileellipses = '...' +changelogentry = shortlogentry.tmpl +searchentry = shortlogentry.tmpl +changeset = changeset.tmpl +manifest = manifest.tmpl + +direntry = 'drwxr-xr-x{basename|escape}/' +fileentry = '{permissions|permissions} {date|isodate} {size} {basename|escape}' + +filerevision = filerevision.tmpl +fileannotate = fileannotate.tmpl +filediff = filediff.tmpl +filelog = filelog.tmpl +fileline = '{linenumber}{line|escape}' +filelogentry = filelogentry.tmpl + +annotateline = '{author|obfuscate}@{rev}{linenumber}{line|escape}' + +diffblock = '{lines}
' +difflineplus = '{linenumber}{line|escape}' +difflineminus = '{linenumber}{line|escape}' +difflineat = '{linenumber}{line|escape}' +diffline = '{linenumber}{line|escape}' + +changelogparent = 'parent {rev}:{node|short}' + +changesetparent = '{node|short} ' + +filerevparent = '{rename%filerename}{node|short} ' +filerevchild = '{node|short} ' + +filerename = '{file|escape}@' +filelogrename = 'base:{file|escape}@{node|short}' +fileannotateparent = 'parent:{rename%filerename}{node|short}' +changesetchild = '{node|short}' +changelogchild = 'child{node|short}' +fileannotatechild = 'child:{node|short}' +tags = tags.tmpl +tagentry = '{tag|escape}{node|short}' +changelogtag = 'tag:{tag|escape}' +changelogtag = '{name|escape} ' +changesettag = '{tag|escape} ' +filediffparent = 'parent {rev}:{node|short}' +filelogparent = 'parent {rev}:{node|short}' +filediffchild = 'child {rev}:{node|short}' +filelogchild = 'child {rev}:{node|short}' +indexentry = '{name|escape}{description}{contact|obfuscate}{lastchange|age} agoRSS Atom {archives%archiveentry}' +index = index.tmpl +archiveentry = '
  • {type|escape}
  • ' +notfound = notfound.tmpl +error = error.tmpl +urlparameter = '{separator}{name}={value|urlescape}' +hiddenformentry = '' diff --git a/templates/coal/notfound.tmpl b/templates/coal/notfound.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/notfound.tmpl @@ -0,0 +1,12 @@ +{header} +Mercurial repository not found + + + +

    Mercurial repository not found

    + +The specified repository "{repo|escape}" is unknown, sorry. + +Please go back to the main repository list page. + +{footer} diff --git a/templates/coal/search.tmpl b/templates/coal/search.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/search.tmpl @@ -0,0 +1,40 @@ +{header} +{repo|escape}: searching for {query|escape} + + + +
    + + +
    + +

    {repo|escape}

    +

    searching for '{query|escape}'

    + + + + + + +{entries} +
    Age + Author + Description +
    + +
    +
    + +{footer} diff --git a/templates/coal/shortlog.tmpl b/templates/coal/shortlog.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/shortlog.tmpl @@ -0,0 +1,54 @@ +{header} +{repo|escape}: log + + + + + +
    + + +
    + +

    {repo|escape}

    +

    log

    + + + + + + + + +{entries%shortlogentry} +
    Age + Author + Description +
    + + +
    +
    + +{footer} diff --git a/templates/coal/shortlogentry.tmpl b/templates/coal/shortlogentry.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/shortlogentry.tmpl @@ -0,0 +1,5 @@ + + {date|age} + {author|person} + {desc|strip|firstline|escape}{tags%changelogtag} + diff --git a/templates/coal/tags.tmpl b/templates/coal/tags.tmpl new file mode 100644 --- /dev/null +++ b/templates/coal/tags.tmpl @@ -0,0 +1,41 @@ +{header} +{repo|escape}: tags + + + + + +
    + + +
    +

    {repo|escape}

    +

    tags

    + + + + + + + + +{entries%tagentry} +
    tagnode
    +
    +
    + +{footer} diff --git a/templates/static/background.png b/templates/static/background.png new file mode 100644 index 0000000000000000000000000000000000000000..af8a0aa4eb5c4ab8e7e9ddc27756ce31e596f05a GIT binary patch literal 603 zc$@)S0;K(kP)@mjPuwX1dD! z2jIiS*~#nj!|x^&6{A~RM>SdLrQHf-n#`{K;4;91KkF6#6UA( zUylZ6*6$sr+yO3VW^SgmW=Dq%bQkRF(SSQhnJvwA`+6>HM)wX-?x{5Uz8jcXZ|1b5=MN#-k5ug`fWdhs)9}M&X(0T*?1@`r5U}iwwnL5hf zzy*}KsJWK%k4jN<4do+vRY0?wS-)2_GZ#>IrrJRN0-7+;e_&rhnHyKB?$TG{sjTLr p`&?GDaO07=nNCJk8ui;`z5wIw-7x^=I%NO=002ovPDHLkV1k9zAOZjY diff --git a/templates/static/hgicon.png b/templates/static/hgicon.png index 7745acfee3575b1bd58f5c1b28e5d8664937e2ba..60effbc5e613d8c8a6f1418853ded6aa4e599671 GIT binary patch literal 792 zc$^(kYfREn6i21SXf9`cP+L~(LxoE}WNP6%Oc_ocI5pAbT$`_%X>2~rrlwJ%`9TvD z9n>0vq6n7!@i9=$2UMg&PRPnkMHC;)M-X)MZ1;E1`Q3BR`Q3ZyaWRq3SPv`;g>oiF z5y-H+94?F#;N`0)DJYZ!JuW&v!fLhJY&N^yesE+ES}d0B?d`q2J#c_oSXfy6xo9$( zfLU2t+1=eWo6UN?9{APO)tTv;jg5`1t*yDaIkie{Fc=`5nwnZ#TAG-cKoCTy(}6D$ zONNJsJ3BiODKa!P1Zi5W78079n;RP&xg4%qt?uvd9~&F%?(PO09313wxr|x{i^bye z`9P+nrHMo$3Yn6Zmp3pl00{Xs8Vy>A#p0Zt9Jo?hSxKkU8;>lS6fKcRAZ%!8AdyG{ zfuO#=zO}U#sudO%0^;%b%*@P;jEv&qVh~0o5~);bRaI3$KmZ(tgoKdEB!tDgxnGw*O;(^z zKhem}$$IcTGQ3D8bK1EdU{aJl{IDDt`7El-Jvr5lS9cs8DX;CQ`~JWW4Bso>C--;3?N1$D<)*MZWskjxMm#np+1TIm3SrxlxRW>i zy5na{Qchje+#-C__ZdeHc%k8oQ8`#&X7;eT592FfrG7q(*ayCPy9Sc@K5H5#^=?S4 zWxe`5#lyCFrtgPYSGjc$jr0GQ@O(AsMqu0cF^68<7fxBpJNXH#W40ye%_HmkYIq@v M7!gAdhNo5h2bj0NGXMYp diff --git a/templates/static/hglogo.png b/templates/static/hglogo.png index 07c8e17c4c33b54d92a54d16d71ecffbc9b9abaa..adc6e65d1a70dd63bfa6d0a73f33a8392377f6d4 GIT binary patch literal 4123 zc$@(n5ajQPP)003GD0ssI2f2KTx00006VoOIv0RI60 z0RN!9r;`8x570?OK~#9!?VNdBRn->9dzzA_mQwg>a0qj1Ff1@ZAwroH9GGG-2^A9z z1Hl170ri7gB8r(@aVQ65Fw06(lOCvG6eQ>q95N&5~seGcAr*Z;%#;DZnTbvq7l{TCrW{CztPaNR*@xbfFte_gq9 zrLL~-^y$+lPMl!H!wrKE$B!T9;<({T}VhHQ&>%aT%JCN+(zyF_VyLT@i)UO{rco4uBFJ3eVR3jq9zRQ;{Gi^aZfxwfOm-pU#?`39YzVpsI85tQW zwZV^EsFP%W6hd1xw*LlXIWVpIeg<0!X>1TaNUO= zey9{f0Ky$Rb_fSTbSe`L zVs+udg$@o5NOt2QT%%eesWX*n$F5zw1`HUGl9KZK@4p)hArbP%8*khwgh;~0ix>Ck z(E|-^EQD9DUQJ3$5(vpg6C*^p?%A`ackkY_XU|6K8wDY~->g})*hnF%=m|^=5_y=A zkkGw*_hZM783iFVciOaRWhu)D&JG3~Sb-{uK?c296EiKg( zA%uD9(j_F)_uqei`SN8AHOLpk!^1s1JUVyoynXw2cGMtkp-zR7Mi~eMs{F{K8HA!? zFDfdcn&&kP+V+x?lJn=!tKZ}2>j$m1ZryswkRik>4XY^;qV=(=W52a|W}*6rD6pZ)sluXR9( z_wWYJX_Ubr6-n9?#zBEWDN9q>$X2adMMXuiB#N=o?;2yU<7iaUUrr7G)s~joKu_ zb!*o_Q0j9XIB@x|)<>b1f_^Sdq1U`spV{2x&}+L-lOto4@>TfDj)J95_&(y>!Dv?1sGh>Z>Rz zdwcsXUAizi`Dtfo2O9|`NqT2zXRlwszU2pvScN47mzkLv3neBd{`ljMiV(&`$EY7k zkWLc3ix)3Kl`p^ivYVS5=_;==RaI4Pu5Q7>!2tmQ+%{* z@{p)FR)eT@8pJ>LFvI4}n+1xvxHyWoB81CRm#flM>ZcNC&YU4iYieqMhtzg*a+)-0 zQd1&x2Ybg@B-4vazvob#*;-=#X|nNBu>zf-@u} z1e(R4pv53|3I^iGcJ10hNGw5^=>d}MMvGz+@gh*nojX@4LI%9V-m~RwwxgpXiXkW{ z2w+UdzbjX+R482WC*c$t8fs^2_sT1;%$PA_>eQ+9%_PhZKm0Ie%ovynkszn;X2lvi zRasfd7pe6E1;M2>N`WNL=+L1vVrIZYH0kg*ZiHYJ!Xu;!0g@1{FC`(>i-uTfwJ^;S z_Tj^Zlb^kM^@40bNFSsSAwI`}r%s)M_F!fKfq>`w)vH%;qBj*TT(~g8eFUXQob)I} zNKu7OK!`Smr8;%$g#8p}Utiz-`}ZqVZ6+IJfseP3KuE|b)Y-s;r6^|e=FJoKlhuBH ze&yxmMtN>QU?5OMi;P>YUAv~!*I`$x1qh)>B@e*i5)g{^MX)IHFeWC3PG8OuEkZ~< zknUw=WzxG9ViXh~ zB!7mXCqlv!#Y8@6;dk7EKhZtSg3RBW&o(t%@rhwl0C?Yi`z@US+UV}P@5XYvdkO}v z!pV~-4RhAUK9!c10LM6`!1Nyu&5B{=&9wEzzvLb>>S`0(Mv^0c(H7hZUQ zmZi~`HS|G9He-;&Q$xsL+O%ovjk0_Yd)TM_2@Erc&gRIGBcjO^8A#(xNks0-SyWGi zY@tr4X{4yNwKcom)P!&YyP(l+<9sSxNl6JbCQ6?e;Dlf(Do;QCv@km-C&$^@nJe^k zhCxU+Lm}jVlJj=RfOf>k$H&vtv#BR1>^%_yKS|%h66r8OeQ*(HvNVN3*i4|JODXga zY*UG#8$xDb0fkRO2`3sta+UV?zWeUeko?jUa##@`O36ky^h*;13*l=`hsC1q(!voBl_a(E20NF>}65D>up)B|}$Pzl9zRh)DB^y#MHAs)y# zk`qP|)>8dwECvl4MB&vgp>#ut-3bW^+TRJn)~c#1VHtO_>oztv=H})ar*aI+8l)vS z23~0j9!P+JyQp}mGfcIxuwbvFqN3vB;u?M4q(4Hs^{^>nnAPZs1CpPNs;;gUmZ2Vr zD*(WIbZ&C4+qZ8YA<8|lzf=t5-Xkf1N3Sf}Tr)E>Arjr(++bP*zfVJ4O`I?hg!1=h z;A?SIrOtbB=}RxYG;!j@QKLp_=qVska>Rpi_N7tgtf{FXGKtUh^z@D$J7Od?knJE{ zpMU=OZMoZ&yxpdAwZNdIOP7*7>TYC@*=+TVhatI`nwt8|GtUGE2UE~B<|!;F6k?ru z2to~P1OiK}U%#GRK#{d?-(JAOlL$r+50Ax*7dKUYT8faYaB+6QKjIXSJtjCILs*fN zpxJ{n!G`zP2;vhf{r&wl`fdjINIfASi;Igffa=1ukSbTuWz6s8BGQOQDGZ_K;a>=M~)nc25hvn8WJJdn3R|l;QycVY}EaePd>@MzTPkb0|TwBtOg7i zfQvAca00emZEyu$A`k*;+_-Vfz^=Kvx>D}$zyE&eFL@q$?f`t<4OU|h;|*d=pIW>aE{$|hdmmK3J?K(DYnqyX3; z;n>*Npuix)o*Xghd)|i+9}XTL>|pQU=IUlU*w)6{#?H=e@ZiD7MO>uiJtYSDIcwG| zLe$pQRv6&z?Y&^Zf|QgLswjLTa-Plz_r^rWY}&XPDczbzMvPs=XAAJ-9(DdTypt7=(gd_@rf`W*A?x{Rl*^)EM8+O))qo#&W z#o_bk&nKmA8U|@hH{|E%H#u~2VS}V@bvWT)~y>Y486jJ4I9u<$SZzCc}mAy z;(U=CI(6#Qw{Kr0n7DrO46qqkyF3kwT+f95=J;DF8u(a`jG*g-Rf=A;cp zOjlG?(BnEdIIy;KAm6TCJ7hExgn#e3=N|F*9W+F}d-rCW%FD~?_qp=++i%k`uv6TL zL8x{v4jVQMwJj}*ahNDRj~+dmzKm{DJmC^d6C51OhhxW%@hz67V=gT%g?^Cl`XF4f zVueK0Ae5f$Aph;{?Zsy&Cnq{?>0AB!^#g-I7#<$3{xFAdc=OFSHDXLVLYfZ^E)@vn z4D{fG54H&5`Sa)15w2dndeERj;(++xd+$}RKaP%$%a$#ZBRqcmI5XfqV<5!CUAlB> z5kh)Ub%ZLFicVZ4TkF=X>+0&HZ;_%zqa5MRojc9V&E*ZA-U!Kmf}b>ILl-Vw_`m}X z7zJTjSs4gJ8itRL56NI=W=71&5pLbO71oinqJ9XOXVRoe4?p}c9VsAveSN!j?P?T+ zB_$q|1W;Zc0QCEb!cI|?+rQ=}u78)}O!Yfy+9p<;*=n)si`4$_UzdsG#1>}r%xZ95qf)jZ{ECFdJs((F|YVB zGc(i6%S(L5Eml@mWMk*fo!ho;YiVgI&VQq#qUO(^uRdX3ULNY?p@$v<5@{pOo#0_> zYim>vCh}VZ3SSiWhlYkyc-3c^Idf)gY^-1!J`TxwwD zE&i_olt;5i(bP|FJ9Oxf`s?(39p>O7Ue)PkDt3q2h=2JbgF8L`9fY?k!rT9UGrPUV ZzX9yYMs{m}{pkPz002ovPDHLkV1fy8=Q;oY diff --git a/templates/static/style-coal.css b/templates/static/style-coal.css new file mode 100644 --- /dev/null +++ b/templates/static/style-coal.css @@ -0,0 +1,160 @@ +body { + margin: 0; + padding: 0; + background: black url(background.png) repeat-x; + font-family: sans-serif; +} + +.container { + padding-right: 150px; +} + +.main { + position: relative; + background: white; + padding: 2em; + border-right: 15px solid black; + border-bottom: 15px solid black; +} + +.overflow { + width: 100%; + overflow: auto; +} + +.menu { + background: #999; + padding: 10px; + width: 75px; + margin: 0; + font-size: 80% /*smaller*/; + text-align: left; + position: fixed; + top: 27px; + left: auto; + right: 27px; +} + +.menu ul { + list-style: none; + padding: 0; + margin: 10px 0 0 0; +} + +.menu li { + margin-bottom: 3px; + padding: 2px 4px; + background: white; + color: black; + font-weight: normal; +} + +.menu li.active { + border-left: 3px solid black; +} + +.search { + position: absolute; + top: .7em; + right: 2em; +} + +.menu a { color: black; display: block; } + +a { text-decoration:none; } +.age { white-space:nowrap; } +.date { white-space:nowrap; } +.indexlinks { white-space:nowrap; } +.parity0 { background-color: #f5f5f5; } +.parity1 { background-color: white; } +.plusline { color: green; } +.minusline { color: red; } +.atline { color: purple; } + +.navigate { + text-align: right; + font-size: 60%; + margin: 1em 0 1em 0; +} + +.tag { + color: #999; + font-size: 70%; + font-weight: normal; + margin-left: .5em; + vertical-align: text-baseline; +} + +.navigate a { + #padding: 2pt; + #background-color: #f5f5f5; +} + +/* Common */ +pre { margin: 0; } + +h2 { font-size: 120%; border-bottom: 1px solid #999; } +h3 { + margin-top: -.7em; + font-size: 100%; +} + +/* log and tags tables */ +.bigtable { + border-bottom: 1px solid #999; + border-collapse: collapse; + font-size: 90%; + width: 100%; + font-weight: normal; + text-align: left; +} + +.bigtable td { + padding: 1px 4px 1px 4px; + vertical-align: top; +} + +.bigtable th { + padding: 1px 4px 1px 4px; + border-bottom: 1px solid #999; + font-size: smaller; +} +.bigtable tr { border: none; } +.bigtable .age { width: 6em; } +.bigtable .author { width: 10em; } +.bigtable .description { } +.bigtable .node { width: 5em; font-family: monospace;} +.bigtable .lineno { width: 2em; text-align: right;} +.bigtable .lineno a { color: #999; font-size: smaller; font-family: monospace;} +.bigtable td.source { font-family: monospace; white-space: pre; } +.bigtable .permissions { width: 8em; text-align: left;} +.bigtable td.permissions { font-family: monospace; } +.bigtable .date { width: 10em; text-align: left;} +.bigtable .size { width: 5em; text-align: right; } +.bigtable td.size { font-family: monospace; } +.bigtable .annotate { text-align: right; padding-right: } +.bigtable td.annotate { font-size: smaller; } + +/* Changeset entry */ +#changesetEntry { + border-collapse: collapse; + font-size: 90%; + width: 100%; + margin-bottom: 1em; +} + +#changesetEntry th { + padding: 1px 4px 1px 4px; + width: 4em; + text-align: right; + font-weight: normal; + color: #999; + margin-right: .5em; + vertical-align: top; +} + +div.description { + border-left: 3px solid #999; + margin: 1em 0 1em 0; + padding: .3em; +} diff --git a/tests/test-churn b/tests/test-churn --- a/tests/test-churn +++ b/tests/test-churn @@ -3,6 +3,8 @@ echo "[extensions]" >> $HGRCPATH echo "churn=" >> $HGRCPATH +COLUMNS=80; export COLUMNS + echo % create test repository hg init repo cd repo diff --git a/tests/test-dispatch.out b/tests/test-dispatch.out --- a/tests/test-dispatch.out +++ b/tests/test-dispatch.out @@ -10,7 +10,7 @@ output the current or given revision of or tip if no revision is checked out. Output may be to a file, in which case the name of the file is - given using a format string. The formatting rules are the same as + given using a format string. The formatting rules are the same as for the export command, with the following additions: %s basename of file being printed diff --git a/tests/test-help.out b/tests/test-help.out --- a/tests/test-help.out +++ b/tests/test-help.out @@ -216,10 +216,10 @@ aliases: st show changed files in the working directory - Show status of files in the repository. If names are given, only - files that match are shown. Files that are clean or ignored or + Show status of files in the repository. If names are given, only + files that match are shown. Files that are clean or ignored or source of a copy/move operation, are not listed unless -c (clean), - -i (ignored), -C (copies) or -A is given. Unless options described + -i (ignored), -C (copies) or -A is given. Unless options described with "show only ..." are given, the options -mardu are used. Option -q/--quiet hides untracked (unknown and ignored) files diff --git a/tests/test-serve.out b/tests/test-serve.out --- a/tests/test-serve.out +++ b/tests/test-serve.out @@ -1,12 +1,12 @@ % Without -v access log created - .hg/hgrc respected % With -v -listening at http://localhost/ (127.0.0.1) +listening at http://localhost/ (bound to 127.0.0.1) % With --prefix foo -listening at http://localhost/foo/ (127.0.0.1) +listening at http://localhost/foo/ (bound to 127.0.0.1) % With --prefix /foo -listening at http://localhost/foo/ (127.0.0.1) +listening at http://localhost/foo/ (bound to 127.0.0.1) % With --prefix foo/ -listening at http://localhost/foo/ (127.0.0.1) +listening at http://localhost/foo/ (bound to 127.0.0.1) % With --prefix /foo/ -listening at http://localhost/foo/ (127.0.0.1) +listening at http://localhost/foo/ (bound to 127.0.0.1)