Merge OS X performance regression fix
authorBryan O'Sullivan <bos@serpentine.com>
Wed, 08 Jul 2009 17:03:50 -0700
changeset 9085 4858f2cacb4d
parent 9082 31e54756559b (diff)
parent 9084 9f191931c859 (current diff)
child 9086 f459f09b4214
Merge OS X performance regression fix
mercurial/util.py
--- a/Makefile	Wed Jul 08 17:03:16 2009 -0700
+++ b/Makefile	Wed Jul 08 17:03:50 2009 -0700
@@ -89,7 +89,7 @@
         # Extracting with an explicit encoding of ISO-8859-1 will make
         # xgettext "parse" and ignore them.
 	echo $^ | xargs \
-	  xgettext --package-name "Mercurial" \
+	  xgettext --width 82 --package-name "Mercurial" \
 	  --msgid-bugs-address "<mercurial-devel@selenic.com>" \
 	  --copyright-holder "Matt Mackall <mpm@selenic.com> and others" \
 	  --from-code ISO-8859-1 --join --sort-by-file \
--- a/hgext/acl.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/acl.py	Wed Jul 08 17:03:50 2009 -0700
@@ -8,19 +8,18 @@
 
 '''hooks for controlling repository access
 
-This hook makes it possible to allow or deny write access to portions
-of a repository when receiving incoming changesets.
-
-The authorization is matched based on the local user name on the
-system where the hook runs, and not the committer of the original
-changeset (since the latter is merely informative).
+This hook makes it possible to allow or deny write access to portions of a
+repository when receiving incoming changesets.
 
-The acl hook is best used along with a restricted shell like hgsh,
-preventing authenticating users from doing anything other than
-pushing or pulling. The hook is not safe to use if users have
-interactive shell access, as they can then disable the hook.
-Nor is it safe if remote users share an account, because then there
-is no way to distinguish them.
+The authorization is matched based on the local user name on the system where
+the hook runs, and not the committer of the original changeset (since the
+latter is merely informative).
+
+The acl hook is best used along with a restricted shell like hgsh, preventing
+authenticating users from doing anything other than pushing or pulling. The
+hook is not safe to use if users have interactive shell access, as they can
+then disable the hook. Nor is it safe if remote users share an account,
+because then there is no way to distinguish them.
 
 To use this hook, configure the acl extension in your hgrc like this:
 
@@ -35,10 +34,9 @@
   # ("serve" == ssh or http, "push", "pull", "bundle")
   sources = serve
 
-The allow and deny sections take a subtree pattern as key (with a
-glob syntax by default), and a comma separated list of users as
-the corresponding value. The deny list is checked before the allow
-list is.
+The allow and deny sections take a subtree pattern as key (with a glob syntax
+by default), and a comma separated list of users as the corresponding value.
+The deny list is checked before the allow list is.
 
   [acl.allow]
   # If acl.allow is not present, all users are allowed by default.
--- a/hgext/bookmarks.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/bookmarks.py	Wed Jul 08 17:03:50 2009 -0700
@@ -7,25 +7,22 @@
 
 '''track a line of development with movable markers
 
-Bookmarks are local movable markers to changesets. Every bookmark
-points to a changeset identified by its hash. If you commit a
-changeset that is based on a changeset that has a bookmark on it,
-the bookmark shifts to the new changeset.
+Bookmarks are local movable markers to changesets. Every bookmark points to a
+changeset identified by its hash. If you commit a changeset that is based on a
+changeset that has a bookmark on it, the bookmark shifts to the new changeset.
 
-It is possible to use bookmark names in every revision lookup
-(e.g. hg merge, hg update).
+It is possible to use bookmark names in every revision lookup (e.g. hg merge,
+hg update).
 
-By default, when several bookmarks point to the same changeset, they
-will all move forward together. It is possible to obtain a more
-git-like experience by adding the following configuration option to
-your .hgrc:
+By default, when several bookmarks point to the same changeset, they will all
+move forward together. It is possible to obtain a more git-like experience by
+adding the following configuration option to your .hgrc:
 
   [bookmarks]
   track.current = True
 
-This will cause Mercurial to track the bookmark that you are currently
-using, and only update it. This is similar to git's approach to
-branching.
+This will cause Mercurial to track the bookmark that you are currently using,
+and only update it. This is similar to git's approach to branching.
 '''
 
 from mercurial.i18n import _
@@ -124,15 +121,15 @@
 def bookmark(ui, repo, mark=None, rev=None, force=False, delete=False, rename=None):
     '''track a line of development with movable markers
 
-    Bookmarks are pointers to certain commits that move when
-    committing. Bookmarks are local. They can be renamed, copied and
-    deleted. It is possible to use bookmark names in 'hg merge' and
-    'hg update' to merge and update respectively to a given bookmark.
+    Bookmarks are pointers to certain commits that move when committing.
+    Bookmarks are local. They can be renamed, copied and deleted. It is
+    possible to use bookmark names in 'hg merge' and 'hg update' to merge and
+    update respectively to a given bookmark.
 
     You can use 'hg bookmark NAME' to set a bookmark on the working
-    directory's parent revision with the given name. If you specify
-    a revision using -r REV (where REV may be an existing bookmark),
-    the bookmark is assigned to that revision.
+    directory's parent revision with the given name. If you specify a revision
+    using -r REV (where REV may be an existing bookmark), the bookmark is
+    assigned to that revision.
     '''
     hexfn = ui.debugflag and hex or short
     marks = parse(repo)
--- a/hgext/bugzilla.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/bugzilla.py	Wed Jul 08 17:03:50 2009 -0700
@@ -7,77 +7,69 @@
 
 '''hooks for integrating with the Bugzilla bug tracker
 
-This hook extension adds comments on bugs in Bugzilla when changesets
-that refer to bugs by Bugzilla ID are seen. The hook does not change
-bug status.
+This hook extension adds comments on bugs in Bugzilla when changesets that
+refer to bugs by Bugzilla ID are seen. The hook does not change bug status.
 
-The hook updates the Bugzilla database directly. Only Bugzilla
-installations using MySQL are supported.
+The hook updates the Bugzilla database directly. Only Bugzilla installations
+using MySQL are supported.
 
-The hook relies on a Bugzilla script to send bug change notification
-emails. That script changes between Bugzilla versions; the
-'processmail' script used prior to 2.18 is replaced in 2.18 and
-subsequent versions by 'config/sendbugmail.pl'. Note that these will
-be run by Mercurial as the user pushing the change; you will need to
-ensure the Bugzilla install file permissions are set appropriately.
+The hook relies on a Bugzilla script to send bug change notification emails.
+That script changes between Bugzilla versions; the 'processmail' script used
+prior to 2.18 is replaced in 2.18 and subsequent versions by
+'config/sendbugmail.pl'. Note that these will be run by Mercurial as the user
+pushing the change; you will need to ensure the Bugzilla install file
+permissions are set appropriately.
 
 Configuring the extension:
 
     [bugzilla]
 
-    host       Hostname of the MySQL server holding the Bugzilla
-               database.
+    host       Hostname of the MySQL server holding the Bugzilla database.
     db         Name of the Bugzilla database in MySQL. Default 'bugs'.
     user       Username to use to access MySQL server. Default 'bugs'.
     password   Password to use to access MySQL server.
     timeout    Database connection timeout (seconds). Default 5.
-    version    Bugzilla version. Specify '3.0' for Bugzilla versions
-               3.0 and later, '2.18' for Bugzilla versions from 2.18
-               and '2.16' for versions prior to 2.18.
+    version    Bugzilla version. Specify '3.0' for Bugzilla versions 3.0 and
+               later, '2.18' for Bugzilla versions from 2.18 and '2.16' for
+               versions prior to 2.18.
     bzuser     Fallback Bugzilla user name to record comments with, if
                changeset committer cannot be found as a Bugzilla user.
-    bzdir      Bugzilla install directory. Used by default notify.
-               Default '/var/www/html/bugzilla'.
+    bzdir      Bugzilla install directory. Used by default notify. Default
+               '/var/www/html/bugzilla'.
     notify     The command to run to get Bugzilla to send bug change
-               notification emails. Substitutes from a map with 3
-               keys, 'bzdir', 'id' (bug id) and 'user' (committer
-               bugzilla email). Default depends on version; from 2.18
-               it is "cd %(bzdir)s && perl -T contrib/sendbugmail.pl
-               %(id)s %(user)s".
+               notification emails. Substitutes from a map with 3 keys,
+               'bzdir', 'id' (bug id) and 'user' (committer bugzilla email).
+               Default depends on version; from 2.18 it is "cd %(bzdir)s &&
+               perl -T contrib/sendbugmail.pl %(id)s %(user)s".
     regexp     Regular expression to match bug IDs in changeset commit
-               message. Must contain one "()" group. The default
-               expression matches 'Bug 1234', 'Bug no. 1234', 'Bug
-               number 1234', 'Bugs 1234,5678', 'Bug 1234 and 5678' and
-               variations thereof. Matching is case insensitive.
+               message. Must contain one "()" group. The default expression
+               matches 'Bug 1234', 'Bug no. 1234', 'Bug number 1234', 'Bugs
+               1234,5678', 'Bug 1234 and 5678' and variations thereof.
+               Matching is case insensitive.
     style      The style file to use when formatting comments.
-    template   Template to use when formatting comments. Overrides
-               style if specified. In addition to the usual Mercurial
-               keywords, the extension specifies:
+    template   Template to use when formatting comments. Overrides style if
+               specified. In addition to the usual Mercurial keywords, the
+               extension specifies:
                    {bug}       The Bugzilla bug ID.
-                   {root}      The full pathname of the Mercurial
-                               repository.
-                   {webroot}   Stripped pathname of the Mercurial
-                               repository.
-                   {hgweb}     Base URL for browsing Mercurial
-                               repositories.
+                   {root}      The full pathname of the Mercurial repository.
+                   {webroot}   Stripped pathname of the Mercurial repository.
+                   {hgweb}     Base URL for browsing Mercurial repositories.
                Default 'changeset {node|short} in repo {root} refers '
                        'to bug {bug}.\\ndetails:\\n\\t{desc|tabindent}'
-    strip      The number of slashes to strip from the front of {root}
-               to produce {webroot}. Default 0.
-    usermap    Path of file containing Mercurial committer ID to
-               Bugzilla user ID mappings. If specified, the file
-               should contain one mapping per line,
-               "committer"="Bugzilla user". See also the [usermap]
+    strip      The number of slashes to strip from the front of {root} to
+               produce {webroot}. Default 0.
+    usermap    Path of file containing Mercurial committer ID to Bugzilla user
+               ID mappings. If specified, the file should contain one mapping
+               per line, "committer"="Bugzilla user". See also the [usermap]
                section.
 
     [usermap]
-    Any entries in this section specify mappings of Mercurial
-    committer ID to Bugzilla user ID. See also [bugzilla].usermap.
-    "committer"="Bugzilla user"
+    Any entries in this section specify mappings of Mercurial committer ID to
+    Bugzilla user ID. See also [bugzilla].usermap. "committer"="Bugzilla user"
 
     [web]
-    baseurl    Base URL for browsing Mercurial repositories. Reference
-               from templates as {hgweb}.
+    baseurl    Base URL for browsing Mercurial repositories. Reference from
+               templates as {hgweb}.
 
 Activating the extension:
 
@@ -90,9 +82,9 @@
 
 Example configuration:
 
-This example configuration is for a collection of Mercurial
-repositories in /var/local/hg/repos/ used with a local Bugzilla 3.2
-installation in /opt/bugzilla-3.2.
+This example configuration is for a collection of Mercurial repositories in
+/var/local/hg/repos/ used with a local Bugzilla 3.2 installation in
+/opt/bugzilla-3.2.
 
     [bugzilla]
     host=localhost
--- a/hgext/children.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/children.py	Wed Jul 08 17:03:50 2009 -0700
@@ -18,11 +18,11 @@
 def children(ui, repo, file_=None, **opts):
     """show the children of the given or working directory revision
 
-    Print the children of the working directory's revisions. If a
-    revision is given via -r/--rev, the children of that revision will
-    be printed. If a file argument is given, revision in which the
-    file was last changed (after the working directory revision or the
-    argument to --rev if given) is printed.
+    Print the children of the working directory's revisions. If a revision is
+    given via -r/--rev, the children of that revision will be printed. If a
+    file argument is given, revision in which the file was last changed (after
+    the working directory revision or the argument to --rev if given) is
+    printed.
     """
     rev = opts.get('rev')
     if file_:
--- a/hgext/churn.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/churn.py	Wed Jul 08 17:03:50 2009 -0700
@@ -94,15 +94,13 @@
 def churn(ui, repo, *pats, **opts):
     '''histogram of changes to the repository
 
-    This command will display a histogram representing the number
-    of changed lines or revisions, grouped according to the given
-    template. The default template will group changes by author.
-    The --dateformat option may be used to group the results by
-    date instead.
+    This command will display a histogram representing the number of changed
+    lines or revisions, grouped according to the given template. The default
+    template will group changes by author. The --dateformat option may be used
+    to group the results by date instead.
 
-    Statistics are based on the number of changed lines, or
-    alternatively the number of matching revisions if the
-    --changesets option is specified.
+    Statistics are based on the number of changed lines, or alternatively the
+    number of matching revisions if the --changesets option is specified.
 
     Examples:
 
@@ -118,8 +116,8 @@
       # display count of lines changed in every year
       hg churn -f '%Y' -s
 
-    It is possible to map alternate email addresses to a main address
-    by providing a file using the following format:
+    It is possible to map alternate email addresses to a main address by
+    providing a file using the following format:
 
     <alias email> <actual email>
 
@@ -143,8 +141,8 @@
     if not rate:
         return
 
-    sortfn = ((not opts.get('sort')) and (lambda a, b: cmp(b[1], a[1])) or None)
-    rate.sort(sortfn)
+    sortkey = ((not opts.get('sort')) and (lambda x: -x[1]) or None)
+    rate.sort(key=sortkey)
 
     maxcount = float(max([v for k, v in rate]))
     maxname = max([len(k) for k, v in rate])
--- a/hgext/color.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/color.py	Wed Jul 08 17:03:50 2009 -0700
@@ -18,16 +18,15 @@
 
 '''colorize output from some commands
 
-This extension modifies the status command to add color to its output
-to reflect file status, the qseries command to add color to reflect
-patch status (applied, unapplied, missing), and to diff-related
-commands to highlight additions, removals, diff headers, and trailing
-whitespace.
+This extension modifies the status command to add color to its output to
+reflect file status, the qseries command to add color to reflect patch status
+(applied, unapplied, missing), and to diff-related commands to highlight
+additions, removals, diff headers, and trailing whitespace.
 
-Other effects in addition to color, like bold and underlined text, are
-also available. Effects are rendered with the ECMA-48 SGR control
-function (aka ANSI escape codes). This module also provides the
-render_text function, which can be used to add effects to any text.
+Other effects in addition to color, like bold and underlined text, are also
+available. Effects are rendered with the ECMA-48 SGR control function (aka
+ANSI escape codes). This module also provides the render_text function, which
+can be used to add effects to any text.
 
 Default effects may be overridden from the .hgrc file:
 
@@ -146,9 +145,9 @@
     for patch in patches:
         patchname = patch
         if opts['summary']:
-            patchname = patchname.split(': ')[0]
+            patchname = patchname.split(': ', 1)[0]
         if ui.verbose:
-            patchname = patchname.split(' ', 2)[-1]
+            patchname = patchname.lstrip().split(' ', 2)[-1]
 
         if opts['missing']:
             effects = _patch_effects['missing']
@@ -158,7 +157,9 @@
             effects = _patch_effects['applied']
         else:
             effects = _patch_effects['unapplied']
-        ui.write(render_effects(patch, effects) + '\n')
+
+        patch = patch.replace(patchname, render_effects(patchname, effects), 1)
+        ui.write(patch + '\n')
     return retval
 
 _patch_effects = { 'applied': ['blue', 'bold', 'underline'],
--- a/hgext/convert/__init__.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/convert/__init__.py	Wed Jul 08 17:03:50 2009 -0700
@@ -33,45 +33,45 @@
     - Mercurial [hg]
     - Subversion [svn] (history on branches is not preserved)
 
-    If no revision is given, all revisions will be converted.
-    Otherwise, convert will only import up to the named revision
-    (given in a format understood by the source).
+    If no revision is given, all revisions will be converted. Otherwise,
+    convert will only import up to the named revision (given in a format
+    understood by the source).
 
-    If no destination directory name is specified, it defaults to the
-    basename of the source with '-hg' appended. If the destination
-    repository doesn't exist, it will be created.
+    If no destination directory name is specified, it defaults to the basename
+    of the source with '-hg' appended. If the destination repository doesn't
+    exist, it will be created.
 
-    By default, all sources except Mercurial will use
-    --branchsort. Mercurial uses --sourcesort to preserve original
-    revision numbers order. Sort modes have the following effects:
-      --branchsort: convert from parent to child revision when
-        possible, which means branches are usually converted one after
-        the other. It generates more compact repositories.
+    By default, all sources except Mercurial will use --branchsort. Mercurial
+    uses --sourcesort to preserve original revision numbers order. Sort modes
+    have the following effects:
+      --branchsort: convert from parent to child revision when possible, which
+        means branches are usually converted one after the other. It generates
+        more compact repositories.
       --datesort: sort revisions by date. Converted repositories have
-        good-looking changelogs but are often an order of magnitude
-        larger than the same ones generated by --branchsort.
-      --sourcesort: try to preserve source revisions order, only
-        supported by Mercurial sources.
+        good-looking changelogs but are often an order of magnitude larger
+        than the same ones generated by --branchsort.
+      --sourcesort: try to preserve source revisions order, only supported by
+        Mercurial sources.
 
     If <REVMAP> isn't given, it will be put in a default location
-    (<dest>/.hg/shamap by default). The <REVMAP> is a simple text file
-    that maps each source commit ID to the destination ID for that
-    revision, like so:
+    (<dest>/.hg/shamap by default). The <REVMAP> is a simple text file that
+    maps each source commit ID to the destination ID for that revision, like
+    so:
+
     <source ID> <destination ID>
 
-    If the file doesn't exist, it's automatically created. It's
-    updated on each commit copied, so convert-repo can be interrupted
-    and can be run repeatedly to copy new commits.
+    If the file doesn't exist, it's automatically created. It's updated on
+    each commit copied, so convert-repo can be interrupted and can be run
+    repeatedly to copy new commits.
 
-    The [username mapping] file is a simple text file that maps each
-    source commit author to a destination commit author. It is handy
-    for source SCMs that use unix logins to identify authors (eg:
-    CVS). One line per author mapping and the line format is:
-    srcauthor=whatever string you want
+    The [username mapping] file is a simple text file that maps each source
+    commit author to a destination commit author. It is handy for source SCMs
+    that use unix logins to identify authors (eg: CVS). One line per author
+    mapping and the line format is: srcauthor=whatever string you want
 
-    The filemap is a file that allows filtering and remapping of files
-    and directories. Comment lines start with '#'. Each line can
-    contain one of the following directives:
+    The filemap is a file that allows filtering and remapping of files and
+    directories. Comment lines start with '#'. Each line can contain one of
+    the following directives:
 
       include path/to/file
 
@@ -79,35 +79,32 @@
 
       rename from/file to/file
 
-    The 'include' directive causes a file, or all files under a
-    directory, to be included in the destination repository, and the
-    exclusion of all other files and directories not explicitly included.
-    The 'exclude' directive causes files or directories to be omitted.
-    The 'rename' directive renames a file or directory. To rename from
-    a subdirectory into the root of the repository, use '.' as the
-    path to rename to.
+    The 'include' directive causes a file, or all files under a directory, to
+    be included in the destination repository, and the exclusion of all other
+    files and directories not explicitly included. The 'exclude' directive
+    causes files or directories to be omitted. The 'rename' directive renames
+    a file or directory. To rename from a subdirectory into the root of the
+    repository, use '.' as the path to rename to.
 
-    The splicemap is a file that allows insertion of synthetic
-    history, letting you specify the parents of a revision. This is
-    useful if you want to e.g. give a Subversion merge two parents, or
-    graft two disconnected series of history together. Each entry
-    contains a key, followed by a space, followed by one or two
-    comma-separated values. The key is the revision ID in the source
-    revision control system whose parents should be modified (same
-    format as a key in .hg/shamap). The values are the revision IDs
-    (in either the source or destination revision control system) that
+    The splicemap is a file that allows insertion of synthetic history,
+    letting you specify the parents of a revision. This is useful if you want
+    to e.g. give a Subversion merge two parents, or graft two disconnected
+    series of history together. Each entry contains a key, followed by a
+    space, followed by one or two comma-separated values. The key is the
+    revision ID in the source revision control system whose parents should be
+    modified (same format as a key in .hg/shamap). The values are the revision
+    IDs (in either the source or destination revision control system) that
     should be used as the new parents for that node.
 
     The branchmap is a file that allows you to rename a branch when it is
     being brought in from whatever external repository. When used in
-    conjunction with a splicemap, it allows for a powerful combination
-    to help fix even the most badly mismanaged repositories and turn them
-    into nicely structured Mercurial repositories. The branchmap contains
-    lines of the form "original_branch_name new_branch_name".
-    "original_branch_name" is the name of the branch in the source
-    repository, and "new_branch_name" is the name of the branch is the
-    destination repository. This can be used to (for instance) move code
-    in one repository from "default" to a named branch.
+    conjunction with a splicemap, it allows for a powerful combination to help
+    fix even the most badly mismanaged repositories and turn them into nicely
+    structured Mercurial repositories. The branchmap contains lines of the
+    form "original_branch_name new_branch_name". "original_branch_name" is the
+    name of the branch in the source repository, and "new_branch_name" is the
+    name of the branch is the destination repository. This can be used to (for
+    instance) move code in one repository from "default" to a named branch.
 
     Mercurial Source
     -----------------
@@ -117,75 +114,73 @@
         repositories with missing revlogs, by converting from and to
         Mercurial.
     --config convert.hg.saverev=False         (boolean)
-        store original revision ID in changeset (forces target IDs to
-        change)
+        store original revision ID in changeset (forces target IDs to change)
     --config convert.hg.startrev=0            (hg revision identifier)
         convert start revision and its descendants
 
     CVS Source
     ----------
 
-    CVS source will use a sandbox (i.e. a checked-out copy) from CVS
-    to indicate the starting point of what will be converted. Direct
-    access to the repository files is not needed, unless of course the
-    repository is :local:. The conversion uses the top level directory
-    in the sandbox to find the CVS repository, and then uses CVS rlog
-    commands to find files to convert. This means that unless a
-    filemap is given, all files under the starting directory will be
-    converted, and that any directory reorganization in the CVS
-    sandbox is ignored.
+    CVS source will use a sandbox (i.e. a checked-out copy) from CVS to
+    indicate the starting point of what will be converted. Direct access to
+    the repository files is not needed, unless of course the repository is
+    :local:. The conversion uses the top level directory in the sandbox to
+    find the CVS repository, and then uses CVS rlog commands to find files to
+    convert. This means that unless a filemap is given, all files under the
+    starting directory will be converted, and that any directory
+    reorganization in the CVS sandbox is ignored.
 
     Because CVS does not have changesets, it is necessary to collect
-    individual commits to CVS and merge them into changesets. CVS
-    source uses its internal changeset merging code by default but can
-    be configured to call the external 'cvsps' program by setting:
+    individual commits to CVS and merge them into changesets. CVS source uses
+    its internal changeset merging code by default but can be configured to
+    call the external 'cvsps' program by setting:
+
         --config convert.cvsps='cvsps -A -u --cvs-direct -q'
+
     This option is deprecated and will be removed in Mercurial 1.4.
 
     The options shown are the defaults.
 
     Internal cvsps is selected by setting
+
         --config convert.cvsps=builtin
+
     and has a few more configurable options:
         --config convert.cvsps.cache=True     (boolean)
             Set to False to disable remote log caching, for testing and
             debugging purposes.
         --config convert.cvsps.fuzz=60        (integer)
-            Specify the maximum time (in seconds) that is allowed
-            between commits with identical user and log message in a
-            single changeset. When very large files were checked in as
-            part of a changeset then the default may not be long
-            enough.
+            Specify the maximum time (in seconds) that is allowed between
+            commits with identical user and log message in a single changeset.
+            When very large files were checked in as part of a changeset then
+            the default may not be long enough.
         --config convert.cvsps.mergeto='{{mergetobranch ([-\\w]+)}}'
-            Specify a regular expression to which commit log messages
-            are matched. If a match occurs, then the conversion
-            process will insert a dummy revision merging the branch on
-            which this log message occurs to the branch indicated in
-            the regex.
+            Specify a regular expression to which commit log messages are
+            matched. If a match occurs, then the conversion process will
+            insert a dummy revision merging the branch on which this log
+            message occurs to the branch indicated in the regex.
         --config convert.cvsps.mergefrom='{{mergefrombranch ([-\\w]+)}}'
-            Specify a regular expression to which commit log messages
-            are matched. If a match occurs, then the conversion
-            process will add the most recent revision on the branch
-            indicated in the regex as the second parent of the
-            changeset.
+            Specify a regular expression to which commit log messages are
+            matched. If a match occurs, then the conversion process will add
+            the most recent revision on the branch indicated in the regex as
+            the second parent of the changeset.
 
-    The hgext/convert/cvsps wrapper script allows the builtin
-    changeset merging code to be run without doing a conversion. Its
-    parameters and output are similar to that of cvsps 2.1.
+    The hgext/convert/cvsps wrapper script allows the builtin changeset
+    merging code to be run without doing a conversion. Its parameters and
+    output are similar to that of cvsps 2.1.
 
     Subversion Source
     -----------------
 
-    Subversion source detects classical trunk/branches/tags layouts.
-    By default, the supplied "svn://repo/path/" source URL is
-    converted as a single branch. If "svn://repo/path/trunk" exists it
-    replaces the default branch. If "svn://repo/path/branches" exists,
-    its subdirectories are listed as possible branches. If
-    "svn://repo/path/tags" exists, it is looked for tags referencing
-    converted branches. Default "trunk", "branches" and "tags" values
-    can be overridden with following options. Set them to paths
-    relative to the source URL, or leave them blank to disable auto
-    detection.
+    Subversion source detects classical trunk/branches/tags layouts. By
+    default, the supplied "svn://repo/path/" source URL is converted as a
+    single branch. If "svn://repo/path/trunk" exists it replaces the default
+    branch. If "svn://repo/path/branches" exists, its subdirectories are
+    listed as possible branches. If "svn://repo/path/tags" exists, it is
+    looked for tags referencing converted branches. Default "trunk",
+    "branches" and "tags" values can be overridden with following options. Set
+    them to paths relative to the source URL, or leave them blank to disable
+    auto detection.
 
     --config convert.svn.branches=branches    (directory name)
         specify the directory containing branches
@@ -194,9 +189,9 @@
     --config convert.svn.trunk=trunk          (directory name)
         specify the name of the trunk branch
 
-    Source history can be retrieved starting at a specific revision,
-    instead of being integrally converted. Only single branch
-    conversions are supported.
+    Source history can be retrieved starting at a specific revision, instead
+    of being integrally converted. Only single branch conversions are
+    supported.
 
     --config convert.svn.startrev=0           (svn revision number)
         specify start Subversion revision.
@@ -204,15 +199,14 @@
     Perforce Source
     ---------------
 
-    The Perforce (P4) importer can be given a p4 depot path or a
-    client specification as source. It will convert all files in the
-    source to a flat Mercurial repository, ignoring labels, branches
-    and integrations. Note that when a depot path is given you then
-    usually should specify a target directory, because otherwise the
-    target may be named ...-hg.
+    The Perforce (P4) importer can be given a p4 depot path or a client
+    specification as source. It will convert all files in the source to a flat
+    Mercurial repository, ignoring labels, branches and integrations. Note
+    that when a depot path is given you then usually should specify a target
+    directory, because otherwise the target may be named ...-hg.
 
-    It is possible to limit the amount of source history to be
-    converted by specifying an initial Perforce revision.
+    It is possible to limit the amount of source history to be converted by
+    specifying an initial Perforce revision.
 
     --config convert.p4.startrev=0            (perforce changelist number)
         specify initial Perforce revision.
@@ -237,14 +231,13 @@
 def debugcvsps(ui, *args, **opts):
     '''create changeset information from CVS
 
-    This command is intended as a debugging tool for the CVS to
-    Mercurial converter, and can be used as a direct replacement for
-    cvsps.
+    This command is intended as a debugging tool for the CVS to Mercurial
+    converter, and can be used as a direct replacement for cvsps.
 
-    Hg debugcvsps reads the CVS rlog for current directory (or any
-    named directory) in the CVS repository, and converts the log to a
-    series of changesets based on matching commit log entries and
-    dates.'''
+    Hg debugcvsps reads the CVS rlog for current directory (or any named
+    directory) in the CVS repository, and converts the log to a series of
+    changesets based on matching commit log entries and dates.
+    '''
     return cvsps.debugcvsps(ui, *args, **opts)
 
 commands.norepo += " convert debugsvnlog debugcvsps"
--- a/hgext/convert/cvs.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/convert/cvs.py	Wed Jul 08 17:03:50 2009 -0700
@@ -38,8 +38,8 @@
         self.lastbranch = {}
         self.parent = {}
         self.socket = None
-        self.cvsroot = file(os.path.join(cvs, "Root")).read()[:-1]
-        self.cvsrepo = file(os.path.join(cvs, "Repository")).read()[:-1]
+        self.cvsroot = open(os.path.join(cvs, "Root")).read()[:-1]
+        self.cvsrepo = open(os.path.join(cvs, "Repository")).read()[:-1]
         self.encoding = locale.getpreferredencoding()
 
         self._connect()
--- a/hgext/convert/cvsps.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/convert/cvsps.py	Wed Jul 08 17:03:50 2009 -0700
@@ -12,13 +12,6 @@
 from mercurial import util
 from mercurial.i18n import _
 
-def listsort(list, key):
-    "helper to sort by key in Python 2.3"
-    try:
-        list.sort(key=key)
-    except TypeError:
-        list.sort(lambda l, r: cmp(key(l), key(r)))
-
 class logentry(object):
     '''Class logentry has the following attributes:
         .author    - author name as CVS knows it
@@ -130,7 +123,7 @@
 
         # Get the real directory in the repository
         try:
-            prefix = file(os.path.join('CVS','Repository')).read().strip()
+            prefix = open(os.path.join('CVS','Repository')).read().strip()
             if prefix == ".":
                 prefix = ""
             directory = prefix
@@ -142,7 +135,7 @@
 
         # Use the Root file in the sandbox, if it exists
         try:
-            root = file(os.path.join('CVS','Root')).read().strip()
+            root = open(os.path.join('CVS','Root')).read().strip()
         except IOError:
             pass
 
@@ -175,7 +168,7 @@
     if cache == 'update':
         try:
             ui.note(_('reading cvs log cache %s\n') % cachefile)
-            oldlog = pickle.load(file(cachefile))
+            oldlog = pickle.load(open(cachefile))
             ui.note(_('cache has %d log entries\n') % len(oldlog))
         except Exception, e:
             ui.note(_('error reading cache: %r\n') % e)
@@ -419,7 +412,7 @@
             if len(log) % 100 == 0:
                 ui.status(util.ellipsis('%d %s' % (len(log), e.file), 80)+'\n')
 
-    listsort(log, key=lambda x:(x.rcs, x.revision))
+    log.sort(key=lambda x: (x.rcs, x.revision))
 
     # find parent revisions of individual files
     versions = {}
@@ -435,7 +428,7 @@
     if cache:
         if log:
             # join up the old and new logs
-            listsort(log, key=lambda x:x.date)
+            log.sort(key=lambda x: x.date)
 
             if oldlog and oldlog[-1].date >= log[0].date:
                 raise logerror('Log cache overlaps with new log entries,'
@@ -445,7 +438,7 @@
 
             # write the new cachefile
             ui.note(_('writing cvs log cache %s\n') % cachefile)
-            pickle.dump(log, file(cachefile, 'w'))
+            pickle.dump(log, open(cachefile, 'w'))
         else:
             log = oldlog
 
@@ -484,7 +477,7 @@
 
     # Merge changesets
 
-    listsort(log, key=lambda x:(x.comment, x.author, x.branch, x.date))
+    log.sort(key=lambda x: (x.comment, x.author, x.branch, x.date))
 
     changesets = []
     files = set()
--- a/hgext/convert/p4.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/convert/p4.py	Wed Jul 08 17:03:50 2009 -0700
@@ -92,7 +92,7 @@
 
         # list with depot pathnames, longest first
         vieworder = views.keys()
-        vieworder.sort(key=lambda x: -len(x))
+        vieworder.sort(key=len, reverse=True)
 
         # handle revision limiting
         startrev = self.ui.config('convert', 'p4.startrev', default=0)
--- a/hgext/convert/subversion.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/convert/subversion.py	Wed Jul 08 17:03:50 2009 -0700
@@ -2,7 +2,6 @@
 #
 # Copyright(C) 2007 Daniel Holth et al
 
-import locale
 import os
 import re
 import sys
--- a/hgext/extdiff.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/extdiff.py	Wed Jul 08 17:03:50 2009 -0700
@@ -7,14 +7,13 @@
 
 '''command to allow external programs to compare revisions
 
-The `extdiff' Mercurial extension allows you to use external programs
-to compare revisions, or revision with working directory. The external diff
-programs are called with a configurable set of options and two
-non-option arguments: paths to directories containing snapshots of
-files to compare.
+The `extdiff' Mercurial extension allows you to use external programs to
+compare revisions, or revision with working directory. The external diff
+programs are called with a configurable set of options and two non-option
+arguments: paths to directories containing snapshots of files to compare.
 
-The `extdiff' extension also allows to configure new diff commands, so
-you do not need to type "hg extdiff -p kdiff3" always.
+The `extdiff' extension also allows to configure new diff commands, so you do
+not need to type "hg extdiff -p kdiff3" always.
 
   [extdiff]
   # add new command that runs GNU diff(1) in 'context diff' mode
@@ -29,16 +28,15 @@
   # add new command called meld, runs meld (no need to name twice)
   meld =
 
-  # add new command called vimdiff, runs gvimdiff with DirDiff plugin
-  # (see http://www.vim.org/scripts/script.php?script_id=102)
-  # Non English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
-  # your .vimrc
+  # add new command called vimdiff, runs gvimdiff with DirDiff plugin (see
+  # http://www.vim.org/scripts/script.php?script_id=102) Non English user, be
+  # sure to put "let g:DirDiffDynamicDiffText = 1" in your .vimrc
   vimdiff = gvim -f '+next' '+execute "DirDiff" argv(0) argv(1)'
 
-You can use -I/-X and list of file or directory names like normal "hg
-diff" command. The `extdiff' extension makes snapshots of only needed
-files, so running the external diff program will actually be pretty
-fast (at least faster than having to compare the entire tree).
+You can use -I/-X and list of file or directory names like normal "hg diff"
+command. The `extdiff' extension makes snapshots of only needed files, so
+running the external diff program will actually be pretty fast (at least
+faster than having to compare the entire tree).
 '''
 
 from mercurial.i18n import _
@@ -159,20 +157,20 @@
 def extdiff(ui, repo, *pats, **opts):
     '''use external program to diff repository (or selected files)
 
-    Show differences between revisions for the specified files, using
-    an external program. The default program used is diff, with
-    default options "-Npru".
+    Show differences between revisions for the specified files, using an
+    external program. The default program used is diff, with default options
+    "-Npru".
 
-    To select a different program, use the -p/--program option. The
-    program will be passed the names of two directories to compare. To
-    pass additional options to the program, use -o/--option. These
-    will be passed before the names of the directories to compare.
+    To select a different program, use the -p/--program option. The program
+    will be passed the names of two directories to compare. To pass additional
+    options to the program, use -o/--option. These will be passed before the
+    names of the directories to compare.
 
-    When two revision arguments are given, then changes are shown
-    between those revisions. If only one revision is specified then
-    that revision is compared to the working directory, and, when no
-    revisions are specified, the working directory files are compared
-    to its parent.'''
+    When two revision arguments are given, then changes are shown between
+    those revisions. If only one revision is specified then that revision is
+    compared to the working directory, and, when no revisions are specified,
+    the working directory files are compared to its parent.
+    '''
     program = opts['program'] or 'diff'
     if opts['program']:
         option = opts['option']
@@ -211,18 +209,17 @@
             '''use closure to save diff command to use'''
             def mydiff(ui, repo, *pats, **opts):
                 return dodiff(ui, repo, path, diffopts, pats, opts)
-            mydiff.__doc__ = '''use %(path)s to diff repository (or selected files)
+            mydiff.__doc__ = _('''\
+use %(path)s to diff repository (or selected files)
 
-            Show differences between revisions for the specified
-            files, using the %(path)s program.
+    Show differences between revisions for the specified files, using the
+    %(path)s program.
 
-            When two revision arguments are given, then changes are
-            shown between those revisions. If only one revision is
-            specified then that revision is compared to the working
-            directory, and, when no revisions are specified, the
-            working directory files are compared to its parent.''' % {
-                'path': util.uirepr(path),
-                }
+    When two revision arguments are given, then changes are shown between
+    those revisions. If only one revision is specified then that revision is
+    compared to the working directory, and, when no revisions are specified,
+    the working directory files are compared to its parent.\
+''') % dict(path=util.uirepr(path))
             return mydiff
         cmdtable[cmd] = (save(cmd, path, diffopts),
                          cmdtable['extdiff'][1][1:],
--- a/hgext/fetch.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/fetch.py	Wed Jul 08 17:03:50 2009 -0700
@@ -15,18 +15,17 @@
 def fetch(ui, repo, source='default', **opts):
     '''pull changes from a remote repository, merge new changes if needed.
 
-    This finds all changes from the repository at the specified path
-    or URL and adds them to the local repository.
+    This finds all changes from the repository at the specified path or URL
+    and adds them to the local repository.
 
-    If the pulled changes add a new branch head, the head is
-    automatically merged, and the result of the merge is committed.
-    Otherwise, the working directory is updated to include the new
-    changes.
+    If the pulled changes add a new branch head, the head is automatically
+    merged, and the result of the merge is committed. Otherwise, the working
+    directory is updated to include the new changes.
 
     When a merge occurs, the newly pulled changes are assumed to be
-    "authoritative". The head of the new changes is used as the first
-    parent, with local changes as the second. To switch the merge
-    order, use --switch-parent.
+    "authoritative". The head of the new changes is used as the first parent,
+    with local changes as the second. To switch the merge order, use
+    --switch-parent.
 
     See 'hg help dates' for a list of formats valid for -d/--date.
     '''
--- a/hgext/graphlog.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/graphlog.py	Wed Jul 08 17:03:50 2009 -0700
@@ -8,8 +8,8 @@
 '''command to view revision graphs from a shell
 
 This extension adds a --graph option to the incoming, outgoing and log
-commands. When this options is given, an ASCII representation of the
-revision graph is also shown.
+commands. When this options is given, an ASCII representation of the revision
+graph is also shown.
 '''
 
 import os, sys
@@ -236,11 +236,10 @@
 def graphlog(ui, repo, path=None, **opts):
     """show revision history alongside an ASCII revision graph
 
-    Print a revision history alongside a revision graph drawn with
-    ASCII characters.
+    Print a revision history alongside a revision graph drawn with ASCII
+    characters.
 
-    Nodes printed as an @ character are parents of the working
-    directory.
+    Nodes printed as an @ character are parents of the working directory.
     """
 
     check_unsupported_flags(opts)
@@ -298,11 +297,10 @@
 def gincoming(ui, repo, source="default", **opts):
     """show the incoming changesets alongside an ASCII revision graph
 
-    Print the incoming changesets alongside a revision graph drawn with
-    ASCII characters.
+    Print the incoming changesets alongside a revision graph drawn with ASCII
+    characters.
 
-    Nodes printed as an @ character are parents of the working
-    directory.
+    Nodes printed as an @ character are parents of the working directory.
     """
 
     check_unsupported_flags(opts)
--- a/hgext/hgcia.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/hgcia.py	Wed Jul 08 17:03:50 2009 -0700
@@ -3,8 +3,8 @@
 
 """hooks for integrating with the CIA.vc notification service
 
-This is meant to be run as a changegroup or incoming hook.
-To configure it, set the following options in your hgrc:
+This is meant to be run as a changegroup or incoming hook. To configure it,
+set the following options in your hgrc:
 
 [cia]
 # your registered CIA user name
--- a/hgext/hgk.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/hgk.py	Wed Jul 08 17:03:50 2009 -0700
@@ -7,31 +7,31 @@
 
 '''browse the repository in a graphical way
 
-The hgk extension allows browsing the history of a repository in a
-graphical way. It requires Tcl/Tk version 8.4 or later. (Tcl/Tk is not
-distributed with Mercurial.)
+The hgk extension allows browsing the history of a repository in a graphical
+way. It requires Tcl/Tk version 8.4 or later. (Tcl/Tk is not distributed with
+Mercurial.)
 
-hgk consists of two parts: a Tcl script that does the displaying and
-querying of information, and an extension to Mercurial named hgk.py,
-which provides hooks for hgk to get information. hgk can be found in
-the contrib directory, and the extension is shipped in the hgext
-repository, and needs to be enabled.
+hgk consists of two parts: a Tcl script that does the displaying and querying
+of information, and an extension to Mercurial named hgk.py, which provides
+hooks for hgk to get information. hgk can be found in the contrib directory,
+and the extension is shipped in the hgext repository, and needs to be enabled.
 
-The hg view command will launch the hgk Tcl script. For this command
-to work, hgk must be in your search path. Alternately, you can specify
-the path to hgk in your .hgrc file:
+The hg view command will launch the hgk Tcl script. For this command to work,
+hgk must be in your search path. Alternately, you can specify the path to hgk
+in your .hgrc file:
 
   [hgk]
   path=/location/of/hgk
 
-hgk can make use of the extdiff extension to visualize revisions.
-Assuming you had already configured extdiff vdiff command, just add:
+hgk can make use of the extdiff extension to visualize revisions. Assuming you
+had already configured extdiff vdiff command, just add:
 
   [hgk]
   vdiff=vdiff
 
-Revisions context menu will now display additional entries to fire
-vdiff on hovered and selected revisions.'''
+Revisions context menu will now display additional entries to fire vdiff on
+hovered and selected revisions.
+'''
 
 import os
 from mercurial import commands, util, patch, revlog, cmdutil
--- a/hgext/highlight/__init__.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/highlight/__init__.py	Wed Jul 08 17:03:50 2009 -0700
@@ -10,8 +10,7 @@
 
 """syntax highlighting for hgweb (requires Pygments)
 
-It depends on the Pygments syntax highlighting library:
-http://pygments.org/
+It depends on the Pygments syntax highlighting library: http://pygments.org/
 
 There is a single configuration option:
 
--- a/hgext/interhg.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/interhg.py	Wed Jul 08 17:03:50 2009 -0700
@@ -10,12 +10,12 @@
 
 '''expand expressions into changelog and summaries
 
-This extension allows the use of a special syntax in summaries,
-which will be automatically expanded into links or any other
-arbitrary expression, much like InterWiki does.
+This extension allows the use of a special syntax in summaries, which will be
+automatically expanded into links or any other arbitrary expression, much like
+InterWiki does.
 
-A few example patterns (link to bug tracking, etc.) that may
-be used in your hgrc:
+A few example patterns (link to bug tracking, etc.) that may be used in your
+hgrc:
 
   [interhg]
   issues = s!issue(\\d+)!<a href="http://bts/issue\\1">issue\\1</a>!
--- a/hgext/keyword.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/keyword.py	Wed Jul 08 17:03:50 2009 -0700
@@ -28,15 +28,15 @@
 
 '''expand keywords in tracked files
 
-This extension expands RCS/CVS-like or self-customized $Keywords$ in
-tracked text files selected by your configuration.
+This extension expands RCS/CVS-like or self-customized $Keywords$ in tracked
+text files selected by your configuration.
 
-Keywords are only expanded in local repositories and not stored in the
-change history. The mechanism can be regarded as a convenience for the
-current user or for archive distribution.
+Keywords are only expanded in local repositories and not stored in the change
+history. The mechanism can be regarded as a convenience for the current user
+or for archive distribution.
 
-Configuration is done in the [keyword] and [keywordmaps] sections of
-hgrc files.
+Configuration is done in the [keyword] and [keywordmaps] sections of hgrc
+files.
 
 Example:
 
@@ -45,40 +45,39 @@
     **.py =
     x*    = ignore
 
-Note: the more specific you are in your filename patterns
-      the less you lose speed in huge repositories.
+Note: the more specific you are in your filename patterns the less you lose
+      speed in huge repositories.
 
-For [keywordmaps] template mapping and expansion demonstration and
-control run "hg kwdemo".
+For [keywordmaps] template mapping and expansion demonstration and control run
+"hg kwdemo".
 
 An additional date template filter {date|utcdate} is provided.
 
-The default template mappings (view with "hg kwdemo -d") can be
-replaced with customized keywords and templates. Again, run "hg
-kwdemo" to control the results of your config changes.
+The default template mappings (view with "hg kwdemo -d") can be replaced with
+customized keywords and templates. Again, run "hg kwdemo" to control the
+results of your config changes.
 
-Before changing/disabling active keywords, run "hg kwshrink" to avoid
-the risk of inadvertently storing expanded keywords in the change
-history.
+Before changing/disabling active keywords, run "hg kwshrink" to avoid the risk
+of inadvertently storing expanded keywords in the change history.
 
-To force expansion after enabling it, or a configuration change, run
-"hg kwexpand".
+To force expansion after enabling it, or a configuration change, run "hg
+kwexpand".
 
-Also, when committing with the record extension or using mq's qrecord,
-be aware that keywords cannot be updated. Again, run "hg kwexpand" on
-the files in question to update keyword expansions after all changes
-have been checked in.
+Also, when committing with the record extension or using mq's qrecord, be
+aware that keywords cannot be updated. Again, run "hg kwexpand" on the files
+in question to update keyword expansions after all changes have been checked
+in.
 
-Expansions spanning more than one line and incremental expansions,
-like CVS' $Log$, are not supported. A keyword template map
-"Log = {desc}" expands to the first line of the changeset description.
+Expansions spanning more than one line and incremental expansions, like CVS'
+$Log$, are not supported. A keyword template map "Log = {desc}" expands to the
+first line of the changeset description.
 '''
 
 from mercurial import commands, cmdutil, dispatch, filelog, revlog, extensions
 from mercurial import patch, localrepo, templater, templatefilters, util, match
 from mercurial.hgweb import webcommands
 from mercurial.lock import release
-from mercurial.node import nullid, hex
+from mercurial.node import nullid
 from mercurial.i18n import _
 import re, shutil, tempfile, time
 
@@ -125,9 +124,8 @@
 
         kwmaps = self.ui.configitems('keywordmaps')
         if kwmaps: # override default templates
-            kwmaps = [(k, templater.parsestring(v, False))
-                      for (k, v) in kwmaps]
-            self.templates = dict(kwmaps)
+            self.templates = dict((k, templater.parsestring(v, False))
+                                  for k, v in kwmaps)
         escaped = map(re.escape, self.templates.keys())
         kwpat = r'\$(%s)(: [^$\n\r]*? )??\$' % '|'.join(escaped)
         self.re_kw = re.compile(kwpat)
@@ -362,20 +360,19 @@
 def files(ui, repo, *pats, **opts):
     '''show files configured for keyword expansion
 
-    List which files in the working directory are matched by the
-    [keyword] configuration patterns.
+    List which files in the working directory are matched by the [keyword]
+    configuration patterns.
 
-    Useful to prevent inadvertent keyword expansion and to speed up
-    execution by including only files that are actual candidates
-    for expansion.
+    Useful to prevent inadvertent keyword expansion and to speed up execution
+    by including only files that are actual candidates for expansion.
 
-    See "hg help keyword" on how to construct patterns both for
-    inclusion and exclusion of files.
+    See "hg help keyword" on how to construct patterns both for inclusion and
+    exclusion of files.
 
     Use -u/--untracked to list untracked files as well.
 
-    With -a/--all and -v/--verbose the codes used to show the status
-    of files are:
+    With -a/--all and -v/--verbose the codes used to show the status of files
+    are:
     K = keyword expansion candidate
     k = keyword expansion candidate (untracked)
     I = ignored
@@ -495,7 +492,8 @@
                 release(lock, wlock)
 
     # monkeypatches
-    def kwpatchfile_init(orig, self, ui, fname, opener, missing=False, eol=None):
+    def kwpatchfile_init(orig, self, ui, fname, opener,
+                         missing=False, eol=None):
         '''Monkeypatch/wrap patch.patchfile.__init__ to avoid
         rejects or conflicts due to expanded keywords in working dir.'''
         orig(self, ui, fname, opener, missing, eol)
--- a/hgext/mq.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/mq.py	Wed Jul 08 17:03:50 2009 -0700
@@ -8,11 +8,11 @@
 '''manage a stack of patches
 
 This extension lets you work with a stack of patches in a Mercurial
-repository. It manages two stacks of patches - all known patches, and
-applied patches (subset of known patches).
+repository. It manages two stacks of patches - all known patches, and applied
+patches (subset of known patches).
 
-Known patches are represented as patch files in the .hg/patches
-directory. Applied patches are both patch files and changesets.
+Known patches are represented as patch files in the .hg/patches directory.
+Applied patches are both patch files and changesets.
 
 Common tasks (use "hg help command" for more details):
 
@@ -1343,19 +1343,24 @@
 
     def qseries(self, repo, missing=None, start=0, length=None, status=None,
                 summary=False):
-        def displayname(patchname):
+        def displayname(pfx, patchname):
             if summary:
                 ph = patchheader(self.join(patchname))
                 msg = ph.message
                 msg = msg and ': ' + msg[0] or ': '
             else:
                 msg = ''
-            return '%s%s' % (patchname, msg)
+            msg = "%s%s%s" % (pfx, patchname, msg)
+            if self.ui.interactive():
+                msg = util.ellipsis(msg, util.termwidth())
+            self.ui.write(msg + '\n')
 
         applied = set([p.name for p in self.applied])
         if length is None:
             length = len(self.series) - start
         if not missing:
+            if self.ui.verbose:
+                idxwidth = len(str(start+length - 1))
             for i in xrange(start, start+length):
                 patch = self.series[i]
                 if patch in applied:
@@ -1366,10 +1371,10 @@
                     stat = 'G'
                 pfx = ''
                 if self.ui.verbose:
-                    pfx = '%d %s ' % (i, stat)
+                    pfx = '%*d %s ' % (idxwidth, i, stat)
                 elif status and status != stat:
                     continue
-                self.ui.write('%s%s\n' % (pfx, displayname(patch)))
+                displayname(pfx, patch)
         else:
             msng_list = []
             for root, dirs, files in os.walk(self.path):
@@ -1383,7 +1388,7 @@
                         msng_list.append(fl)
             for x in sorted(msng_list):
                 pfx = self.ui.verbose and ('D ') or ''
-                self.ui.write("%s%s\n" % (pfx, displayname(x)))
+                displayname(pfx, x)
 
     def issaveline(self, l):
         if l.name == '.hg.patches.save.line':
@@ -1536,7 +1541,7 @@
                 raise util.Abort(_('option "-r" not valid when importing '
                                    'files'))
             rev = cmdutil.revrange(repo, rev)
-            rev.sort(lambda x, y: cmp(y, x))
+            rev.sort(reverse=True)
         if (len(files) > 1 or len(rev) > 1) and patchname:
             raise util.Abort(_('option "-n" not valid when importing multiple '
                                'patches'))
@@ -1676,29 +1681,26 @@
 def qimport(ui, repo, *filename, **opts):
     """import a patch
 
-    The patch is inserted into the series after the last applied
-    patch. If no patches have been applied, qimport prepends the patch
-    to the series.
+    The patch is inserted into the series after the last applied patch. If no
+    patches have been applied, qimport prepends the patch to the series.
 
-    The patch will have the same name as its source file unless you
-    give it a new one with -n/--name.
+    The patch will have the same name as its source file unless you give it a
+    new one with -n/--name.
 
-    You can register an existing patch inside the patch directory with
-    the -e/--existing flag.
+    You can register an existing patch inside the patch directory with the
+    -e/--existing flag.
 
-    With -f/--force, an existing patch of the same name will be
-    overwritten.
+    With -f/--force, an existing patch of the same name will be overwritten.
 
-    An existing changeset may be placed under mq control with -r/--rev
-    (e.g. qimport --rev tip -n patch will place tip under mq control).
-    With -g/--git, patches imported with --rev will use the git diff
-    format. See the diffs help topic for information on why this is
-    important for preserving rename/copy information and permission
-    changes.
+    An existing changeset may be placed under mq control with -r/--rev (e.g.
+    qimport --rev tip -n patch will place tip under mq control). With
+    -g/--git, patches imported with --rev will use the git diff format. See
+    the diffs help topic for information on why this is important for
+    preserving rename/copy information and permission changes.
 
-    To import a patch from standard input, pass - as the patch file.
-    When importing from standard input, a patch name must be specified
-    using the --name flag.
+    To import a patch from standard input, pass - as the patch file. When
+    importing from standard input, a patch name must be specified using the
+    --name flag.
     """
     q = repo.mq
     q.qimport(repo, filename, patchname=opts['name'],
@@ -1713,11 +1715,12 @@
 def init(ui, repo, **opts):
     """init a new queue repository
 
-    The queue repository is unversioned by default. If
-    -c/--create-repo is specified, qinit will create a separate nested
-    repository for patches (qinit -c may also be run later to convert
-    an unversioned patch repository into a versioned one). You can use
-    qcommit to commit changes to this queue repository."""
+    The queue repository is unversioned by default. If -c/--create-repo is
+    specified, qinit will create a separate nested repository for patches
+    (qinit -c may also be run later to convert an unversioned patch repository
+    into a versioned one). You can use qcommit to commit changes to this queue
+    repository.
+    """
     q = repo.mq
     r = q.init(repo, create=opts['create_repo'])
     q.save_dirty()
@@ -1739,17 +1742,16 @@
 def clone(ui, source, dest=None, **opts):
     '''clone main and patch repository at same time
 
-    If source is local, destination will have no patches applied. If
-    source is remote, this command can not check if patches are
-    applied in source, so cannot guarantee that patches are not
-    applied in destination. If you clone remote repository, be sure
-    before that it has no patches applied.
+    If source is local, destination will have no patches applied. If source is
+    remote, this command can not check if patches are applied in source, so
+    cannot guarantee that patches are not applied in destination. If you clone
+    remote repository, be sure before that it has no patches applied.
 
-    Source patch repository is looked for in <src>/.hg/patches by
-    default. Use -p <url> to change.
+    Source patch repository is looked for in <src>/.hg/patches by default. Use
+    -p <url> to change.
 
-    The patch directory must be a nested Mercurial repository, as
-    would be created by qinit -c.
+    The patch directory must be a nested Mercurial repository, as would be
+    created by qinit -c.
     '''
     def patchdir(repo):
         url = repo.url()
@@ -1855,26 +1857,24 @@
 def new(ui, repo, patch, *args, **opts):
     """create a new patch
 
-    qnew creates a new patch on top of the currently-applied patch (if
-    any). It will refuse to run if there are any outstanding changes
-    unless -f/--force is specified, in which case the patch will be
-    initialized with them. You may also use -I/--include,
-    -X/--exclude, and/or a list of files after the patch name to add
-    only changes to matching files to the new patch, leaving the rest
-    as uncommitted modifications.
+    qnew creates a new patch on top of the currently-applied patch (if any).
+    It will refuse to run if there are any outstanding changes unless
+    -f/--force is specified, in which case the patch will be initialized with
+    them. You may also use -I/--include, -X/--exclude, and/or a list of files
+    after the patch name to add only changes to matching files to the new
+    patch, leaving the rest as uncommitted modifications.
 
-    -u/--user and -d/--date can be used to set the (given) user and
-    date, respectively. -U/--currentuser and -D/--currentdate set user
-    to current user and date to current date.
+    -u/--user and -d/--date can be used to set the (given) user and date,
+    respectively. -U/--currentuser and -D/--currentdate set user to current
+    user and date to current date.
 
-    -e/--edit, -m/--message or -l/--logfile set the patch header as
-    well as the commit message. If none is specified, the header is
-    empty and the commit message is '[mq]: PATCH'.
+    -e/--edit, -m/--message or -l/--logfile set the patch header as well as
+    the commit message. If none is specified, the header is empty and the
+    commit message is '[mq]: PATCH'.
 
-    Use the -g/--git option to keep the patch in the git extended diff
-    format. Read the diffs help topic for more information on why this
-    is important for preserving permission changes and copy/rename
-    information.
+    Use the -g/--git option to keep the patch in the git extended diff format.
+    Read the diffs help topic for more information on why this is important
+    for preserving permission changes and copy/rename information.
     """
     msg = cmdutil.logmessage(opts)
     def getmsg(): return ui.edit(msg, ui.username())
@@ -1892,17 +1892,16 @@
 def refresh(ui, repo, *pats, **opts):
     """update the current patch
 
-    If any file patterns are provided, the refreshed patch will
-    contain only the modifications that match those patterns; the
-    remaining modifications will remain in the working directory.
+    If any file patterns are provided, the refreshed patch will contain only
+    the modifications that match those patterns; the remaining modifications
+    will remain in the working directory.
 
-    If -s/--short is specified, files currently included in the patch
-    will be refreshed just like matched files and remain in the patch.
+    If -s/--short is specified, files currently included in the patch will be
+    refreshed just like matched files and remain in the patch.
 
-    hg add/remove/copy/rename work as usual, though you might want to
-    use git-style patches (-g/--git or [diff] git=1) to track copies
-    and renames. See the diffs help topic for more information on the
-    git diff format.
+    hg add/remove/copy/rename work as usual, though you might want to use
+    git-style patches (-g/--git or [diff] git=1) to track copies and renames.
+    See the diffs help topic for more information on the git diff format.
     """
     q = repo.mq
     message = cmdutil.logmessage(opts)
@@ -1923,15 +1922,13 @@
 def diff(ui, repo, *pats, **opts):
     """diff of the current patch and subsequent modifications
 
-    Shows a diff which includes the current patch as well as any
-    changes which have been made in the working directory since the
-    last refresh (thus showing what the current patch would become
-    after a qrefresh).
+    Shows a diff which includes the current patch as well as any changes which
+    have been made in the working directory since the last refresh (thus
+    showing what the current patch would become after a qrefresh).
 
-    Use 'hg diff' if you only want to see the changes made since the
-    last qrefresh, or 'hg export qtip' if you want to see changes made
-    by the current patch without including changes made since the
-    qrefresh.
+    Use 'hg diff' if you only want to see the changes made since the last
+    qrefresh, or 'hg export qtip' if you want to see changes made by the
+    current patch without including changes made since the qrefresh.
     """
     repo.mq.diff(repo, pats, opts)
     return 0
@@ -1939,15 +1936,15 @@
 def fold(ui, repo, *files, **opts):
     """fold the named patches into the current patch
 
-    Patches must not yet be applied. Each patch will be successively
-    applied to the current patch in the order given. If all the
-    patches apply successfully, the current patch will be refreshed
-    with the new cumulative patch, and the folded patches will be
-    deleted. With -k/--keep, the folded patch files will not be
-    removed afterwards.
+    Patches must not yet be applied. Each patch will be successively applied
+    to the current patch in the order given. If all the patches apply
+    successfully, the current patch will be refreshed with the new cumulative
+    patch, and the folded patches will be deleted. With -k/--keep, the folded
+    patch files will not be removed afterwards.
 
-    The header for each folded patch will be concatenated with the
-    current patch header, separated by a line of '* * *'."""
+    The header for each folded patch will be concatenated with the current
+    patch header, separated by a line of '* * *'.
+    """
 
     q = repo.mq
 
@@ -2013,14 +2010,13 @@
 def guard(ui, repo, *args, **opts):
     '''set or print guards for a patch
 
-    Guards control whether a patch can be pushed. A patch with no
-    guards is always pushed. A patch with a positive guard ("+foo") is
-    pushed only if the qselect command has activated it. A patch with
-    a negative guard ("-foo") is never pushed if the qselect command
-    has activated it.
+    Guards control whether a patch can be pushed. A patch with no guards is
+    always pushed. A patch with a positive guard ("+foo") is pushed only if
+    the qselect command has activated it. A patch with a negative guard
+    ("-foo") is never pushed if the qselect command has activated it.
 
-    With no arguments, print the currently active guards.
-    With arguments, set guards for the named patch.
+    With no arguments, print the currently active guards. With arguments, set
+    guards for the named patch.
     NOTE: Specifying negative guards now requires '--'.
 
     To set guards on another patch:
@@ -2097,8 +2093,8 @@
 def push(ui, repo, patch=None, **opts):
     """push the next patch onto the stack
 
-    When -f/--force is applied, all local changes in patched files
-    will be lost.
+    When -f/--force is applied, all local changes in patched files will be
+    lost.
     """
     q = repo.mq
     mergeq = None
@@ -2120,9 +2116,9 @@
 def pop(ui, repo, patch=None, **opts):
     """pop the current patch off the stack
 
-    By default, pops off the top of the patch stack. If given a patch
-    name, keeps popping off patches until the named patch is at the
-    top of the stack.
+    By default, pops off the top of the patch stack. If given a patch name,
+    keeps popping off patches until the named patch is at the top of the
+    stack.
     """
     localupdate = True
     if opts['name']:
@@ -2239,8 +2235,7 @@
     """strip a revision and all its descendants from the repository
 
     If one of the working directory's parent revisions is stripped, the
-    working directory will be updated to the parent of the stripped
-    revision.
+    working directory will be updated to the parent of the stripped revision.
     """
     backup = 'all'
     if opts['backup']:
@@ -2265,35 +2260,33 @@
 def select(ui, repo, *args, **opts):
     '''set or print guarded patches to push
 
-    Use the qguard command to set or print guards on patch, then use
-    qselect to tell mq which guards to use. A patch will be pushed if
-    it has no guards or any positive guards match the currently
-    selected guard, but will not be pushed if any negative guards
-    match the current guard. For example:
+    Use the qguard command to set or print guards on patch, then use qselect
+    to tell mq which guards to use. A patch will be pushed if it has no guards
+    or any positive guards match the currently selected guard, but will not be
+    pushed if any negative guards match the current guard. For example:
 
         qguard foo.patch -stable    (negative guard)
         qguard bar.patch +stable    (positive guard)
         qselect stable
 
-    This activates the "stable" guard. mq will skip foo.patch (because
-    it has a negative match) but push bar.patch (because it has a
-    positive match).
+    This activates the "stable" guard. mq will skip foo.patch (because it has
+    a negative match) but push bar.patch (because it has a positive match).
 
-    With no arguments, prints the currently active guards.
-    With one argument, sets the active guard.
+    With no arguments, prints the currently active guards. With one argument,
+    sets the active guard.
 
-    Use -n/--none to deactivate guards (no other arguments needed).
-    When no guards are active, patches with positive guards are
-    skipped and patches with negative guards are pushed.
+    Use -n/--none to deactivate guards (no other arguments needed). When no
+    guards are active, patches with positive guards are skipped and patches
+    with negative guards are pushed.
 
-    qselect can change the guards on applied patches. It does not pop
-    guarded patches by default. Use --pop to pop back to the last
-    applied patch that is not guarded. Use --reapply (which implies
-    --pop) to push back to the current patch afterwards, but skip
-    guarded patches.
+    qselect can change the guards on applied patches. It does not pop guarded
+    patches by default. Use --pop to pop back to the last applied patch that
+    is not guarded. Use --reapply (which implies --pop) to push back to the
+    current patch afterwards, but skip guarded patches.
 
-    Use -s/--series to print a list of all guards in the series file
-    (no other arguments needed). Use -v for more information.'''
+    Use -s/--series to print a list of all guards in the series file (no other
+    arguments needed). Use -v for more information.
+    '''
 
     q = repo.mq
     guards = q.active()
@@ -2329,7 +2322,7 @@
         if ui.verbose:
             guards['NONE'] = noguards
         guards = guards.items()
-        guards.sort(lambda a, b: cmp(a[0][1:], b[0][1:]))
+        guards.sort(key=lambda x: x[0][1:])
         if guards:
             ui.note(_('guards in series file:\n'))
             for guard, count in guards:
@@ -2368,18 +2361,16 @@
 def finish(ui, repo, *revrange, **opts):
     """move applied patches into repository history
 
-    Finishes the specified revisions (corresponding to applied
-    patches) by moving them out of mq control into regular repository
-    history.
+    Finishes the specified revisions (corresponding to applied patches) by
+    moving them out of mq control into regular repository history.
 
-    Accepts a revision range or the -a/--applied option. If --applied
-    is specified, all applied mq revisions are removed from mq
-    control. Otherwise, the given revisions must be at the base of the
-    stack of applied patches.
+    Accepts a revision range or the -a/--applied option. If --applied is
+    specified, all applied mq revisions are removed from mq control.
+    Otherwise, the given revisions must be at the base of the stack of applied
+    patches.
 
-    This can be especially useful if your changes have been applied to
-    an upstream repository, or if you are about to push your changes
-    to upstream.
+    This can be especially useful if your changes have been applied to an
+    upstream repository, or if you are about to push your changes to upstream.
     """
     if not opts['applied'] and not revrange:
         raise util.Abort(_('no revisions specified'))
--- a/hgext/notify.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/notify.py	Wed Jul 08 17:03:50 2009 -0700
@@ -7,8 +7,8 @@
 
 '''hooks for sending email notifications at commit/push time
 
-Subscriptions can be managed through hgrc. Default mode is to print
-messages to stdout, for testing and configuring.
+Subscriptions can be managed through hgrc. Default mode is to print messages
+to stdout, for testing and configuring.
 
 To use, configure notify extension and enable in hgrc like this:
 
@@ -47,9 +47,8 @@
    [web]
    baseurl = http://hgserver/... # root of hg web site for browsing commits
 
- notify config file has same format as regular hgrc. it has two
- sections so you can express subscriptions in whatever way is handier
- for you.
+ notify config file has same format as regular hgrc. it has two sections so
+ you can express subscriptions in whatever way is handier for you.
 
    [usersubs]
    # key is subscriber email, value is ","-separated list of glob patterns
@@ -61,8 +60,9 @@
 
  glob patterns are matched against path to repository root.
 
- if you like, you can put notify config file in repository that users
- can push changes to, they can manage their own subscriptions.'''
+ if you like, you can put notify config file in repository that users can push
+ changes to, they can manage their own subscriptions.
+'''
 
 from mercurial.i18n import _
 from mercurial import patch, cmdutil, templater, util, mail
--- a/hgext/pager.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/pager.py	Wed Jul 08 17:03:50 2009 -0700
@@ -19,11 +19,10 @@
   [pager]
   pager = LESS='FSRX' less
 
-If no pager is set, the pager extensions uses the environment variable
-$PAGER. If neither pager.pager, nor $PAGER is set, no pager is used.
+If no pager is set, the pager extensions uses the environment variable $PAGER.
+If neither pager.pager, nor $PAGER is set, no pager is used.
 
-If you notice "BROKEN PIPE" error messages, you can disable them by
-setting:
+If you notice "BROKEN PIPE" error messages, you can disable them by setting:
 
   [pager]
   quiet = True
@@ -34,16 +33,15 @@
   [pager]
   ignore = version, help, update
 
-You can also enable the pager only for certain commands using
-pager.attend:
+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
+To ignore global commands like "hg version" or "hg help", you have to specify
+them in the global .hgrc
 '''
 
 import sys, os, signal
--- a/hgext/parentrevspec.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/parentrevspec.py	Wed Jul 08 17:03:50 2009 -0700
@@ -7,8 +7,8 @@
 
 '''interpret suffixes to refer to ancestor revisions
 
-This extension allows you to use git-style suffixes to refer to the
-ancestors of a specific revision.
+This extension allows you to use git-style suffixes to refer to the ancestors
+of a specific revision.
 
 For example, if you can refer to a revision as "foo", then:
 
--- a/hgext/patchbomb.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/patchbomb.py	Wed Jul 08 17:03:50 2009 -0700
@@ -10,9 +10,9 @@
 The series is started off with a "[PATCH 0 of N]" introduction, which
 describes the series as a whole.
 
-Each patch email has a Subject line of "[PATCH M of N] ...", using the
-first line of the changeset description as the subject text. The
-message contains two or three body parts:
+Each patch email has a Subject line of "[PATCH M of N] ...", using the first
+line of the changeset description as the subject text. The message contains
+two or three body parts:
 
   The changeset description.
 
@@ -20,16 +20,15 @@
 
   The patch itself, as generated by "hg export".
 
-Each message refers to the first in the series using the In-Reply-To
-and References headers, so they will show up as a sequence in threaded
-mail and news readers, and in mail archives.
+Each message refers to the first in the series using the In-Reply-To and
+References headers, so they will show up as a sequence in threaded mail and
+news readers, and in mail archives.
 
-With the -d/--diffstat option, you will be prompted for each changeset
-with a diffstat summary and the changeset summary, so you can be sure
-you are sending the right changes.
+With the -d/--diffstat option, you will be prompted for each changeset with a
+diffstat summary and the changeset summary, so you can be sure you are sending
+the right changes.
 
-To configure other defaults, add a section like this to your hgrc
-file:
+To configure other defaults, add a section like this to your hgrc file:
 
   [email]
   from = My Name <my@email>
@@ -37,40 +36,38 @@
   cc = cc1, cc2, ...
   bcc = bcc1, bcc2, ...
 
-Then you can use the "hg email" command to mail a series of changesets
-as a patchbomb.
+Then you can use the "hg email" command to mail a series of changesets as a
+patchbomb.
 
-To avoid sending patches prematurely, it is a good idea to first run
-the "email" command with the "-n" option (test only). You will be
-prompted for an email recipient address, a subject and an introductory
-message describing the patches of your patchbomb. Then when all is
-done, patchbomb messages are displayed. If the PAGER environment
-variable is set, your pager will be fired up once for each patchbomb
-message, so you can verify everything is alright.
+To avoid sending patches prematurely, it is a good idea to first run the
+"email" command with the "-n" option (test only). You will be prompted for an
+email recipient address, a subject and an introductory message describing the
+patches of your patchbomb. Then when all is done, patchbomb messages are
+displayed. If the PAGER environment variable is set, your pager will be fired
+up once for each patchbomb message, so you can verify everything is alright.
 
-The -m/--mbox option is also very useful. Instead of previewing each
-patchbomb message in a pager or sending the messages directly, it will
-create a UNIX mailbox file with the patch emails. This mailbox file
-can be previewed with any mail user agent which supports UNIX mbox
-files, e.g. with mutt:
+The -m/--mbox option is also very useful. Instead of previewing each patchbomb
+message in a pager or sending the messages directly, it will create a UNIX
+mailbox file with the patch emails. This mailbox file can be previewed with
+any mail user agent which supports UNIX mbox files, e.g. with mutt:
 
   % mutt -R -f mbox
 
-When you are previewing the patchbomb messages, you can use `formail'
-(a utility that is commonly installed as part of the procmail
-package), to send each message out:
+When you are previewing the patchbomb messages, you can use `formail' (a
+utility that is commonly installed as part of the procmail package), to send
+each message out:
 
   % formail -s sendmail -bm -t < mbox
 
 That should be all. Now your patchbomb is on its way out.
 
-You can also either configure the method option in the email section
-to be a sendmail compatible mailer or fill out the [smtp] section so
-that the patchbomb extension can automatically send patchbombs
-directly from the commandline. See the [email] and [smtp] sections in
-hgrc(5) for details.'''
+You can also either configure the method option in the email section to be a
+sendmail compatible mailer or fill out the [smtp] section so that the
+patchbomb extension can automatically send patchbombs directly from the
+commandline. See the [email] and [smtp] sections in hgrc(5) for details.
+'''
 
-import os, errno, socket, tempfile, cStringIO
+import os, errno, socket, tempfile, cStringIO, time
 import email.MIMEMultipart, email.MIMEBase
 import email.Utils, email.Encoders, email.Generator
 from mercurial import cmdutil, commands, hg, mail, patch, util
@@ -176,30 +173,27 @@
 def patchbomb(ui, repo, *revs, **opts):
     '''send changesets by email
 
-    By default, diffs are sent in the format generated by hg export,
-    one per message. The series starts with a "[PATCH 0 of N]"
-    introduction, which describes the series as a whole.
+    By default, diffs are sent in the format generated by hg export, one per
+    message. The series starts with a "[PATCH 0 of N]" introduction, which
+    describes the series as a whole.
 
-    Each patch email has a Subject line of "[PATCH M of N] ...", using
-    the first line of the changeset description as the subject text.
-    The message contains two or three parts. First, the changeset
-    description. Next, (optionally) if the diffstat program is
-    installed and -d/--diffstat is used, the result of running
-    diffstat on the patch. Finally, the patch itself, as generated by
-    "hg export".
+    Each patch email has a Subject line of "[PATCH M of N] ...", using the
+    first line of the changeset description as the subject text. The message
+    contains two or three parts. First, the changeset description. Next,
+    (optionally) if the diffstat program is installed and -d/--diffstat is
+    used, the result of running diffstat on the patch. Finally, the patch
+    itself, as generated by "hg export".
 
-    By default the patch is included as text in the email body for
-    easy reviewing. Using the -a/--attach option will instead create
-    an attachment for the patch. With -i/--inline an inline attachment
-    will be created.
+    By default the patch is included as text in the email body for easy
+    reviewing. Using the -a/--attach option will instead create an attachment
+    for the patch. With -i/--inline an inline attachment will be created.
 
-    With -o/--outgoing, emails will be generated for patches not found
-    in the destination repository (or only those which are ancestors
-    of the specified revisions if any are provided)
+    With -o/--outgoing, emails will be generated for patches not found in the
+    destination repository (or only those which are ancestors of the specified
+    revisions if any are provided)
 
-    With -b/--bundle, changesets are selected as for --outgoing, but a
-    single email containing a binary Mercurial bundle as an attachment
-    will be sent.
+    With -b/--bundle, changesets are selected as for --outgoing, but a single
+    email containing a binary Mercurial bundle as an attachment will be sent.
 
     Examples:
 
@@ -218,8 +212,8 @@
     hg email -b -r 3000       # bundle of all ancestors of 3000 not in default
     hg email -b -r 3000 DEST  # bundle of all ancestors of 3000 not in DEST
 
-    Before using this command, you will need to enable email in your
-    hgrc. See the [email] section in hgrc(5) for details.
+    Before using this command, you will need to enable email in your hgrc. See
+    the [email] section in hgrc(5) for details.
     '''
 
     _charsets = mail._charsets(ui)
@@ -417,7 +411,7 @@
             first = False
 
         m['User-Agent'] = 'Mercurial-patchbomb/%s' % util.version()
-        m['Date'] = email.Utils.formatdate(start_time[0])
+        m['Date'] = email.Utils.formatdate(start_time[0], localtime=True)
 
         start_time = (start_time[0] + 1, start_time[1])
         m['From'] = sender
@@ -446,7 +440,7 @@
             ui.status(_('Writing '), subj, ' ...\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')
+            date = time.ctime(start_time[0])
             fp.write('From %s %s\n' % (sender_addr, date))
             generator.flatten(m, 0)
             fp.write('\n\n')
--- a/hgext/purge.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/purge.py	Wed Jul 08 17:03:50 2009 -0700
@@ -32,13 +32,13 @@
 def purge(ui, repo, *dirs, **opts):
     '''removes files not tracked by Mercurial
 
-    Delete files not known to Mercurial. This is useful to test local
-    and uncommitted changes in an otherwise-clean source tree.
+    Delete files not known to Mercurial. This is useful to test local and
+    uncommitted changes in an otherwise-clean source tree.
 
     This means that purge will delete:
      - Unknown files: files marked with "?" by "hg status"
-     - Empty directories: in fact Mercurial ignores directories unless
-       they contain files under source control management
+     - Empty directories: in fact Mercurial ignores directories unless they
+       contain files under source control management
     But it will leave untouched:
      - Modified and unmodified tracked files
      - Ignored files (unless --all is specified)
@@ -47,10 +47,9 @@
     If directories are given on the command line, only files in these
     directories are considered.
 
-    Be careful with purge, as you could irreversibly delete some files
-    you forgot to add to the repository. If you only want to print the
-    list of files that this program would delete, use the --print
-    option.
+    Be careful with purge, as you could irreversibly delete some files you
+    forgot to add to the repository. If you only want to print the list of
+    files that this program would delete, use the --print option.
     '''
     act = not opts['print']
     eol = '\n'
--- a/hgext/rebase.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/rebase.py	Wed Jul 08 17:03:50 2009 -0700
@@ -7,8 +7,7 @@
 
 '''command to move sets of revisions to a different ancestor
 
-This extension lets you rebase changesets in an existing Mercurial
-repository.
+This extension lets you rebase changesets in an existing Mercurial repository.
 
 For more information:
 http://mercurial.selenic.com/wiki/RebaseProject
@@ -42,9 +41,9 @@
 def rebase(ui, repo, **opts):
     """move changeset (and descendants) to a different branch
 
-    Rebase uses repeated merging to graft changesets from one part of
-    history onto another. This can be useful for linearizing local
-    changes relative to a master development tree.
+    Rebase uses repeated merging to graft changesets from one part of history
+    onto another. This can be useful for linearizing local changes relative to
+    a master development tree.
 
     If a rebase is interrupted to manually resolve a merge, it can be
     continued with --continue/-c or aborted with --abort/-a.
--- a/hgext/record.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/record.py	Wed Jul 08 17:03:50 2009 -0700
@@ -291,25 +291,28 @@
                     _('Record &all changes to all remaining files'),
                     _('&Quit, recording no changes'),
                     _('&?'))
-            r = (ui.prompt("%s %s " % (query, resps), choices)
-                 or _('y')).lower()
-            if r == _('?'):
+            r = ui.promptchoice("%s %s " % (query, resps), choices)
+            if r == 7: # ?
                 doc = gettext(record.__doc__)
                 c = doc.find(_('y - record this change'))
                 for l in doc[c:].splitlines():
                     if l: ui.write(l.strip(), '\n')
                 continue
-            elif r == _('s'):
-                r = resp_file[0] = 'n'
-            elif r == _('f'):
-                r = resp_file[0] = 'y'
-            elif r == _('d'):
-                r = resp_all[0] = 'n'
-            elif r == _('a'):
-                r = resp_all[0] = 'y'
-            elif r == _('q'):
+            elif r == 0: # yes
+                ret = 'y'
+            elif r == 1: # no
+                ret = 'n'
+            elif r == 2: # Skip
+                ret = resp_file[0] = 'n'
+            elif r == 3: # file (Record remaining)
+                ret = resp_file[0] = 'y'
+            elif r == 4: # done, skip remaining
+                ret = resp_all[0] = 'n'
+            elif r == 5: # all
+                ret = resp_all[0] = 'y'
+            elif r == 6: # quit
                 raise util.Abort(_('user quit'))
-            return r
+            return ret
     pos, total = 0, len(chunks) - 1
     while chunks:
         chunk = chunks.pop()
@@ -354,15 +357,14 @@
 def record(ui, repo, *pats, **opts):
     '''interactively select changes to commit
 
-    If a list of files is omitted, all changes reported by "hg status"
-    will be candidates for recording.
+    If a list of files is omitted, all changes reported by "hg status" will be
+    candidates for recording.
 
     See 'hg help dates' for a list of formats valid for -d/--date.
 
-    You will be prompted for whether to record changes to each
-    modified file, and for files with multiple changes, for each
-    change to use. For each query, the following responses are
-    possible:
+    You will be prompted for whether to record changes to each modified file,
+    and for files with multiple changes, for each change to use. For each
+    query, the following responses are possible:
 
     y - record this change
     n - skip this change
@@ -385,8 +387,7 @@
 def qrecord(ui, repo, patch, *pats, **opts):
     '''interactively record a new patch
 
-    See 'hg help qnew' & 'hg help record' for more information and
-    usage.
+    See 'hg help qnew' & 'hg help record' for more information and usage.
     '''
 
     try:
--- a/hgext/share.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/share.py	Wed Jul 08 17:03:50 2009 -0700
@@ -5,18 +5,17 @@
 
 '''share a common history between several working directories'''
 
-import os
 from mercurial.i18n import _
 from mercurial import hg, commands
 
 def share(ui, source, dest=None, noupdate=False):
     """create a new shared repository (experimental)
 
-    Initialize a new repository and working directory that shares its
-    history with another repository.
+    Initialize a new repository and working directory that shares its history
+    with another repository.
 
-    NOTE: actions that change history such as rollback or moving the
-    source may confuse sharers.
+    NOTE: actions that change history such as rollback or moving the source
+    may confuse sharers.
     """
 
     return hg.share(ui, source, dest, not noupdate)
--- a/hgext/transplant.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/transplant.py	Wed Jul 08 17:03:50 2009 -0700
@@ -9,8 +9,8 @@
 
 This extension allows you to transplant patches from another branch.
 
-Transplanted patches are recorded in .hg/transplant/transplants, as a
-map from a changeset hash to its hash in the source repository.
+Transplanted patches are recorded in .hg/transplant/transplants, as a map from
+a changeset hash to its hash in the source repository.
 '''
 
 from mercurial.i18n import _
@@ -437,37 +437,34 @@
     '''transplant changesets from another branch
 
     Selected changesets will be applied on top of the current working
-    directory with the log of the original changeset. If --log is
-    specified, log messages will have a comment appended of the form:
+    directory with the log of the original changeset. If --log is specified,
+    log messages will have a comment appended of the form:
 
     (transplanted from CHANGESETHASH)
 
-    You can rewrite the changelog message with the --filter option.
-    Its argument will be invoked with the current changelog message as
-    $1 and the patch as $2.
+    You can rewrite the changelog message with the --filter option. Its
+    argument will be invoked with the current changelog message as $1 and the
+    patch as $2.
 
-    If --source/-s is specified, selects changesets from the named
-    repository. If --branch/-b is specified, selects changesets from
-    the branch holding the named revision, up to that revision. If
-    --all/-a is specified, all changesets on the branch will be
-    transplanted, otherwise you will be prompted to select the
-    changesets you want.
+    If --source/-s is specified, selects changesets from the named repository.
+    If --branch/-b is specified, selects changesets from the branch holding
+    the named revision, up to that revision. If --all/-a is specified, all
+    changesets on the branch will be transplanted, otherwise you will be
+    prompted to select the changesets you want.
 
-    hg transplant --branch REVISION --all will rebase the selected
-    branch (up to the named revision) onto your current working
-    directory.
+    hg transplant --branch REVISION --all will rebase the selected branch (up
+    to the named revision) onto your current working directory.
 
     You can optionally mark selected transplanted changesets as merge
-    changesets. You will not be prompted to transplant any ancestors
-    of a merged transplant, and you can merge descendants of them
-    normally instead of transplanting them.
+    changesets. You will not be prompted to transplant any ancestors of a
+    merged transplant, and you can merge descendants of them normally instead
+    of transplanting them.
 
-    If no merges or revisions are provided, hg transplant will start
-    an interactive changeset browser.
+    If no merges or revisions are provided, hg transplant will start an
+    interactive changeset browser.
 
-    If a changeset application fails, you can fix the merge by hand
-    and then resume where you left off by calling hg transplant
-    --continue/-c.
+    If a changeset application fails, you can fix the merge by hand and then
+    resume where you left off by calling hg transplant --continue/-c.
     '''
     def getremotechanges(repo, url):
         sourcerepo = ui.expandpath(url)
--- a/hgext/win32mbcs.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/win32mbcs.py	Wed Jul 08 17:03:50 2009 -0700
@@ -11,12 +11,11 @@
 
 '''allow the use of MBCS paths with problematic encodings
 
-Some MBCS encodings are not good for some path operations (i.e.
-splitting path, case conversion, etc.) with its encoded bytes. We call
-such a encoding (i.e. shift_jis and big5) as "problematic encoding".
-This extension can be used to fix the issue with those encodings by
-wrapping some functions to convert to Unicode string before path
-operation.
+Some MBCS encodings are not good for some path operations (i.e. splitting
+path, case conversion, etc.) with its encoded bytes. We call such a encoding
+(i.e. shift_jis and big5) as "problematic encoding". This extension can be
+used to fix the issue with those encodings by wrapping some functions to
+convert to Unicode string before path operation.
 
 This extension is useful for:
  * Japanese Windows users using shift_jis encoding.
@@ -30,12 +29,10 @@
 
 Note that there are some limitations on using this extension:
  * You should use single encoding in one repository.
- * You should set same encoding for the repository by locale or
-   HGENCODING.
+ * You should set same encoding for the repository by locale or HGENCODING.
 
-Path encoding conversion are done between Unicode and
-encoding.encoding which is decided by Mercurial from current locale
-setting or HGENCODING.
+Path encoding conversion are done between Unicode and encoding.encoding which
+is decided by Mercurial from current locale setting or HGENCODING.
 '''
 
 import os
--- a/hgext/zeroconf/__init__.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/hgext/zeroconf/__init__.py	Wed Jul 08 17:03:50 2009 -0700
@@ -7,12 +7,12 @@
 
 '''discover and advertise repositories on the local network
 
-Zeroconf enabled repositories will be announced in a network without
-the need to configure a server or a service. They can be discovered
-without knowing their actual IP address.
+Zeroconf enabled repositories will be announced in a network without the need
+to configure a server or a service. They can be discovered without knowing
+their actual IP address.
 
-To allow other people to discover your repository using run "hg serve"
-in your repository.
+To allow other people to discover your repository using run "hg serve" in your
+repository.
 
  $ cd test
  $ hg serve
--- a/mercurial/byterange.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/byterange.py	Wed Jul 08 17:03:50 2009 -0700
@@ -208,7 +208,7 @@
     """
     def open_local_file(self, req):
         import mimetypes
-        import mimetools
+        import email
         host = req.get_host()
         file = req.get_selector()
         localfile = urllib.url2pathname(file)
@@ -232,9 +232,9 @@
                 raise RangeError('Requested Range Not Satisfiable')
             size = (lb - fb)
             fo = RangeableFileObject(fo, (fb, lb))
-        headers = mimetools.Message(StringIO(
+        headers = email.message_from_string(
             'Content-Type: %s\nContent-Length: %d\nLast-Modified: %s\n' %
-            (mtype or 'text/plain', size, modified)))
+            (mtype or 'text/plain', size, modified))
         return urllib.addinfourl(fo, headers, 'file:'+file)
 
 
@@ -251,7 +251,7 @@
 import socket
 import sys
 import mimetypes
-import mimetools
+import email
 
 class FTPRangeHandler(urllib2.FTPHandler):
     def ftp_open(self, req):
@@ -325,8 +325,7 @@
                 headers += "Content-Type: %s\n" % mtype
             if retrlen is not None and retrlen >= 0:
                 headers += "Content-Length: %d\n" % retrlen
-            sf = StringIO(headers)
-            headers = mimetools.Message(sf)
+            headers = email.message_from_string(headers)
             return addinfourl(fp, headers, req.get_full_url())
         except ftplib.all_errors, msg:
             raise IOError('ftp error', msg), sys.exc_info()[2]
--- a/mercurial/commands.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/commands.py	Wed Jul 08 17:03:50 2009 -0700
@@ -8,9 +8,9 @@
 from node import hex, nullid, nullrev, short
 from lock import release
 from i18n import _, gettext
-import os, re, sys, subprocess, difflib, time
+import os, re, sys, subprocess, difflib, time, tempfile
 import hg, util, revlog, bundlerepo, extensions, copies, context, error
-import patch, help, mdiff, tempfile, url, encoding
+import patch, help, mdiff, url, encoding
 import archival, changegroup, cmdutil, sshserver, hbisect
 from hgweb import server
 import merge as merge_
@@ -20,11 +20,10 @@
 def add(ui, repo, *pats, **opts):
     """add the specified files on the next commit
 
-    Schedule files to be version controlled and added to the
-    repository.
-
-    The files will be added to the repository at the next commit. To
-    undo an add before that, see hg forget.
+    Schedule files to be version controlled and added to the repository.
+
+    The files will be added to the repository at the next commit. To undo an
+    add before that, see hg forget.
 
     If no names are given, add all files to the repository.
     """
@@ -49,19 +48,16 @@
 def addremove(ui, repo, *pats, **opts):
     """add all new files, delete all missing files
 
-    Add all new files and remove all missing files from the
-    repository.
-
-    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/--similarity 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 between 0 (disabled) and 100 (files must be
-    identical) as its parameter. Detecting renamed files this way can
-    be expensive.
+    Add all new files and remove all missing files from the repository.
+
+    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/--similarity option to detect renamed files. With a parameter
+    greater than 0, this compares every removed file with every added file and
+    records 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.
     """
     try:
         sim = float(opts.get('similarity') or 0)
@@ -74,16 +70,13 @@
 def annotate(ui, repo, *pats, **opts):
     """show changeset information by line for each file
 
-    List changes in files, showing the revision id responsible for
-    each line
-
-    This command is useful for discovering when a change was made and
-    by whom.
-
-    Without the -a/--text option, annotate will avoid processing files
-    it detects as binary. With -a, annotate will annotate the file
-    anyway, although the results will probably be neither useful
-    nor desirable.
+    List changes in files, showing the revision id responsible for each line
+
+    This command is useful for discovering when a change was made and by whom.
+
+    Without the -a/--text option, annotate will avoid processing files it
+    detects as binary. With -a, annotate will annotate the file anyway,
+    although the results will probably be neither useful nor desirable.
     """
     datefunc = ui.quiet and util.shortdate or util.datestr
     getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
@@ -137,11 +130,10 @@
 def archive(ui, repo, dest, **opts):
     '''create an unversioned archive of a repository revision
 
-    By default, the revision used is the parent of the working
-    directory; use -r/--rev to specify a different revision.
-
-    To specify the type of archive to create, use -t/--type. Valid
-    types are:
+    By default, the revision used is the parent of the working directory; use
+    -r/--rev to specify a different revision.
+
+    To specify the type of archive to create, use -t/--type. Valid types are:
 
     "files" (default): a directory full of files
     "tar": tar archive, uncompressed
@@ -150,13 +142,12 @@
     "uzip": zip archive, uncompressed
     "zip": zip archive, compressed using deflate
 
-    The exact name of the destination archive or directory is given
-    using a format string; see 'hg help export' for details.
-
-    Each member added to an archive file has a directory prefix
-    prepended. Use -p/--prefix to specify a format string for the
-    prefix. The default is the basename of the archive, with suffixes
-    removed.
+    The exact name of the destination archive or directory is given using a
+    format string; see 'hg help export' for details.
+
+    Each member added to an archive file has a directory prefix prepended. Use
+    -p/--prefix to specify a format string for the prefix. The default is the
+    basename of the archive, with suffixes removed.
     '''
 
     ctx = repo[opts.get('rev')]
@@ -181,17 +172,17 @@
 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
-    changeset is a child of the backed out changeset.
-
-    If you backout a changeset other than the tip, a new head is
-    created. This head will be the new tip and you should merge this
-    backout changeset with another head.
-
-    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 with a normal merge.
+    Commit the backed out changes as a new changeset. The new changeset is a
+    child of the backed out changeset.
+
+    If you backout a changeset other than the tip, a new head is created. This
+    head will be the new tip and you should merge this backout changeset with
+    another head.
+
+    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 with a normal merge.
 
     See 'hg help dates' for a list of formats valid for -d/--date.
     '''
@@ -268,23 +259,22 @@
                reset=None, good=None, bad=None, skip=None, noupdate=None):
     """subdivision search of changesets
 
-    This command helps to find changesets which introduce problems. To
-    use, mark the earliest changeset you know exhibits the problem as
-    bad, then mark the latest changeset which is free from the problem
-    as good. Bisect will update your working directory to a revision
-    for testing (unless the -U/--noupdate option is specified). Once
-    you have performed tests, mark the working directory as good or
-    bad, and bisect will either update to another candidate changeset
-    or announce that it has found the bad revision.
-
-    As a shortcut, you can also use the revision argument to mark a
-    revision as good or bad without checking it out first.
-
-    If you supply a command, it will be used for automatic bisection.
-    Its exit status will be used to mark revisions as good or bad:
-    status 0 means good, 125 means to skip the revision, 127
-    (command not found) will abort the bisection, and any other
-    non-zero exit status means the revision is bad.
+    This command helps to find changesets which introduce problems. To use,
+    mark the earliest changeset you know exhibits the problem as bad, then
+    mark the latest changeset which is free from the problem as good. Bisect
+    will update your working directory to a revision for testing (unless the
+    -U/--noupdate option is specified). Once you have performed tests, mark
+    the working directory as good or bad, and bisect will either update to
+    another candidate changeset or announce that it has found the bad
+    revision.
+
+    As a shortcut, you can also use the revision argument to mark a revision
+    as good or bad without checking it out first.
+
+    If you supply a command, it will be used for automatic bisection. Its exit
+    status will be used to mark revisions as good or bad: status 0 means good,
+    125 means to skip the revision, 127 (command not found) will abort the
+    bisection, and any other non-zero exit status means the revision is bad.
     """
     def print_result(nodes, good):
         displayer = cmdutil.show_changeset(ui, repo, {})
@@ -396,8 +386,8 @@
         while size <= changesets:
             tests, size = tests + 1, size * 2
         rev = repo.changelog.rev(node)
-        ui.write(_("Testing changeset %s:%s "
-                   "(%s changesets remaining, ~%s tests)\n")
+        ui.write(_("Testing changeset %d:%s "
+                   "(%d changesets remaining, ~%d tests)\n")
                  % (rev, short(node), changesets, tests))
         if not noupdate:
             cmdutil.bail_if_changed(repo)
@@ -406,21 +396,19 @@
 def branch(ui, repo, label=None, **opts):
     """set or show the current branch name
 
-    With no argument, show the current branch name. With one argument,
-    set the working directory branch name (the branch will not exist
-    in the repository until the next commit). Standard practice
-    recommends that primary development take place on the 'default'
-    branch.
-
-    Unless -f/--force is specified, branch will not let you set a
-    branch name that already exists, even if it's inactive.
-
-    Use -C/--clean to reset the working directory branch to that of
-    the parent of the working directory, negating a previous branch
-    change.
-
-    Use the command 'hg update' to switch to an existing branch. Use
-    'hg commit --close-branch' to mark this branch as closed.
+    With no argument, show the current branch name. With one argument, set the
+    working directory branch name (the branch will not exist in the repository
+    until the next commit). Standard practice recommends that primary
+    development take place on the 'default' branch.
+
+    Unless -f/--force is specified, branch will not let you set a branch name
+    that already exists, even if it's inactive.
+
+    Use -C/--clean to reset the working directory branch to that of the parent
+    of the working directory, negating a previous branch change.
+
+    Use the command 'hg update' to switch to an existing branch. Use 'hg
+    commit --close-branch' to mark this branch as closed.
     """
 
     if opts.get('clean'):
@@ -440,12 +428,12 @@
 def branches(ui, repo, active=False, closed=False):
     """list repository named branches
 
-    List the repository's named branches, indicating which ones are
-    inactive. If -c/--closed is specified, also list branches which have
-    been marked closed (see hg commit --close-branch).
-
-    If -a/--active is specified, only show active branches. A branch
-    is considered active if it contains repository heads.
+    List the repository's named branches, indicating which ones are inactive.
+    If -c/--closed is specified, also list branches which have been marked
+    closed (see hg commit --close-branch).
+
+    If -a/--active is specified, only show active branches. A branch is
+    considered active if it contains repository heads.
 
     Use the command 'hg update' to switch to an existing branch.
     """
@@ -482,25 +470,24 @@
 def bundle(ui, repo, fname, dest=None, **opts):
     """create a changegroup file
 
-    Generate a compressed changegroup file collecting changesets not
-    known to be in another repository.
-
-    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
-    -a/--all (or --base null).
-
-    You can change compression method with the -t/--type option.
-    The available compression methods are: none, bzip2, and
-    gzip (by default, bundles are compressed using bzip2).
-
-    The bundle file can then be transferred using conventional means
-    and applied to another repository with the unbundle or pull
-    command. This is useful when direct push and pull are not
-    available or when exporting an entire repository is undesirable.
-
-    Applying bundles preserves all changeset contents including
-    permissions, copy/rename information, and revision history.
+    Generate a compressed changegroup file collecting changesets not known to
+    be in another repository.
+
+    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 -a/--all (or --base null).
+
+    You can change compression method with the -t/--type option. The available
+    compression methods are: none, bzip2, and gzip (by default, bundles are
+    compressed using bzip2).
+
+    The bundle file can then be transferred using conventional means and
+    applied to another repository with the unbundle or pull command. This is
+    useful when direct push and pull are not available or when exporting an
+    entire repository is undesirable.
+
+    Applying bundles preserves all changeset contents including permissions,
+    copy/rename information, and revision history.
     """
     revs = opts.get('rev') or None
     if revs:
@@ -557,13 +544,13 @@
 def cat(ui, repo, file1, *pats, **opts):
     """output the current or given revision of files
 
-    Print the specified files as they were at the given revision. If
-    no revision is given, the parent of the working directory is used,
-    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
-    for the export command, with the following additions:
+    Print the specified files as they were at the given revision. If no
+    revision is given, the parent of the working directory is used, 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 for the export
+    command, with the following additions:
 
     %s   basename of file being printed
     %d   dirname of file being printed, or '.' if in repository root
@@ -586,47 +573,42 @@
 
     Create a copy of an existing repository in a new directory.
 
-    If no destination directory name is specified, it defaults to the
-    basename of the source.
-
-    The location of the source is added to the new repository's
-    .hg/hgrc file, as the default to be used for future pulls.
-
-    If you use the -r/--rev option to clone up to a specific revision,
-    no subsequent revisions (including subsequent tags) will be
-    present in the cloned repository. This option implies --pull, even
-    on local repositories.
-
-    By default, clone will check out the head of the 'default' branch.
-    If the -U/--noupdate option is used, the new clone will contain
-    only a repository (.hg) and no working copy (the working copy
-    parent is the null revision).
+    If no destination directory name is specified, it defaults to the basename
+    of the source.
+
+    The location of the source is added to the new repository's .hg/hgrc file,
+    as the default to be used for future pulls.
+
+    If you use the -r/--rev option to clone up to a specific revision, no
+    subsequent revisions (including subsequent tags) will be present in the
+    cloned repository. This option implies --pull, even on local repositories.
+
+    By default, clone will check out the head of the 'default' branch. If the
+    -U/--noupdate option is used, the new clone will contain only a repository
+    (.hg) and no working copy (the working copy parent is the null revision).
 
     See 'hg help urls' for valid source format details.
 
     It is possible to specify an ssh:// URL as the destination, but no
-    .hg/hgrc and working directory will be created on the remote side.
-    Please see 'hg help urls' for important details about ssh:// URLs.
-
-    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
-    filesystems, such as AFS, implement hardlinking incorrectly, but
-    do not report errors. In these cases, use the --pull option to
-    avoid hardlinking.
-
-    In some cases, you can clone repositories and checked out files
-    using full hardlinks with
+    .hg/hgrc and working directory will be created on the remote side. Please
+    see 'hg help urls' for important details about ssh:// URLs.
+
+    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 filesystems, such as
+    AFS, implement hardlinking incorrectly, but do not report errors. In these
+    cases, use the --pull option to avoid hardlinking.
+
+    In some cases, you can clone repositories and checked out files using full
+    hardlinks with
 
       $ cp -al REPO REPOCLONE
 
-    This is the fastest way to clone, but it is not always safe. The
-    operation is not atomic (making sure REPO is not modified during
-    the operation is up to you) and you have to make sure your editor
-    breaks hardlinks (Emacs and most Linux Kernel tools do so). Also,
-    this is not compatible with certain extensions that place their
-    metadata under the .hg directory, such as mq.
-
+    This is the fastest way to clone, but it is not always safe. The operation
+    is not atomic (making sure REPO is not modified during the operation is up
+    to you) and you have to make sure your editor breaks hardlinks (Emacs and
+    most Linux Kernel tools do so). Also, this is not compatible with certain
+    extensions that place their metadata under the .hg directory, such as mq.
     """
     hg.clone(cmdutil.remoteui(ui, opts), source, dest,
              pull=opts.get('pull'),
@@ -638,17 +620,17 @@
     """commit the specified files or all outstanding changes
 
     Commit changes to the given files into the repository. Unlike a
-    centralized RCS, this operation is a local operation. See hg push
-    for a way to actively distribute your changes.
-
-    If a list of files is omitted, all changes reported by "hg status"
-    will be committed.
-
-    If you are committing the result of a merge, do not provide any
-    filenames or -I/-X filters.
-
-    If no commit message is specified, the configured editor is
-    started to prompt you for a message.
+    centralized RCS, this operation is a local operation. See hg push for a
+    way to actively distribute your changes.
+
+    If a list of files is omitted, all changes reported by "hg status" will be
+    committed.
+
+    If you are committing the result of a merge, do not provide any filenames
+    or -I/-X filters.
+
+    If no commit message is specified, the configured editor is started to
+    prompt you for a message.
 
     See 'hg help dates' for a list of formats valid for -d/--date.
     """
@@ -686,16 +668,16 @@
 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,
-    the source must be a single file.
-
-    By default, this command copies the contents of files as they
-    exist in the working directory. If invoked with -A/--after, the
-    operation is recorded, but no copying is performed.
-
-    This command takes effect with the next commit. To undo a copy
-    before that, see hg revert.
+    Mark dest as having copies of source files. If dest is a directory, copies
+    are put in that directory. If dest is a file, the source must be a single
+    file.
+
+    By default, this command copies the contents of files as they exist in the
+    working directory. If invoked with -A/--after, the operation is recorded,
+    but no copying is performed.
+
+    This command takes effect with the next commit. To undo a copy before
+    that, see hg revert.
     """
     wlock = repo.wlock(False)
     try:
@@ -750,7 +732,7 @@
     ui.write("%s\n" % "\n".join(sorted(cmdlist)))
 
 def debugfsinfo(ui, path = "."):
-    file('.debugfsinfo', 'w').write('')
+    open('.debugfsinfo', 'w').write('')
     ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
     ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
     ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
@@ -798,14 +780,14 @@
 
     With no arguments, print names and values of all config items.
 
-    With one argument of the form section.name, print just the value
-    of that config item.
-
-    With multiple arguments, print names and values of all config
-    items with matching section names.
-
-    With --debug, the source (filename and line number) is printed
-    for each config item.
+    With one argument of the form section.name, print just the value of that
+    config item.
+
+    With multiple arguments, print names and values of all config items with
+    matching section names.
+
+    With --debug, the source (filename and line number) is printed for each
+    config item.
     """
 
     untrusted = bool(opts.get('untrusted'))
@@ -832,8 +814,8 @@
 def debugsetparents(ui, repo, rev1, rev2=None):
     """manually set the parents of the current working directory
 
-    This is useful for writing repository conversion tools, but should
-    be used with care.
+    This is useful for writing repository conversion tools, but should be used
+    with care.
     """
 
     if not rev2:
@@ -983,7 +965,7 @@
         if list(files) != [os.path.basename(fa)]:
             ui.write(_(" unexpected patch output!\n"))
             patchproblems += 1
-        a = file(fa).read()
+        a = open(fa).read()
         if a != b:
             ui.write(_(" patch test failed!\n"))
             patchproblems += 1
@@ -1067,22 +1049,21 @@
 
     Differences between files are shown using the unified diff format.
 
-    NOTE: diff may generate unexpected results for merges, as it will
-    default to comparing against the working directory's first parent
-    changeset if no revisions are specified.
-
-    When two revision arguments are given, then changes are shown
-    between those revisions. If only one revision is specified then
-    that revision is compared to the working directory, and, when no
-    revisions are specified, the working directory files are compared
-    to its parent.
-
-    Without the -a/--text option, diff will avoid generating diffs of
-    files it detects as binary. With -a, diff will generate a diff
-    anyway, probably with undesirable results.
-
-    Use the -g/--git option to generate diffs in the git extended diff
-    format. For more information, read 'hg help diffs'.
+    NOTE: diff may generate unexpected results for merges, as it will default
+    to comparing against the working directory's first parent changeset if no
+    revisions are specified.
+
+    When two revision arguments are given, then changes are shown between
+    those revisions. If only one revision is specified then that revision is
+    compared to the working directory, and, when no revisions are specified,
+    the working directory files are compared to its parent.
+
+    Without the -a/--text option, diff will avoid generating diffs of files it
+    detects as binary. With -a, diff will generate a diff anyway, probably
+    with undesirable results.
+
+    Use the -g/--git option to generate diffs in the git extended diff format.
+    For more information, read 'hg help diffs'.
     """
 
     revs = opts.get('rev')
@@ -1107,15 +1088,14 @@
 
     Print the changeset header and diffs for one or more revisions.
 
-    The information shown in the changeset header is: author,
-    changeset hash, parent(s) and commit comment.
-
-    NOTE: export may generate unexpected diff output for merge
-    changesets, 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:
+    The information shown in the changeset header is: author, changeset hash,
+    parent(s) and commit comment.
+
+    NOTE: export may generate unexpected diff output for merge changesets, 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:
 
     %%   literal "%" character
     %H   changeset hash (40 bytes of hexadecimal)
@@ -1126,15 +1106,15 @@
     %n   zero-padded sequence number, starting at 1
     %r   zero-padded changeset revision number
 
-    Without the -a/--text option, export will avoid generating diffs
-    of files it detects as binary. With -a, export will generate a
-    diff anyway, probably with undesirable results.
-
-    Use the -g/--git option to generate diffs in the git extended diff
-    format. See 'hg help diffs' for more information.
-
-    With the --switch-parent option, the diff will be against the
-    second parent. It can be useful to review a merge.
+    Without the -a/--text option, export will avoid generating diffs of files
+    it detects as binary. With -a, export will generate a diff anyway,
+    probably with undesirable results.
+
+    Use the -g/--git option to generate diffs in the git extended diff format.
+    See 'hg help diffs' for more information.
+
+    With the --switch-parent option, the diff will be against the second
+    parent. It can be useful to review a merge.
     """
     if not changesets:
         raise util.Abort(_("export requires at least one changeset"))
@@ -1150,12 +1130,11 @@
 def forget(ui, repo, *pats, **opts):
     """forget the specified files on the next commit
 
-    Mark the specified files so they will no longer be tracked
-    after the next commit.
-
-    This only removes files from the current branch, not from the
-    entire project history, and it does not delete them from the
-    working directory.
+    Mark the specified files so they will no longer be tracked after the next
+    commit.
+
+    This only removes files from the current branch, not from the entire
+    project history, and it does not delete them from the working directory.
 
     To undo a forget before the next commit, see hg add.
     """
@@ -1184,15 +1163,13 @@
     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 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
-    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.
+    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 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.
     """
     reflags = 0
     if opts.get('ignore_case'):
@@ -1366,23 +1343,23 @@
 
     With no arguments, show all repository head changesets.
 
-    Repository "heads" are changesets that don't have child
-    changesets. They are where development generally takes place and
-    are the usual targets for update and merge operations.
-
-    If one or more REV is given, the "branch heads" will be shown for
-    the named branch associated with that revision. The name of the
-    branch is called the revision's branch tag.
-
-    Branch heads are revisions on a given named branch that do not have
-    any descendants on the same branch. A branch head could be a true head
-    or it could be the last changeset on a branch before a new branch
-    was created. If none of the branch heads are true heads, the branch
-    is considered inactive. If -c/--closed is specified, also show branch
-    heads marked closed (see hg commit --close-branch).
-
-    If STARTREV is specified only those heads (or branch heads) that
-    are descendants of STARTREV will be displayed.
+    Repository "heads" are changesets that don't have child changesets. They
+    are where development generally takes place and are the usual targets for
+    update and merge operations.
+
+    If one or more REV is given, the "branch heads" will be shown for the
+    named branch associated with that revision. The name of the branch is
+    called the revision's branch tag.
+
+    Branch heads are revisions on a given named branch that do not have any
+    descendants on the same branch. A branch head could be a true head or it
+    could be the last changeset on a branch before a new branch was created.
+    If none of the branch heads are true heads, the branch is considered
+    inactive. If -c/--closed is specified, also show branch heads marked
+    closed (see hg commit --close-branch).
+
+    If STARTREV is specified only those heads (or branch heads) that are
+    descendants of STARTREV will be displayed.
     """
     if opts.get('rev'):
         start = repo.lookup(opts['rev'])
@@ -1428,8 +1405,8 @@
 
     With no arguments, print a list of commands with short help messages.
 
-    Given a topic, extension, or command name, print help for that
-    topic."""
+    Given a topic, extension, or command name, print help for that topic.
+    """
     option_lists = []
 
     def addglobalopts(aliases):
@@ -1457,7 +1434,10 @@
         try:
             aliases, i = cmdutil.findcmd(name, table, False)
         except error.AmbiguousCommand, inst:
-            select = lambda c: c.lstrip('^').startswith(inst.args[0])
+            # py3k fix: except vars can't be used outside the scope of the
+            # except block, nor can be used inside a lambda. python issue4617
+            prefix = inst.args[0]
+            select = lambda c: c.lstrip('^').startswith(prefix)
             helplist(_('list of commands:\n\n'), select)
             return
 
@@ -1634,16 +1614,15 @@
              rev=None, num=None, id=None, branch=None, tags=None):
     """identify the working copy or specified revision
 
-    With no revision, print a summary of the current state of the
-    repository.
-
-    Specifying a path to a repository root or Mercurial bundle will
-    cause lookup to operate on that repository/bundle.
-
-    This summary identifies the repository state using one or two
-    parent hash identifiers, followed by a "+" if there are
-    uncommitted changes in the working directory, a list of tags for
-    this revision and a branch name for non-default branches.
+    With no revision, print a summary of the current state of the repository.
+
+    Specifying a path to a repository root or Mercurial bundle will cause
+    lookup to operate on that repository/bundle.
+
+    This summary identifies the repository state using one or two parent hash
+    identifiers, followed by a "+" if there are uncommitted changes in the
+    working directory, a list of tags for this revision and a branch name for
+    non-default branches.
     """
 
     if not repo and not source:
@@ -1710,33 +1689,31 @@
 
     Import a list of patches and commit them individually.
 
-    If there are outstanding changes in the working directory, import
-    will abort unless given the -f/--force flag.
-
-    You can import a patch straight from a mail message. Even patches
-    as attachments work (to use the body part, it must have type
-    text/plain or text/x-patch). 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 given on command line with -m/--message and -u/--user
-    override these.
-
-    If --exact is specified, import will set the working directory to
-    the parent of each patch before applying it, and will abort if the
-    resulting changeset has a different ID than the one recorded in
-    the patch. This may happen due to character set problems or other
-    deficiencies in the text patch format.
-
-    With -s/--similarity, hg will attempt to discover renames and
-    copies in the patch in the same way as 'addremove'.
-
-    To read a patch from standard input, use "-" as the patch name. If
-    a URL is specified, the patch will be downloaded from it.
-    See 'hg help dates' for a list of formats valid for -d/--date.
+    If there are outstanding changes in the working directory, import will
+    abort unless given the -f/--force flag.
+
+    You can import a patch straight from a mail message. Even patches as
+    attachments work (to use the body part, it must have type text/plain or
+    text/x-patch). 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 given on
+    command line with -m/--message and -u/--user override these.
+
+    If --exact is specified, import will set the working directory to the
+    parent of each patch before applying it, and will abort if the resulting
+    changeset has a different ID than the one recorded in the patch. This may
+    happen due to character set problems or other deficiencies in the text
+    patch format.
+
+    With -s/--similarity, hg will attempt to discover renames and copies in
+    the patch in the same way as 'addremove'.
+
+    To read a patch from standard input, use "-" as the patch name. If a URL
+    is specified, the patch will be downloaded from it. See 'hg help dates'
+    for a list of formats valid for -d/--date.
     """
     patches = (patch1,) + patches
 
@@ -1836,12 +1813,12 @@
 def incoming(ui, repo, source="default", **opts):
     """show new changesets found in source
 
-    Show new changesets found in the specified path/URL or the default
-    pull location. These are the changesets that would have been pulled
-    if a pull at the time you issued this command.
-
-    For remote repository, using --bundle avoids downloading the
-    changesets twice if the incoming is followed by a pull.
+    Show new changesets found in the specified path/URL or the default pull
+    location. These are the changesets that would have been pulled if a pull
+    at the time you issued this command.
+
+    For remote repository, using --bundle avoids downloading the changesets
+    twice if the incoming is followed by a pull.
 
     See pull for valid source format details.
     """
@@ -1905,33 +1882,33 @@
 def init(ui, dest=".", **opts):
     """create a new repository in the given directory
 
-    Initialize a new repository in the given directory. If the given
-    directory does not exist, it will be created.
+    Initialize a new repository in the given directory. If the given directory
+    does not exist, it will be created.
 
     If no directory is given, the current directory is used.
 
-    It is possible to specify an ssh:// URL as the destination.
-    See 'hg help urls' for more information.
+    It is possible to specify an ssh:// URL as the destination. See 'hg help
+    urls' for more information.
     """
     hg.repository(cmdutil.remoteui(ui, opts), dest, create=1)
 
 def locate(ui, repo, *pats, **opts):
     """locate files matching specific patterns
 
-    Print files under Mercurial control in the working directory whose
-    names match the given patterns.
+    Print files under Mercurial control in the working directory whose names
+    match the given patterns.
 
     By default, this command searches all directories in the working
-    directory. To search just the current directory and its
-    subdirectories, use "--include .".
-
-    If no patterns are given to match, this command prints the names
-    of all files under Mercurial control in the working directory.
-
-    If you want to feed the output of this command into the "xargs"
-    command, use the -0 option to both this command and "xargs". This
-    will avoid the problem of "xargs" treating single filenames that
-    contain whitespace as multiple filenames.
+    directory. To search just the current directory and its subdirectories,
+    use "--include .".
+
+    If no patterns are given to match, this command prints the names of all
+    files under Mercurial control in the working directory.
+
+    If you want to feed the output of this command into the "xargs" command,
+    use the -0 option to both this command and "xargs". This will avoid the
+    problem of "xargs" treating single filenames that contain whitespace as
+    multiple filenames.
     """
     end = opts.get('print0') and '\0' or '\n'
     rev = opts.get('rev') or None
@@ -1953,30 +1930,29 @@
 def log(ui, repo, *pats, **opts):
     """show revision history of entire repository or files
 
-    Print the revision history of the specified files or the entire
-    project.
-
-    File history is shown without following rename or copy history of
-    files. Use -f/--follow with a filename to follow history across
-    renames and copies. --follow without a filename will only show
-    ancestors or descendants of the starting revision. --follow-first
-    only follows the first parent of merge revisions.
-
-    If no revision range is specified, the default is tip:0 unless
-    --follow is set, in which case the working directory parent is
-    used as the starting revision.
+    Print the revision history of the specified files or the entire project.
+
+    File history is shown without following rename or copy history of files.
+    Use -f/--follow with a filename to follow history across renames and
+    copies. --follow without a filename will only show ancestors or
+    descendants of the starting revision. --follow-first only follows the
+    first parent of merge revisions.
+
+    If no revision range is specified, the default is tip:0 unless --follow is
+    set, in which case the working directory parent is used as the starting
+    revision.
 
     See 'hg help dates' for a list of formats valid for -d/--date.
 
-    By default this command prints revision number and changeset id,
-    tags, non-trivial parents, user, date and time, and a summary for
-    each commit. When the -v/--verbose switch is used, the list of
-    changed files and full commit message are shown.
+    By default this command prints revision number and changeset id, tags,
+    non-trivial parents, user, date and time, and a summary for each commit.
+    When the -v/--verbose switch is used, the list of changed files and full
+    commit message are shown.
 
     NOTE: log -p/--patch may generate unexpected diff output for merge
-    changesets, as it will only compare the merge changeset against
-    its first parent. Also, only files different from BOTH parents
-    will appear in files:.
+    changesets, as it will only compare the merge changeset against its first
+    parent. Also, only files different from BOTH parents will appear in
+    files:.
     """
 
     get = util.cachefunc(lambda r: repo[r].changeset())
@@ -2079,9 +2055,9 @@
 def manifest(ui, repo, node=None, rev=None):
     """output the current or given revision of the project manifest
 
-    Print a list of version controlled files for the given revision.
-    If no revision is given, the first parent of the working directory
-    is used, or the null revision if no revision is checked out.
+    Print a list of version controlled files for the given revision. If no
+    revision is given, the first parent of the working directory is used, or
+    the null revision if no revision is checked out.
 
     With -v, print file permissions, symlink and executable bits.
     With --debug, print file revision hashes.
@@ -2105,18 +2081,17 @@
 def merge(ui, repo, node=None, **opts):
     """merge working directory with another revision
 
-    The current working directory is updated with all changes made in
-    the requested revision since the last common predecessor revision.
-
-    Files that changed between either parent are marked as changed for
-    the next commit and a commit must be performed before any further
-    updates to the repository are allowed. The next commit will have
-    two parents.
-
-    If no revision is specified, the working directory's parent is a
-    head revision, and the current branch contains exactly one other
-    head, the other head is merged with by default. Otherwise, an
-    explicit revision with which to merge with must be provided.
+    The current working directory is updated with all changes made in the
+    requested revision since the last common predecessor revision.
+
+    Files that changed between either parent are marked as changed for the
+    next commit and a commit must be performed before any further updates to
+    the repository are allowed. The next commit will have two parents.
+
+    If no revision is specified, the working directory's parent is a head
+    revision, and the current branch contains exactly one other head, the
+    other head is merged with by default. Otherwise, an explicit revision with
+    which to merge with must be provided.
     """
 
     if opts.get('rev') and node:
@@ -2163,9 +2138,9 @@
 def outgoing(ui, repo, dest=None, **opts):
     """show changesets not found in destination
 
-    Show changesets not found in the specified destination repository
-    or the default push location. These are the changesets that would
-    be pushed if a push was requested.
+    Show changesets not found in the specified destination repository or the
+    default push location. These are the changesets that would be pushed if a
+    push was requested.
 
     See pull for valid destination format details.
     """
@@ -2198,11 +2173,10 @@
 def parents(ui, repo, file_=None, **opts):
     """show the parents of the working directory or revision
 
-    Print the working directory's parent revisions. If a revision is
-    given via -r/--rev, the parent of that revision will be printed.
-    If a file argument is given, the revision in which the file was
-    last changed (before the working directory revision or the
-    argument to --rev if given) is printed.
+    Print the working directory's parent revisions. If a revision is given via
+    -r/--rev, the parent of that revision will be printed. If a file argument
+    is given, the revision in which the file was last changed (before the
+    working directory revision or the argument to --rev if given) is printed.
     """
     rev = opts.get('rev')
     if rev:
@@ -2238,11 +2212,11 @@
 def paths(ui, repo, search=None):
     """show aliases for remote repositories
 
-    Show definition of symbolic path name NAME. If no name is given,
-    show definition of all 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.
+    Show definition of symbolic path name NAME. If no name is given, show
+    definition of all 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.
 
     See 'hg help urls' for more information.
     """
@@ -2275,18 +2249,18 @@
 
     Pull changes from a remote repository to a local one.
 
-    This finds all changes from the repository at the specified path
-    or URL and adds them to a local repository (the current one unless
-    -R is specified). By default, this does not update the copy of the
-    project in the working directory.
-
-    Use hg incoming if you want to see what would have been added by a
-    pull at the time you issued this command. If you then decide to
-    added those changes to the repository, you should use pull -r X
-    where X is the last changeset listed by hg incoming.
-
-    If SOURCE is omitted, the 'default' path will be used.
-    See 'hg help urls' for more information.
+    This finds all changes from the repository at the specified path or URL
+    and adds them to a local repository (the current one unless -R is
+    specified). By default, this does not update the copy of the project in
+    the working directory.
+
+    Use hg incoming if you want to see what would have been added by a pull at
+    the time you issued this command. If you then decide to added those
+    changes to the repository, you should use pull -r X where X is the last
+    changeset listed by hg incoming.
+
+    If SOURCE is omitted, the 'default' path will be used. See 'hg help urls'
+    for more information.
     """
     source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
     other = hg.repository(cmdutil.remoteui(repo, opts), source)
@@ -2307,20 +2281,19 @@
 
     Push changes from the local repository to the given destination.
 
-    This is the symmetrical operation for pull. It moves changes from
-    the current repository to a different one. If the destination is
-    local this is identical to a pull in that directory from the
-    current one.
+    This is the symmetrical operation for pull. It moves changes from the
+    current repository to a different one. If the destination is local this is
+    identical to a pull in that directory from the current one.
 
     By default, push will refuse to run if it detects the result would
-    increase the number of remote heads. This generally indicates the
-    user forgot to pull and merge before pushing.
-
-    If -r/--rev is used, the named revision and all its ancestors will
-    be pushed to the remote repository.
-
-    Please see 'hg help urls' for important details about ssh://
-    URLs. If DESTINATION is omitted, a default path will be used.
+    increase the number of remote heads. This generally indicates the user
+    forgot to pull and merge before pushing.
+
+    If -r/--rev is used, the named revision and all its ancestors will be
+    pushed to the remote repository.
+
+    Please see 'hg help urls' for important details about ssh:// URLs. If
+    DESTINATION is omitted, a default path will be used.
     """
     dest, revs, checkout = hg.parseurl(
         ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev'))
@@ -2343,9 +2316,8 @@
 
     Recover from an interrupted commit or pull.
 
-    This command tries to fix the repository status after an
-    interrupted operation. It should only be necessary when Mercurial
-    suggests it.
+    This command tries to fix the repository status after an interrupted
+    operation. It should only be necessary when Mercurial suggests it.
     """
     if repo.recover():
         return hg.verify(repo)
@@ -2356,17 +2328,16 @@
 
     Schedule the indicated files for removal from the repository.
 
-    This only removes files from the current branch, not from the
-    entire project history. -A/--after can be used to remove only
-    files that have already been deleted, -f/--force can be used to
-    force deletion, and -Af can be used to remove files from the next
-    revision without deleting them from the working directory.
-
-    The following table details the behavior of remove for different
-    file states (columns) and option combinations (rows). The file
-    states are Added [A], Clean [C], Modified [M] and Missing [!]
-    (as reported by hg status). The actions are Warn, Remove (from
-    branch) and Delete (from disk).
+    This only removes files from the current branch, not from the entire
+    project history. -A/--after can be used to remove only files that have
+    already been deleted, -f/--force can be used to force deletion, and -Af
+    can be used to remove files from the next revision without deleting them
+    from the working directory.
+
+    The following table details the behavior of remove for different file
+    states (columns) and option combinations (rows). The file states are Added
+    [A], Clean [C], Modified [M] and Missing [!] (as reported by hg status).
+    The actions are Warn, Remove (from branch) and Delete (from disk).
 
            A  C  M  !
     none   W  RD W  R
@@ -2374,8 +2345,8 @@
     -A     W  W  W  R
     -Af    R  R  R  R
 
-    This command schedules the files to be removed at the next commit.
-    To undo a remove before that, see hg revert.
+    This command schedules the files to be removed at the next commit. To undo
+    a remove before that, see hg revert.
     """
 
     after, force = opts.get('after'), opts.get('force')
@@ -2415,16 +2386,16 @@
 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 a
-    file, there can only be one source.
-
-    By default, this command copies the contents of files as they
-    exist in the working directory. If invoked with -A/--after, the
-    operation is recorded, but no copying is performed.
-
-    This command takes effect at the next commit. To undo a rename
-    before that, see hg revert.
+    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 exist in the
+    working directory. If invoked with -A/--after, the operation is recorded,
+    but no copying is performed.
+
+    This command takes effect at the next commit. To undo a rename before
+    that, see hg revert.
     """
     wlock = repo.wlock(False)
     try:
@@ -2436,16 +2407,16 @@
     """retry file merges from a merge or update
 
     This command will cleanly retry unresolved file merges using file
-    revisions preserved from the last update or merge. To attempt to
-    resolve all unresolved files, use the -a/--all switch.
-
-    If a conflict is resolved manually, please note that the changes
-    will be overwritten if the merge is retried with resolve. The
-    -m/--mark switch should be used to mark the file as resolved.
-
-    This command also allows listing resolved files and manually
-    indicating whether or not files are resolved. All files must be
-    marked as resolved before a commit is permitted.
+    revisions preserved from the last update or merge. To attempt to resolve
+    all unresolved files, use the -a/--all switch.
+
+    If a conflict is resolved manually, please note that the changes will be
+    overwritten if the merge is retried with resolve. The -m/--mark switch
+    should be used to mark the file as resolved.
+
+    This command also allows listing resolved files and manually indicating
+    whether or not files are resolved. All files must be marked as resolved
+    before a commit is permitted.
 
     The codes used to show the status of files are:
     U = unresolved
@@ -2490,35 +2461,33 @@
 def revert(ui, repo, *pats, **opts):
     """restore individual files or directories to an earlier state
 
-    (Use update -r to check out earlier revisions, revert does not
-    change the working directory parents.)
-
-    With no revision specified, revert the named files or directories
-    to the contents they had in the parent of the working directory.
-    This restores the contents of the affected files to an unmodified
-    state and unschedules adds, removes, copies, and renames. If the
-    working directory has two parents, you must explicitly specify the
-    revision to revert to.
-
-    Using the -r/--rev option, revert the given files or directories
-    to their contents as of a specific revision. This can be helpful
-    to "roll 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 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 mode
-    of a file was changed, it is reset.
-
-    If names are given, all files matching the names are reverted.
-    If no arguments are given, no files are reverted.
-
-    Modified files are saved with a .orig suffix before reverting.
-    To disable these backups, use --no-backup.
+    (Use update -r to check out earlier revisions, revert does not change the
+    working directory parents.)
+
+    With no revision specified, revert the named files or directories to the
+    contents they had in the parent of the working directory. This restores
+    the contents of the affected files to an unmodified state and unschedules
+    adds, removes, copies, and renames. If the working directory has two
+    parents, you must explicitly specify the revision to revert to.
+
+    Using the -r/--rev option, revert the given files or directories to their
+    contents as of a specific revision. This can be helpful to "roll 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 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 mode of a
+    file was changed, it is reset.
+
+    If names are given, all files matching the names are reverted. If no
+    arguments are given, no files are reverted.
+
+    Modified files are saved with a .orig suffix before reverting. To disable
+    these backups, use --no-backup.
     """
 
     if opts["date"]:
@@ -2707,15 +2676,14 @@
     """roll back the last transaction
 
     This command should be used with care. There is only one level of
-    rollback, and there is no way to undo a rollback. It will also
-    restore the dirstate at the time of the last transaction, losing
-    any dirstate changes since that time. This command does not alter
-    the working directory.
-
-    Transactions are used to encapsulate the effects of all commands
-    that create new changesets or propagate existing changesets into a
-    repository. For example, the following commands are transactional,
-    and their effects can be rolled back:
+    rollback, and there is no way to undo a rollback. It will also restore the
+    dirstate at the time of the last transaction, losing any dirstate changes
+    since that time. This command does not alter the working directory.
+
+    Transactions are used to encapsulate the effects of all commands that
+    create new changesets or propagate existing changesets into a repository.
+    For example, the following commands are transactional, and their effects
+    can be rolled back:
 
       commit
       import
@@ -2723,12 +2691,12 @@
       push (with this repository as destination)
       unbundle
 
-    This command is not intended for use on public repositories. Once
-    changes are visible for pull by other users, rolling a transaction
-    back locally is ineffective (someone else may already have pulled
-    the changes). Furthermore, a race is possible with readers of the
-    repository; for example an in-progress pull from the repository
-    may fail if a rollback is performed.
+    This command is not intended for use on public repositories. Once changes
+    are visible for pull by other users, rolling a transaction back locally is
+    ineffective (someone else may already have pulled the changes).
+    Furthermore, a race is possible with readers of the repository; for
+    example an in-progress pull from the repository may fail if a rollback is
+    performed.
     """
     repo.rollback()
 
@@ -2744,9 +2712,8 @@
 
     Start a local HTTP repository browser and pull server.
 
-    By default, the server logs accesses to stdout and errors to
-    stderr. Use the -A/--accesslog and -E/--errorlog options to log to
-    files.
+    By default, the server logs accesses to stdout and errors to stderr. Use
+    the -A/--accesslog and -E/--errorlog options to log to files.
     """
 
     if opts["stdio"]:
@@ -2807,24 +2774,22 @@
 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
-    the source of a copy/move operation, are not listed unless
-    -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
-    Unless options described with "show only ..." are given, the
-    options -mardu are used.
-
-    Option -q/--quiet hides untracked (unknown and ignored) files
-    unless explicitly requested with -u/--unknown or -i/--ignored.
-
-    NOTE: status may appear to disagree with diff if permissions have
-    changed or a merge has occurred. The standard diff format does not
-    report permission changes and diff only reports changes relative
-    to one merge parent.
-
-    If one revision is given, it is used as the base revision.
-    If two revisions are given, the differences between them are
-    shown.
+    Show status of files in the repository. If names are given, only files
+    that match are shown. Files that are clean or ignored or the source of a
+    copy/move operation, are not listed unless -c/--clean, -i/--ignored,
+    -C/--copies or -A/--all are given. Unless options described with "show
+    only ..." are given, the options -mardu are used.
+
+    Option -q/--quiet hides untracked (unknown and ignored) files unless
+    explicitly requested with -u/--unknown or -i/--ignored.
+
+    NOTE: status may appear to disagree with diff if permissions have changed
+    or a merge has occurred. The standard diff format does not report
+    permission changes and diff only reports changes relative to one merge
+    parent.
+
+    If one revision is given, it is used as the base revision. If two
+    revisions are given, the differences between them are shown.
 
     The codes used to show the status of files are:
     M = modified
@@ -2882,18 +2847,17 @@
 
     Name a particular revision using <name>.
 
-    Tags are used to name particular revisions of the repository and are
-    very useful to compare different revisions, to go back to significant
-    earlier versions or to mark branch points as releases, etc.
-
-    If no revision is given, the parent of the working directory is
-    used, or tip if no revision is checked out.
-
-    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
-    shared among repositories).
+    Tags are used to name particular revisions of the repository and are very
+    useful to compare different revisions, to go back to significant earlier
+    versions or to mark branch points as releases, etc.
+
+    If no revision is given, the parent of the working directory is used, or
+    tip if no revision is checked out.
+
+    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 shared among repositories).
 
     See 'hg help dates' for a list of formats valid for -d/--date.
     """
@@ -2946,8 +2910,8 @@
 def tags(ui, repo):
     """list repository tags
 
-    This lists both regular and local tags. When the -v/--verbose
-    switch is used, a third column "local" is printed for local tags.
+    This lists both regular and local tags. When the -v/--verbose switch is
+    used, a third column "local" is printed for local tags.
     """
 
     hexfunc = ui.debugflag and hex or short
@@ -2975,22 +2939,22 @@
 def tip(ui, repo, **opts):
     """show the tip revision
 
-    The tip revision (usually just called the tip) is the changeset
-    most recently added to the repository (and therefore the most
-    recently changed head).
-
-    If you have just made a commit, that commit will be the tip. If
-    you have just pulled changes from another repository, the tip of
-    that repository becomes the current tip. The "tip" tag is special
-    and cannot be renamed or assigned to a different changeset.
+    The tip revision (usually just called the tip) is the changeset most
+    recently added to the repository (and therefore the most recently changed
+    head).
+
+    If you have just made a commit, that commit will be the tip. If you have
+    just pulled changes from another repository, the tip of that repository
+    becomes the current tip. The "tip" tag is special and cannot be renamed or
+    assigned to a different changeset.
     """
     cmdutil.show_changeset(ui, repo, opts).show(repo[len(repo) - 1])
 
 def unbundle(ui, repo, fname1, *fnames, **opts):
     """apply one or more changegroup files
 
-    Apply one or more compressed changegroup files generated by the
-    bundle command.
+    Apply one or more compressed changegroup files generated by the bundle
+    command.
     """
     fnames = (fname1,) + fnames
 
@@ -3008,31 +2972,27 @@
 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
     """update working directory
 
-    Update the repository's working directory to the specified
-    revision, or the tip of the current branch if none is specified.
-    Use null as the revision to remove the working copy (like 'hg
-    clone -U').
-
-    When the working directory contains no uncommitted changes, it
-    will be replaced by the state of the requested revision from the
-    repository. When the requested revision is on a different branch,
-    the working directory will additionally be switched to that
-    branch.
-
-    When there are uncommitted changes, use option -C/--clean to
-    discard them, forcibly replacing the state of the working
-    directory with the requested revision. Alternately, use -c/--check
-    to abort.
-
-    When there are uncommitted changes and option -C/--clean is not
-    used, and the parent revision and requested revision are on the
-    same branch, and one of them is an ancestor of the other, then the
-    new working directory will contain the requested revision merged
-    with the uncommitted changes. Otherwise, the update will fail with
-    a suggestion to use 'merge' or 'update -C' instead.
-
-    If you want to update just one file to an older revision, use
-    revert.
+    Update the repository's working directory to the specified revision, or
+    the tip of the current branch if none is specified. Use null as the
+    revision to remove the working copy (like 'hg clone -U').
+
+    When the working directory contains no uncommitted changes, it will be
+    replaced by the state of the requested revision from the repository. When
+    the requested revision is on a different branch, the working directory
+    will additionally be switched to that branch.
+
+    When there are uncommitted changes, use option -C/--clean to discard them,
+    forcibly replacing the state of the working directory with the requested
+    revision. Alternately, use -c/--check to abort.
+
+    When there are uncommitted changes and option -C/--clean is not used, and
+    the parent revision and requested revision are on the same branch, and one
+    of them is an ancestor of the other, then the new working directory will
+    contain the requested revision merged with the uncommitted changes.
+    Otherwise, the update will fail with a suggestion to use 'merge' or
+    'update -C' instead.
+
+    If you want to update just one file to an older revision, use revert.
 
     See 'hg help dates' for a list of formats valid for -d/--date.
     """
@@ -3063,10 +3023,10 @@
 
     Verify the integrity of the current repository.
 
-    This will perform an extensive check of the repository's
-    integrity, validating the hashes and checksums of each entry in
-    the changelog, manifest, and tracked files, as well as the
-    integrity of their crosslinks and indices.
+    This will perform an extensive check of the repository's integrity,
+    validating the hashes and checksums of each entry in the changelog,
+    manifest, and tracked files, as well as the integrity of their crosslinks
+    and indices.
     """
     return hg.verify(repo)
 
--- a/mercurial/context.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/context.py	Wed Jul 08 17:03:50 2009 -0700
@@ -199,7 +199,9 @@
 
         assert (changeid is not None
                 or fileid is not None
-                or changectx is not None)
+                or changectx is not None), \
+                ("bad args: changeid=%r, fileid=%r, changectx=%r"
+                 % (changeid, fileid, changectx))
 
         if filelog:
             self._filelog = filelog
--- a/mercurial/copies.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/copies.py	Wed Jul 08 17:03:50 2009 -0700
@@ -42,7 +42,7 @@
         seen.add(s)
         if fc.path() != orig and fc.path() not in old:
             old[fc.path()] = (depth, fc.path()) # remember depth
-        if fc.rev() < limit and fc.rev() is not None:
+        if fc.rev() is not None and fc.rev() < limit:
             continue
         visit += [(p, depth - 1) for p in fc.parents()]
 
--- a/mercurial/extensions.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/extensions.py	Wed Jul 08 17:03:50 2009 -0700
@@ -166,10 +166,6 @@
 
 def enabled():
     '''return a dict of {name: desc} of extensions, and the max name length'''
-
-    if not enabled:
-        return {}, 0
-
     exts = {}
     maxlength = 0
     exthelps = []
--- a/mercurial/filemerge.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/filemerge.py	Wed Jul 08 17:03:50 2009 -0700
@@ -145,9 +145,9 @@
 
     if not tool or tool == 'internal:prompt':
         tool = "internal:local"
-        if ui.prompt(_(" no tool found to merge %s\n"
-                       "keep (l)ocal or take (o)ther?") % fd,
-                     (_("&Local"), _("&Other")), _("l")) != _("l"):
+        if ui.promptchoice(_(" no tool found to merge %s\n"
+                             "keep (l)ocal or take (o)ther?") % fd,
+                           (_("&Local"), _("&Other")), 0):
             tool = "internal:other"
     if tool == "internal:local":
         return 0
@@ -213,9 +213,9 @@
 
     if not r and _toolbool(ui, tool, "checkchanged"):
         if filecmp.cmp(repo.wjoin(fd), back):
-            if ui.prompt(_(" output file %s appears unchanged\n"
-                "was merge successful (yn)?") % fd,
-                (_("&Yes"), _("&No")), _("n")) != _("y"):
+            if ui.promptchoice(_(" output file %s appears unchanged\n"
+                                 "was merge successful (yn)?") % fd,
+                               (_("&Yes"), _("&No")), 1):
                 r = 1
 
     if _toolbool(ui, tool, "fixeol"):
--- a/mercurial/help.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/help.py	Wed Jul 08 17:03:50 2009 -0700
@@ -52,21 +52,18 @@
 def extshelp():
     doc = _(r'''
     Mercurial has the ability to add new features through the use of
-    extensions. Extensions may add new commands, add options to
-    existing commands, change the default behavior of commands, or
-    implement hooks.
+    extensions. Extensions may add new commands, add options to existing
+    commands, change the default behavior of commands, or implement hooks.
 
-    Extensions are not loaded by default for a variety of reasons:
-    they can increase startup overhead; they may be meant for
-    advanced usage only; they may provide potentially dangerous
-    abilities (such as letting you destroy or modify history); they
-    might not be ready for prime time; or they may alter some
-    usual behaviors of stock Mercurial. It is thus up to the user to
-    activate extensions as needed.
+    Extensions are not loaded by default for a variety of reasons: they can
+    increase startup overhead; they may be meant for advanced usage only; they
+    may provide potentially dangerous abilities (such as letting you destroy
+    or modify history); they might not be ready for prime time; or they may
+    alter some usual behaviors of stock Mercurial. It is thus up to the user
+    to activate extensions as needed.
 
-    To enable the "foo" extension, either shipped with Mercurial
-    or in the Python search path, create an entry for it in your
-    hgrc, like this:
+    To enable the "foo" extension, either shipped with Mercurial or in the
+    Python search path, create an entry for it in your hgrc, like this:
 
       [extensions]
       foo =
@@ -76,8 +73,8 @@
       [extensions]
       myfeature = ~/.hgext/myfeature.py
 
-    To explicitly disable an extension enabled in an hgrc of broader
-    scope, prepend its path with !:
+    To explicitly disable an extension enabled in an hgrc of broader scope,
+    prepend its path with !:
 
       [extensions]
       # disabling extension bar residing in /path/to/extension/bar.py
@@ -121,10 +118,10 @@
 
     "1165432709 0" (Wed Dec 6 13:18:29 2006 UTC)
 
-    This is the internal representation format for dates. unixtime is
-    the number of seconds since the epoch (1970-01-01 00:00 UTC).
-    offset is the offset of the local timezone, in seconds west of UTC
-    (negative if the timezone is east of UTC).
+    This is the internal representation format for dates. unixtime is the
+    number of seconds since the epoch (1970-01-01 00:00 UTC). offset is the
+    offset of the local timezone, in seconds west of UTC (negative if the
+    timezone is east of UTC).
 
     The log command also accepts date ranges:
 
@@ -136,27 +133,27 @@
 
     (["patterns"], _("File Name Patterns"),
      _(r'''
-    Mercurial accepts several notations for identifying one or more
-    files at a time.
+    Mercurial accepts several notations for identifying one or more files at a
+    time.
 
-    By default, Mercurial treats filenames as shell-style extended
-    glob patterns.
+    By default, Mercurial treats filenames as shell-style extended glob
+    patterns.
 
     Alternate pattern notations must be specified explicitly.
 
-    To use a plain path name without any pattern matching, start it
-    with "path:". These path names must completely match starting at
-    the current repository root.
+    To use a plain path name without any pattern matching, start it with
+    "path:". These path names must completely match starting at the current
+    repository root.
 
-    To use an extended glob, start a name with "glob:". Globs are
-    rooted at the current directory; a glob such as "*.c" will only
-    match files in the current directory ending with ".c".
+    To use an extended glob, start a name with "glob:". Globs are rooted at
+    the current directory; a glob such as "*.c" will only match files in the
+    current directory ending with ".c".
 
-    The supported glob syntax extensions are "**" to match any string
-    across path separators and "{a,b}" to mean "a or b".
+    The supported glob syntax extensions are "**" to match any string across
+    path separators and "{a,b}" to mean "a or b".
 
-    To use a Perl/Python regular expression, start a name with "re:".
-    Regexp pattern matching is anchored at the root of the repository.
+    To use a Perl/Python regular expression, start a name with "re:". Regexp
+    pattern matching is anchored at the root of the repository.
 
     Plain examples:
 
@@ -168,8 +165,8 @@
 
     glob:*.c       any name ending in ".c" in the current directory
     *.c            any name ending in ".c" in the current directory
-    **.c           any name ending in ".c" in any subdirectory of the
-                   current directory including itself.
+    **.c           any name ending in ".c" in any subdirectory of the current
+                   directory including itself.
     foo/*.c        any name ending in ".c" in the directory foo
     foo/**.c       any name ending in ".c" in any subdirectory of foo
                    including itself.
@@ -183,11 +180,11 @@
     (['environment', 'env'], _('Environment Variables'),
      _(r'''
 HG::
-    Path to the 'hg' executable, automatically passed when running
-    hooks, extensions or external tools. If unset or empty, this is
-    the hg executable's name if it's frozen, or an executable named
-    'hg' (with %PATHEXT% [defaulting to COM/EXE/BAT/CMD] extensions on
-    Windows) is searched.
+    Path to the 'hg' executable, automatically passed when running hooks,
+    extensions or external tools. If unset or empty, this is the hg
+    executable's name if it's frozen, or an executable named 'hg' (with
+    %PATHEXT% [defaulting to COM/EXE/BAT/CMD] extensions on Windows) is
+    searched.
 
 HGEDITOR::
     This is the name of the editor to run when committing. See EDITOR.
@@ -195,39 +192,37 @@
     (deprecated, use .hgrc)
 
 HGENCODING::
-    This overrides the default locale setting detected by Mercurial.
-    This setting is used to convert data including usernames,
-    changeset descriptions, tag names, and branches. This setting can
-    be overridden with the --encoding command-line option.
+    This overrides the default locale setting detected by Mercurial. This
+    setting is used to convert data including usernames, changeset
+    descriptions, tag names, and branches. This setting can be overridden with
+    the --encoding command-line option.
 
 HGENCODINGMODE::
-    This sets Mercurial's behavior for handling unknown characters
-    while transcoding user input. The default is "strict", which
-    causes Mercurial to abort if it can't map a character. Other
-    settings include "replace", which replaces unknown characters, and
-    "ignore", which drops them. This setting can be overridden with
-    the --encodingmode command-line option.
+    This sets Mercurial's behavior for handling unknown characters while
+    transcoding user input. The default is "strict", which causes Mercurial to
+    abort if it can't map a character. Other settings include "replace", which
+    replaces unknown characters, and "ignore", which drops them. This setting
+    can be overridden with the --encodingmode command-line option.
 
 HGMERGE::
-    An executable to use for resolving merge conflicts. The program
-    will be executed with three arguments: local file, remote file,
-    ancestor file.
+    An executable to use for resolving merge conflicts. The program will be
+    executed with three arguments: local file, remote file, ancestor file.
 
     (deprecated, use .hgrc)
 
 HGRCPATH::
-    A list of files or directories to search for hgrc files. Item
-    separator is ":" on Unix, ";" on Windows. If HGRCPATH is not set,
-    platform default search path is used. If empty, only the .hg/hgrc
-    from the current repository is read.
+    A list of files or directories to search for hgrc files. Item separator is
+    ":" on Unix, ";" on Windows. If HGRCPATH is not set, platform default
+    search path is used. If empty, only the .hg/hgrc from the current
+    repository is read.
 
     For each element in HGRCPATH:
     * if it's a directory, all files ending with .rc are added
     * otherwise, the file itself will be added
 
 HGUSER::
-    This is the string used as the author of a commit. If not set,
-    available values will be considered in this order:
+    This is the string used as the author of a commit. If not set, available
+    values will be considered in this order:
 
     * HGUSER (deprecated)
     * hgrc files from the HGRCPATH
@@ -247,77 +242,71 @@
     This is the name of the editor to use when committing. See EDITOR.
 
 EDITOR::
-    Sometimes Mercurial needs to open a text file in an editor for a
-    user to modify, for example when writing commit messages. The
-    editor it uses is determined by looking at the environment
-    variables HGEDITOR, VISUAL and EDITOR, in that order. The first
-    non-empty one is chosen. If all of them are empty, the editor
-    defaults to 'vi'.
+    Sometimes Mercurial needs to open a text file in an editor for a user to
+    modify, for example when writing commit messages. The editor it uses is
+    determined by looking at the environment variables HGEDITOR, VISUAL and
+    EDITOR, in that order. The first non-empty one is chosen. If all of them
+    are empty, the editor defaults to 'vi'.
 
 PYTHONPATH::
-    This is used by Python to find imported modules and may need to be
-    set appropriately if this Mercurial is not installed system-wide.
+    This is used by Python to find imported modules and may need to be set
+    appropriately if this Mercurial is not installed system-wide.
     ''')),
 
     (['revs', 'revisions'], _('Specifying Single Revisions'),
      _(r'''
     Mercurial supports several ways to specify individual revisions.
 
-    A plain integer is treated as a revision number. Negative integers
-    are treated as topological offsets from the tip, with -1 denoting
-    the tip. As such, negative numbers are only useful if you've
-    memorized your local tree numbers and want to save typing a single
-    digit. This editor suggests copy and paste.
+    A plain integer is treated as a revision number. Negative integers are
+    treated as topological offsets from the tip, with -1 denoting the tip. As
+    such, negative numbers are only useful if you've memorized your local tree
+    numbers and want to save typing a single digit. This editor suggests copy
+    and paste.
 
-    A 40-digit hexadecimal string is treated as a unique revision
-    identifier.
+    A 40-digit hexadecimal string is treated as a unique revision identifier.
 
-    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
-    prefix of exactly one full-length identifier.
+    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 prefix of exactly 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
-    contain the ":" character.
+    Any other string is treated as a tag name, which is a symbolic name
+    associated with a revision identifier. Tag names may not contain the ":"
+    character.
 
-    The reserved name "tip" is a special tag that always identifies
-    the most recent revision.
+    The reserved name "tip" is a special tag that always identifies the most
+    recent revision.
 
-    The reserved name "null" indicates the null revision. This is the
-    revision of an empty repository, and the parent of revision 0.
+    The reserved name "null" indicates the null revision. This is the revision
+    of an empty repository, and the parent of revision 0.
 
-    The reserved name "." indicates the working directory parent. If
-    no working directory is checked out, it is equivalent to null. If
-    an uncommitted merge is in progress, "." is the revision of the
-    first parent.
+    The reserved name "." indicates the working directory parent. If no
+    working directory is checked out, it is equivalent to null. If an
+    uncommitted merge is in progress, "." is the revision of the first parent.
     ''')),
 
     (['mrevs', 'multirevs'], _('Specifying Multiple Revisions'),
      _(r'''
-    When Mercurial accepts more than one revision, they may be
-    specified individually, or provided as a topologically continuous
-    range, separated by the ":" character.
+    When Mercurial accepts more than one revision, they may be specified
+    individually, or provided as a topologically continuous range, 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 means
-    "all revisions".
+    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 means "all revisions".
 
-    If BEGIN is greater than END, revisions are treated in reverse
-    order.
+    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 9:6 gives 9, 8, 7, and 6.
+    A range acts as a closed interval. This means that a range of 3:5 gives 3,
+    4 and 5. Similarly, a range of 9:6 gives 9, 8, 7, and 6.
     ''')),
 
     (['diffs'], _('Diff Formats'),
      _(r'''
-    Mercurial's default format for showing changes between two
-    versions of a file is compatible with the unified format of GNU
-    diff, which can be used by GNU patch and many other standard
-    tools.
+    Mercurial's default format for showing changes between two versions of a
+    file is compatible with the unified format of GNU diff, which can be used
+    by GNU patch and many other standard tools.
 
     While this standard format is often enough, it does not encode the
     following information:
@@ -327,121 +316,116 @@
      - changes in binary files
      - creation or deletion of empty files
 
-    Mercurial also supports the extended diff format from the git VCS
-    which addresses these limitations. The git diff format is not
-    produced by default because a few widespread tools still do not
-    understand this format.
+    Mercurial also supports the extended diff format from the git VCS which
+    addresses these limitations. The git diff format is not produced by
+    default because a few widespread tools still do not understand this
+    format.
 
-    This means that when generating diffs from a Mercurial repository
-    (e.g. with "hg export"), you should be careful about things like
-    file copies and renames or other things mentioned above, because
-    when applying a standard diff to a different repository, this
-    extra information is lost. Mercurial's internal operations (like
-    push and pull) are not affected by this, because they use an
-    internal binary format for communicating changes.
+    This means that when generating diffs from a Mercurial repository (e.g.
+    with "hg export"), you should be careful about things like file copies and
+    renames or other things mentioned above, because when applying a standard
+    diff to a different repository, this extra information is lost.
+    Mercurial's internal operations (like push and pull) are not affected by
+    this, because they use an internal binary format for communicating
+    changes.
 
-    To make Mercurial produce the git extended diff format, use the
-    --git option available for many commands, or set 'git = True' in
-    the [diff] section of your hgrc. You do not need to set this
-    option when importing diffs in this format or using them in the mq
-    extension.
+    To make Mercurial produce the git extended diff format, use the --git
+    option available for many commands, or set 'git = True' in the [diff]
+    section of your hgrc. You do not need to set this option when importing
+    diffs in this format or using them in the mq extension.
     ''')),
     (['templating'], _('Template Usage'),
      _(r'''
-    Mercurial allows you to customize output of commands through
-    templates. You can either pass in a template from the command
-    line, via the --template option, or select an existing
-    template-style (--style).
+    Mercurial allows you to customize output of commands through templates.
+    You can either pass in a template from the command line, via the
+    --template option, or select an existing template-style (--style).
 
-    You can customize output for any "log-like" command: log,
-    outgoing, incoming, tip, parents, heads and glog.
+    You can customize output for any "log-like" command: log, outgoing,
+    incoming, tip, parents, heads and glog.
 
-    Three styles are packaged with Mercurial: default (the style used
-    when no explicit preference is passed), compact and changelog.
-    Usage:
+    Three styles are packaged with Mercurial: default (the style used when no
+    explicit preference is passed), compact and changelog. Usage:
 
         $ hg log -r1 --style changelog
 
-    A template is a piece of text, with markup to invoke variable
-    expansion:
+    A template is a piece of text, with markup to invoke variable expansion:
 
         $ hg log -r1 --template "{node}\n"
         b56ce7b07c52de7d5fd79fb89701ea538af65746
 
-    Strings in curly braces are called keywords. The availability of
-    keywords depends on the exact context of the templater. These
-    keywords are usually available for templating a log-like command:
+    Strings in curly braces are called keywords. The availability of keywords
+    depends on the exact context of the templater. These keywords are usually
+    available for templating a log-like command:
 
     - author: String. The unmodified author of the changeset.
-    - branches: String. The name of the branch on which the changeset
-          was committed. Will be empty if the branch name was default.
+    - branches: String. The name of the branch on which the changeset was
+          committed. Will be empty if the branch name was default.
     - date: Date information. The date when the changeset was committed.
     - desc: String. The text of the changeset description.
-    - diffstat: String. Statistics of changes with the following
-          format: "modified files: +added/-removed lines"
-    - files: List of strings. All files modified, added, or removed by
-          this changeset.
+    - diffstat: String. Statistics of changes with the following format:
+          "modified files: +added/-removed lines"
+    - files: List of strings. All files modified, added, or removed by this
+          changeset.
     - file_adds: List of strings. Files added by this changeset.
     - file_mods: List of strings. Files modified by this changeset.
     - file_dels: List of strings. Files removed by this changeset.
-    - node: String. The changeset identification hash, as a
-          40-character hexadecimal string.
+    - node: String. The changeset identification hash, as a 40-character
+          hexadecimal string.
     - parents: List of strings. The parents of the changeset.
     - rev: Integer. The repository-local changeset revision number.
     - tags: List of strings. Any tags associated with the changeset.
 
-    The "date" keyword does not produce human-readable output. If you
-    want to use a date in your output, you can use a filter to process
-    it. Filters are functions which return a string based on the input
-    variable. You can also use a chain of filters to get the desired
-    output:
+    The "date" keyword does not produce human-readable output. If you want to
+    use a date in your output, you can use a filter to process it. Filters are
+    functions which return a string based on the input variable. You can also
+    use a chain of filters to get the desired output:
 
        $ hg tip --template "{date|isodate}\n"
        2008-08-21 18:22 +0000
 
     List of filters:
 
-    - addbreaks: Any text. Add an XHTML "<br />" tag before the end of
-          every line except the last.
-    - age: Date. Returns a human-readable date/time difference between
-          the given date/time and the current date/time.
-    - basename: Any text. Treats the text as a path, and returns the
-          last component of the path after splitting by the path
-          separator (ignoring trailing separators). For example,
-          "foo/bar/baz" becomes "baz" and "foo/bar//" becomes "bar".
+    - addbreaks: Any text. Add an XHTML "<br />" tag before the end of every
+          line except the last.
+    - age: Date. Returns a human-readable date/time difference between the
+          given date/time and the current date/time.
+    - basename: Any text. Treats the text as a path, and returns the last
+          component of the path after splitting by the path separator
+          (ignoring trailing separators). For example, "foo/bar/baz" becomes
+          "baz" and "foo/bar//" becomes "bar".
     - stripdir: Treat the text as path and strip a directory level, if
           possible. For example, "foo" and "foo/bar" becomes "foo".
-    - date: Date. Returns a date in a Unix date format, including
-          the timezone: "Mon Sep 04 15:13:13 2006 0700".
-    - domain: Any text. Finds the first string that looks like an
-          email address, and extracts just the domain component.
-          Example: 'User <user@example.com>' becomes 'example.com'.
-    - email: Any text. Extracts the first string that looks like an
-          email address. Example: 'User <user@example.com>' becomes
+    - date: Date. Returns a date in a Unix date format, including the
+          timezone: "Mon Sep 04 15:13:13 2006 0700".
+    - domain: Any text. Finds the first string that looks like an email
+          address, and extracts just the domain component. Example: 'User
+          <user@example.com>' becomes 'example.com'.
+    - email: Any text. Extracts the first string that looks like an email
+          address. Example: 'User <user@example.com>' becomes
           'user@example.com'.
-    - escape: Any text. Replaces the special XML/XHTML characters "&",
-          "<" and ">" with XML entities.
+    - escape: Any text. Replaces the special XML/XHTML characters "&", "<" and
+          ">" with XML entities.
     - fill68: Any text. Wraps the text to fit in 68 columns.
     - fill76: Any text. Wraps the text to fit in 76 columns.
     - firstline: Any text. Returns the first line of text.
     - nonempty: Any text. Returns '(none)' if the string is empty.
-    - hgdate: Date. Returns the date as a pair of numbers:
-          "1157407993 25200" (Unix timestamp, timezone offset).
+    - hgdate: Date. Returns the date as a pair of numbers: "1157407993 25200"
+          (Unix timestamp, timezone offset).
     - isodate: Date. Returns the date in ISO 8601 format.
     - localdate: Date. Converts a date to local date.
-    - obfuscate: Any text. Returns the input text rendered as a
-          sequence of XML entities.
+    - obfuscate: Any text. Returns the input text rendered as a sequence of
+          XML entities.
     - person: Any text. Returns the text before an email address.
-    - rfc822date: Date. Returns a date using the same format used
-          in email headers.
-    - short: Changeset hash. Returns the short form of a changeset
-          hash, i.e. a 12-byte hexadecimal string.
+    - rfc822date: Date. Returns a date using the same format used in email
+          headers.
+    - short: Changeset hash. Returns the short form of a changeset hash, i.e.
+          a 12-byte hexadecimal string.
     - shortdate: Date. Returns a date like "2006-09-18".
     - strip: Any text. Strips all leading and trailing whitespace.
-    - tabindent: Any text. Returns the text, with every line except
-          the first starting with a tab character.
-    - urlescape: Any text. Escapes all "special" characters. For
-          example, "foo bar" becomes "foo%20bar".
+    - tabindent: Any text. Returns the text, with every line except the first
+          starting with a tab character.
+    - urlescape: Any text. Escapes all "special" characters. For example, "foo
+          bar" becomes "foo%20bar".
     - user: Any text. Returns the user portion of an email address.
     ''')),
 
@@ -455,57 +439,53 @@
       https://[user[:pass]@]host[:port]/[path][#revision]
       ssh://[user[:pass]@]host[:port]/[path][#revision]
 
-    Paths in the local filesystem can either point to Mercurial
-    repositories or to bundle files (as created by 'hg bundle' or
-    'hg incoming --bundle').
+    Paths in the local filesystem can either point to Mercurial repositories
+    or to bundle files (as created by 'hg bundle' or 'hg incoming --bundle').
 
-    An optional identifier after # indicates a particular branch, tag,
-    or changeset to use from the remote repository. See also 'hg help
-    revisions'.
+    An optional identifier after # indicates a particular branch, tag, or
+    changeset to use from the remote repository. See also 'hg help revisions'.
 
-    Some features, such as pushing to http:// and https:// URLs are
-    only possible if the feature is explicitly enabled on the remote
-    Mercurial server.
+    Some features, such as pushing to http:// and https:// URLs are only
+    possible if the feature is explicitly enabled on the remote Mercurial
+    server.
 
     Some notes about using SSH with Mercurial:
-    - SSH requires an accessible shell account on the destination
-      machine and a copy of hg in the remote path or specified with as
-      remotecmd.
-    - path is relative to the remote user's home directory by default.
-      Use an extra slash at the start of a path to specify an absolute path:
+    - SSH requires an accessible shell account on the destination machine and
+      a copy of hg in the remote path or specified with as remotecmd.
+    - path is relative to the remote user's home directory by default. Use an
+      extra slash at the start of a path to specify an absolute path:
         ssh://example.com//tmp/repository
-    - Mercurial doesn't use its own compression via SSH; the right
-      thing to do is to configure it in your ~/.ssh/config, e.g.:
+    - Mercurial doesn't use its own compression via SSH; the right thing to do
+      is to configure it in your ~/.ssh/config, e.g.:
         Host *.mylocalnetwork.example.com
           Compression no
         Host *
           Compression yes
-      Alternatively specify "ssh -C" as your ssh command in your hgrc
-      or with the --ssh command line option.
+      Alternatively specify "ssh -C" as your ssh command in your hgrc or with
+      the --ssh command line option.
 
-    These URLs can all be stored in your hgrc with path aliases under
-    the [paths] section like so:
+    These URLs can all be stored in your hgrc with path aliases under the
+    [paths] section like so:
     [paths]
     alias1 = URL1
     alias2 = URL2
     ...
 
-    You can then use the alias for any command that uses a URL (for
-    example 'hg pull alias1' would pull from the 'alias1' path).
+    You can then use the alias for any command that uses a URL (for example
+    'hg pull alias1' would pull from the 'alias1' path).
 
-    Two path aliases are special because they are used as defaults
-    when you do not provide the URL to a command:
+    Two path aliases are special because they are used as defaults when you do
+    not provide the URL to a command:
 
     default:
-      When you create a repository with hg clone, the clone command
-      saves the location of the source repository as the new
-      repository's 'default' path. This is then used when you omit
-      path from push- and pull-like commands (including incoming and
-      outgoing).
+      When you create a repository with hg clone, the clone command saves the
+      location of the source repository as the new repository's 'default'
+      path. This is then used when you omit path from push- and pull-like
+      commands (including incoming and outgoing).
 
     default-push:
-      The push command will look for a path named 'default-push', and
-      prefer it over 'default' if both are defined.
+      The push command will look for a path named 'default-push', and prefer
+      it over 'default' if both are defined.
     ''')),
     (["extensions"], _("Using additional features"), extshelp),
 )
--- a/mercurial/hgweb/common.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/hgweb/common.py	Wed Jul 08 17:03:50 2009 -0700
@@ -69,7 +69,7 @@
         os.stat(path)
         ct = mimetypes.guess_type(path)[0] or "text/plain"
         req.respond(HTTP_OK, ct, length = os.path.getsize(path))
-        return file(path, 'rb').read()
+        return open(path, 'rb').read()
     except TypeError:
         raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename')
     except OSError, err:
--- a/mercurial/hgweb/server.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/hgweb/server.py	Wed Jul 08 17:03:50 2009 -0700
@@ -35,7 +35,7 @@
         for msg in seq:
             self.handler.log_error("HG error:  %s", msg)
 
-class _hgwebhandler(object, BaseHTTPServer.BaseHTTPRequestHandler):
+class _hgwebhandler(BaseHTTPServer.BaseHTTPRequestHandler):
 
     url_scheme = 'http'
 
--- a/mercurial/localrepo.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/localrepo.py	Wed Jul 08 17:03:50 2009 -0700
@@ -1707,24 +1707,13 @@
         def identity(x):
             return x
 
-        # A function generating function.  Sets up an environment for the
-        # inner function.
-        def cmp_by_rev_func(revlog):
-            # Compare two nodes by their revision number in the environment's
-            # revision history.  Since the revision number both represents the
-            # most efficient order to read the nodes in, and represents a
-            # topological sorting of the nodes, this function is often useful.
-            def cmp_by_rev(a, b):
-                return cmp(revlog.rev(a), revlog.rev(b))
-            return cmp_by_rev
-
         # If we determine that a particular file or manifest node must be a
         # node that the recipient of the changegroup will already have, we can
         # also assume the recipient will have all the parents.  This function
         # prunes them from the set of missing nodes.
         def prune_parents(revlog, hasset, msngset):
             haslst = list(hasset)
-            haslst.sort(cmp_by_rev_func(revlog))
+            haslst.sort(key=revlog.rev)
             for node in haslst:
                 parentlst = [p for p in revlog.parents(node) if p != nullid]
                 while parentlst:
@@ -1874,7 +1863,7 @@
             add_extra_nodes(1, msng_mnfst_set)
             msng_mnfst_lst = msng_mnfst_set.keys()
             # Sort the manifestnodes by revision number.
-            msng_mnfst_lst.sort(cmp_by_rev_func(mnfst))
+            msng_mnfst_lst.sort(key=mnfst.rev)
             # Create a generator for the manifestnodes that calls our lookup
             # and data collection functions back.
             group = mnfst.group(msng_mnfst_lst, lookup_manifest_link,
@@ -1912,7 +1901,7 @@
                     yield changegroup.chunkheader(len(fname))
                     yield fname
                     # Sort the filenodes by their revision #
-                    msng_filenode_lst.sort(cmp_by_rev_func(filerevlog))
+                    msng_filenode_lst.sort(key=filerevlog.rev)
                     # Create a group generator and only pass in a changenode
                     # lookup function as we need to collect no information
                     # from filenodes.
--- a/mercurial/lsprof.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/lsprof.py	Wed Jul 08 17:03:50 2009 -0700
@@ -26,12 +26,10 @@
         """XXX docstring"""
         if crit not in profiler_entry.__dict__:
             raise ValueError("Can't sort by %s" % crit)
-        self.data.sort(lambda b, a: cmp(getattr(a, crit),
-                                        getattr(b, crit)))
+        self.data.sort(key=lambda x: getattr(x, crit), reverse=True)
         for e in self.data:
             if e.calls:
-                e.calls.sort(lambda b, a: cmp(getattr(a, crit),
-                                              getattr(b, crit)))
+                e.calls.sort(key=lambda x: getattr(x, crit), reverse=True)
 
     def pprint(self, top=None, file=None, limit=None, climit=None):
         """XXX docstring"""
--- a/mercurial/match.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/match.py	Wed Jul 08 17:03:50 2009 -0700
@@ -5,7 +5,8 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2, incorporated herein by reference.
 
-import util, re
+import re
+import util
 
 class match(object):
     def __init__(self, root, cwd, patterns, include=[], exclude=[],
--- a/mercurial/merge.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/merge.py	Wed Jul 08 17:03:50 2009 -0700
@@ -131,11 +131,13 @@
         if m == n: # flags agree
             return m # unchanged
         if m and n and not a: # flags set, don't agree, differ from parent
-            r = repo.ui.prompt(
+            r = repo.ui.promptchoice(
                 _(" conflicting flags for %s\n"
                   "(n)one, e(x)ec or sym(l)ink?") % f,
-                (_("&None"), _("E&xec"), _("Sym&link")), _("n"))
-            return r != _("n") and r or ''
+                (_("&None"), _("E&xec"), _("Sym&link")), 0)
+            if r == 1: return "x" # Exec
+            if r == 2: return "l" # Symlink
+            return ""
         if m and m != a: # changed from a to m
             return m
         if n and n != a: # changed from a to n
@@ -191,10 +193,10 @@
                     f, f2, f, fmerge(f, f2, f2), False)
         elif f in ma: # clean, a different, no remote
             if n != ma[f]:
-                if repo.ui.prompt(
+                if repo.ui.promptchoice(
                     _(" local changed %s which remote deleted\n"
                       "use (c)hanged version or (d)elete?") % f,
-                    (_("&Changed"), _("&Delete")), _("c")) == _("d"):
+                    (_("&Changed"), _("&Delete")), 0):
                     act("prompt delete", "r", f)
                 else:
                     act("prompt keep", "a", f)
@@ -222,10 +224,10 @@
         elif f not in ma:
             act("remote created", "g", f, m2.flags(f))
         elif n != ma[f]:
-            if repo.ui.prompt(
+            if repo.ui.promptchoice(
                 _("remote changed %s which local deleted\n"
                   "use (c)hanged version or leave (d)eleted?") % f,
-                (_("&Changed"), _("&Deleted")), _("c")) == _("c"):
+                (_("&Changed"), _("&Deleted")), 0) == 0:
                 act("prompt recreating", "g", f, m2.flags(f))
 
     return action
@@ -288,7 +290,7 @@
                 continue
             f2, fd, flags, move = a[2:]
             r = ms.resolve(fd, wctx, mctx)
-            if r > 0:
+            if r is not None and r > 0:
                 unresolved += 1
             else:
                 if r is None:
--- a/mercurial/patch.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/patch.py	Wed Jul 08 17:03:50 2009 -0700
@@ -325,10 +325,6 @@
         # looks through the hash and finds candidate lines.  The
         # result is a list of line numbers sorted based on distance
         # from linenum
-        def sorter(a, b):
-            vala = abs(a - linenum)
-            valb = abs(b - linenum)
-            return cmp(vala, valb)
 
         try:
             cand = self.hash[l]
@@ -337,7 +333,7 @@
 
         if len(cand) > 1:
             # resort our list of potentials forward then back.
-            cand.sort(sorter)
+            cand.sort(key=lambda x: abs(x - linenum))
         return cand
 
     def hashlines(self):
@@ -1139,7 +1135,7 @@
         raise util.Abort(_('Unsupported line endings type: %s') % eolmode)
 
     try:
-        fp = file(patchobj, 'rb')
+        fp = open(patchobj, 'rb')
     except TypeError:
         fp = patchobj
     if cwd:
@@ -1422,8 +1418,8 @@
         # If diffstat runs out of room it doesn't print anything, which
         # isn't very useful, so always print at least one + or - if there
         # were at least some changes
-        pluses = '+' * max(adds/factor, int(bool(adds)))
-        minuses = '-' * max(removes/factor, int(bool(removes)))
+        pluses = '+' * max(adds // factor, int(bool(adds)))
+        minuses = '-' * max(removes // factor, int(bool(removes)))
         output.append(' %-*s |  %*.d %s%s\n' % (maxname, filename, countwidth,
                                                 adds+removes, pluses, minuses))
 
--- a/mercurial/posix.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/posix.py	Wed Jul 08 17:03:50 2009 -0700
@@ -9,7 +9,7 @@
 import osutil
 import os, sys, errno, stat, getpass, pwd, grp
 
-posixfile = file
+posixfile = open
 nulldev = '/dev/null'
 normpath = os.path.normpath
 samestat = os.path.samestat
@@ -70,20 +70,20 @@
     if l:
         if not stat.S_ISLNK(s):
             # switch file to link
-            data = file(f).read()
+            data = open(f).read()
             os.unlink(f)
             try:
                 os.symlink(data, f)
             except:
                 # failed to make a link, rewrite file
-                file(f, "w").write(data)
+                open(f, "w").write(data)
         # no chmod needed at this point
         return
     if stat.S_ISLNK(s):
         # switch link to file
         data = os.readlink(f)
         os.unlink(f)
-        file(f, "w").write(data)
+        open(f, "w").write(data)
         s = 0666 & ~umask # avoid restatting for chmod
 
     sx = s & 0100
--- a/mercurial/pure/base85.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/pure/base85.py	Wed Jul 08 17:03:50 2009 -0700
@@ -25,8 +25,8 @@
     longs = len(text) >> 2
     words = struct.unpack('>%dL' % (longs), text)
 
-    out = ''.join(_b85chars[(word / 52200625) % 85] +
-                  _b85chars2[(word / 7225) % 7225] +
+    out = ''.join(_b85chars[(word // 52200625) % 85] +
+                  _b85chars2[(word // 7225) % 7225] +
                   _b85chars2[word % 7225]
                   for word in words)
 
@@ -37,7 +37,7 @@
     olen = l % 4
     if olen:
         olen += 1
-    olen += l / 4 * 5
+    olen += l // 4 * 5
     return out[:olen]
 
 def b85decode(text):
--- a/mercurial/pure/osutil.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/pure/osutil.py	Wed Jul 08 17:03:50 2009 -0700
@@ -8,7 +8,7 @@
 import os
 import stat as _stat
 
-posixfile = file
+posixfile = open
 
 def _mode_to_kind(mode):
     if _stat.S_ISREG(mode): return _stat.S_IFREG
--- a/mercurial/revlog.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/revlog.py	Wed Jul 08 17:03:50 2009 -0700
@@ -879,7 +879,7 @@
         if len(id) < 40:
             try:
                 # hex(node)[:...]
-                l = len(id) / 2  # grab an even number of digits
+                l = len(id) // 2  # grab an even number of digits
                 bin_id = bin(id[:l*2])
                 nl = [n for n in self.nodemap if n[:l] == bin_id]
                 nl = [n for n in nl if hex(n).startswith(id)]
@@ -1354,7 +1354,7 @@
             f.seek(0, 2)
             actual = f.tell()
             s = self._io.size
-            i = max(0, actual / s)
+            i = max(0, actual // s)
             di = actual - (i * s)
             if self._inline:
                 databytes = 0
--- a/mercurial/subrepo.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/subrepo.py	Wed Jul 08 17:03:50 2009 -0700
@@ -63,11 +63,11 @@
                 wctx.sub(s).get(r)
                 sm[s] = r
             elif l[0] != r[0]: # sources differ
-                if repo.ui.prompt(
+                if repo.ui.promptchoice(
                     _(' subrepository sources for %s differ\n'
                       'use (l)ocal source (%s) or (r)emote source (%s)?')
                       % (s, l[0], r[0]),
-                      (_('&Local'), _('&Remote')), _('l')) == _('r'):
+                      (_('&Local'), _('&Remote')), 0):
                     wctx.sub(s).get(r)
                     sm[s] = r
             elif l[1] == a[1]: # local side is unchanged
@@ -79,10 +79,10 @@
         elif l == a: # remote removed, local unchanged
             wctx.sub(s).remove()
         else:
-            if repo.ui.prompt(
+            if repo.ui.promptchoice(
                 _(' local changed subrepository %s which remote removed\n'
                   'use (c)hanged version or (d)elete?') % s,
-                  (_('&Changed'), _('&Delete')), _('c')) == _('d'):
+                (_('&Changed'), _('&Delete')), 0):
                 wctx.sub(s).remove()
 
     for s, r in s2.items():
@@ -92,10 +92,10 @@
             wctx.sub(s).get(r)
             sm[s] = r
         elif r != sa[s]:
-            if repo.ui.prompt(
+            if repo.ui.promptchoice(
                 _(' remote changed subrepository %s which local removed\n'
                   'use (c)hanged version or (d)elete?') % s,
-                  (_('&Changed'), _('&Delete')), _('c')) == _('c'):
+                (_('&Changed'), _('&Delete')), 0) == 0:
                 wctx.sub(s).get(r)
                 sm[s] = r
 
--- a/mercurial/templatefilters.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/templatefilters.py	Wed Jul 08 17:03:50 2009 -0700
@@ -41,7 +41,7 @@
 
     delta = max(1, int(now - then))
     for t, s in agescales:
-        n = delta / s
+        n = delta // s
         if n >= 2 or s == 1:
             return fmt(t, n)
 
--- a/mercurial/ui.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/ui.py	Wed Jul 08 17:03:50 2009 -0700
@@ -269,30 +269,35 @@
             line = line[:-1]
         return line
 
-    def prompt(self, msg, choices=None, default="y"):
-        """Prompt user with msg, read response, and ensure it matches
-        one of the provided choices. choices is a sequence of acceptable
-        responses with the format: ('&None', 'E&xec', 'Sym&link')
-        No sequence implies no response checking. Responses are case
-        insensitive. If ui is not interactive, the default is returned.
+    def prompt(self, msg, default="y"):
+        """Prompt user with msg, read response.
+        If ui is not interactive, the default is returned.
         """
         if not self.interactive():
             self.write(msg, ' ', default, "\n")
             return default
+        try:
+            r = self._readline(msg + ' ')
+            if not r:
+                return default
+            return r
+        except EOFError:
+            raise util.Abort(_('response expected'))
+
+    def promptchoice(self, msg, choices, default=0):
+        """Prompt user with msg, read response, and ensure it matches
+        one of the provided choices. The index of the choice is returned.
+        choices is a sequence of acceptable responses with the format:
+        ('&None', 'E&xec', 'Sym&link') Responses are case insensitive. 
+        If ui is not interactive, the default is returned.
+        """
+        resps = [s[s.index('&')+1].lower() for s in choices]
         while True:
-            try:
-                r = self._readline(msg + ' ')
-                if not r:
-                    return default
-                if not choices:
-                    return r
-                resps = [s[s.index('&')+1].lower() for s in choices]
-                if r.lower() in resps:
-                    return r.lower()
-                else:
-                    self.write(_("unrecognized response\n"))
-            except EOFError:
-                raise util.Abort(_('response expected'))
+            r = self.prompt(msg, resps[default])
+            if r.lower() in resps:
+                return resps.index(r.lower())
+            self.write(_("unrecognized response\n"))
+
 
     def getpass(self, prompt=None, default=None):
         if not self.interactive(): return default
--- a/mercurial/util.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/util.py	Wed Jul 08 17:03:50 2009 -0700
@@ -939,8 +939,8 @@
     t, tz = date or makedate()
     if "%1" in format or "%2" in format:
         sign = (tz > 0) and "-" or "+"
-        minutes = abs(tz) / 60
-        format = format.replace("%1", "%c%02d" % (sign, minutes / 60))
+        minutes = abs(tz) // 60
+        format = format.replace("%1", "%c%02d" % (sign, minutes // 60))
         format = format.replace("%2", "%02d" % (minutes % 60))
     s = time.strftime(format, time.gmtime(float(t) - tz))
     return s
--- a/mercurial/verify.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/mercurial/verify.py	Wed Jul 08 17:03:50 2009 -0700
@@ -147,7 +147,7 @@
     if havemf:
         for c,m in sorted([(c, m) for m in mflinkrevs for c in mflinkrevs[m]]):
             err(c, _("changeset refers to unknown manifest %s") % short(m))
-        del mflinkrevs
+        mflinkrevs = None # del is bad here due to scope issues
 
         for f in sorted(filelinkrevs):
             if f not in filenodes:
--- a/setup.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/setup.py	Wed Jul 08 17:03:50 2009 -0700
@@ -143,7 +143,7 @@
             break
 
 if version:
-    f = file("mercurial/__version__.py", "w")
+    f = open("mercurial/__version__.py", "w")
     f.write('# this file is autogenerated by setup.py\n')
     f.write('version = "%s"\n' % version)
     f.close()
--- a/tests/killdaemons.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/killdaemons.py	Wed Jul 08 17:03:50 2009 -0700
@@ -4,7 +4,7 @@
 
 # Kill off any leftover daemon processes
 try:
-    fp = file(os.environ['DAEMON_PIDS'])
+    fp = open(os.environ['DAEMON_PIDS'])
     for line in fp:
         try:
             pid = int(line)
--- a/tests/run-tests.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/run-tests.py	Wed Jul 08 17:03:50 2009 -0700
@@ -119,6 +119,8 @@
         help="shortcut for --with-hg=<testdir>/../hg")
     parser.add_option("--pure", action="store_true",
         help="use pure Python code instead of C extensions")
+    parser.add_option("-3", "--py3k-warnings", action="store_true",
+        help="enable Py3k warnings on Python 2.6+")
 
     for option, default in defaults.items():
         defaults[option] = int(os.environ.get(*default))
@@ -171,6 +173,10 @@
     if options.interactive and options.jobs > 1:
         print '(--interactive overrides --jobs)'
         options.jobs = 1
+    if options.py3k_warnings:
+        if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0):
+            print 'ERROR: Py3k warnings switch can only be used on Python 2.6+'
+            sys.exit(1)
 
     return (options, args)
 
@@ -299,6 +305,17 @@
     f.close()
     os.chmod(os.path.join(BINDIR, 'diffstat'), 0700)
 
+    if options.py3k_warnings and not options.anycoverage:
+        vlog("# Updating hg command to enable Py3k Warnings switch")
+        f = open(os.path.join(BINDIR, 'hg'), 'r')
+        lines = [line.rstrip() for line in f]
+        lines[0] += ' -3'
+        f.close()
+        f = open(os.path.join(BINDIR, 'hg'), 'w')
+        for line in lines:
+            f.write(line + '\n')
+        f.close()
+
     if options.anycoverage:
         vlog("# Installing coverage wrapper")
         os.environ['COVERAGE_FILE'] = COVERAGE_FILE
@@ -402,7 +419,7 @@
     vlog("# Test", test)
 
     # create a fresh hgrc
-    hgrc = file(HGRCPATH, 'w+')
+    hgrc = open(HGRCPATH, 'w+')
     hgrc.write('[ui]\n')
     hgrc.write('slash = True\n')
     hgrc.write('[defaults]\n')
@@ -432,7 +449,8 @@
     lctest = test.lower()
 
     if lctest.endswith('.py') or firstline == '#!/usr/bin/env python':
-        cmd = '%s "%s"' % (PYTHON, testpath)
+        py3kswitch = options.py3k_warnings and ' -3' or ''
+        cmd = '%s%s "%s"' % (PYTHON, py3kswitch, testpath)
     elif lctest.endswith('.bat'):
         # do not run batch scripts on non-windows
         if os.name != 'nt':
@@ -507,7 +525,7 @@
 
     # Kill off any leftover daemon processes
     try:
-        fp = file(DAEMON_PIDS)
+        fp = open(DAEMON_PIDS)
         for line in fp:
             try:
                 pid = int(line)
--- a/tests/test-context.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-context.py	Wed Jul 08 17:03:50 2009 -0700
@@ -7,7 +7,7 @@
 os.chdir('test1')
 
 # create 'foo' with fixed time stamp
-f = file('foo', 'w')
+f = open('foo', 'w')
 f.write('foo\n')
 f.close()
 os.utime('foo', (1000, 1000))
--- a/tests/test-convert-cvs-branch	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-convert-cvs-branch	Wed Jul 08 17:03:50 2009 -0700
@@ -83,7 +83,8 @@
 
 cvscall -Q -d `pwd`/cvsmaster2 init >/dev/null 2>&1
 cd cvsmaster2
-export CVSROOT=`pwd`
+CVSROOT=`pwd`
+export CVSROOT
 mkdir foo
 cd ..
 cvscall -Q co -d cvswork2 foo
--- a/tests/test-convert.out	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-convert.out	Wed Jul 08 17:03:50 2009 -0700
@@ -17,45 +17,45 @@
     - Mercurial [hg]
     - Subversion [svn] (history on branches is not preserved)
 
-    If no revision is given, all revisions will be converted.
-    Otherwise, convert will only import up to the named revision
-    (given in a format understood by the source).
+    If no revision is given, all revisions will be converted. Otherwise,
+    convert will only import up to the named revision (given in a format
+    understood by the source).
 
-    If no destination directory name is specified, it defaults to the
-    basename of the source with '-hg' appended. If the destination
-    repository doesn't exist, it will be created.
+    If no destination directory name is specified, it defaults to the basename
+    of the source with '-hg' appended. If the destination repository doesn't
+    exist, it will be created.
 
-    By default, all sources except Mercurial will use
-    --branchsort. Mercurial uses --sourcesort to preserve original
-    revision numbers order. Sort modes have the following effects:
-      --branchsort: convert from parent to child revision when
-        possible, which means branches are usually converted one after
-        the other. It generates more compact repositories.
+    By default, all sources except Mercurial will use --branchsort. Mercurial
+    uses --sourcesort to preserve original revision numbers order. Sort modes
+    have the following effects:
+      --branchsort: convert from parent to child revision when possible, which
+        means branches are usually converted one after the other. It generates
+        more compact repositories.
       --datesort: sort revisions by date. Converted repositories have
-        good-looking changelogs but are often an order of magnitude
-        larger than the same ones generated by --branchsort.
-      --sourcesort: try to preserve source revisions order, only
-        supported by Mercurial sources.
+        good-looking changelogs but are often an order of magnitude larger
+        than the same ones generated by --branchsort.
+      --sourcesort: try to preserve source revisions order, only supported by
+        Mercurial sources.
 
     If <REVMAP> isn't given, it will be put in a default location
-    (<dest>/.hg/shamap by default). The <REVMAP> is a simple text file
-    that maps each source commit ID to the destination ID for that
-    revision, like so:
+    (<dest>/.hg/shamap by default). The <REVMAP> is a simple text file that
+    maps each source commit ID to the destination ID for that revision, like
+    so:
+
     <source ID> <destination ID>
 
-    If the file doesn't exist, it's automatically created. It's
-    updated on each commit copied, so convert-repo can be interrupted
-    and can be run repeatedly to copy new commits.
+    If the file doesn't exist, it's automatically created. It's updated on
+    each commit copied, so convert-repo can be interrupted and can be run
+    repeatedly to copy new commits.
 
-    The [username mapping] file is a simple text file that maps each
-    source commit author to a destination commit author. It is handy
-    for source SCMs that use unix logins to identify authors (eg:
-    CVS). One line per author mapping and the line format is:
-    srcauthor=whatever string you want
+    The [username mapping] file is a simple text file that maps each source
+    commit author to a destination commit author. It is handy for source SCMs
+    that use unix logins to identify authors (eg: CVS). One line per author
+    mapping and the line format is: srcauthor=whatever string you want
 
-    The filemap is a file that allows filtering and remapping of files
-    and directories. Comment lines start with '#'. Each line can
-    contain one of the following directives:
+    The filemap is a file that allows filtering and remapping of files and
+    directories. Comment lines start with '#'. Each line can contain one of
+    the following directives:
 
       include path/to/file
 
@@ -63,35 +63,32 @@
 
       rename from/file to/file
 
-    The 'include' directive causes a file, or all files under a
-    directory, to be included in the destination repository, and the
-    exclusion of all other files and directories not explicitly included.
-    The 'exclude' directive causes files or directories to be omitted.
-    The 'rename' directive renames a file or directory. To rename from
-    a subdirectory into the root of the repository, use '.' as the
-    path to rename to.
+    The 'include' directive causes a file, or all files under a directory, to
+    be included in the destination repository, and the exclusion of all other
+    files and directories not explicitly included. The 'exclude' directive
+    causes files or directories to be omitted. The 'rename' directive renames
+    a file or directory. To rename from a subdirectory into the root of the
+    repository, use '.' as the path to rename to.
 
-    The splicemap is a file that allows insertion of synthetic
-    history, letting you specify the parents of a revision. This is
-    useful if you want to e.g. give a Subversion merge two parents, or
-    graft two disconnected series of history together. Each entry
-    contains a key, followed by a space, followed by one or two
-    comma-separated values. The key is the revision ID in the source
-    revision control system whose parents should be modified (same
-    format as a key in .hg/shamap). The values are the revision IDs
-    (in either the source or destination revision control system) that
+    The splicemap is a file that allows insertion of synthetic history,
+    letting you specify the parents of a revision. This is useful if you want
+    to e.g. give a Subversion merge two parents, or graft two disconnected
+    series of history together. Each entry contains a key, followed by a
+    space, followed by one or two comma-separated values. The key is the
+    revision ID in the source revision control system whose parents should be
+    modified (same format as a key in .hg/shamap). The values are the revision
+    IDs (in either the source or destination revision control system) that
     should be used as the new parents for that node.
 
     The branchmap is a file that allows you to rename a branch when it is
     being brought in from whatever external repository. When used in
-    conjunction with a splicemap, it allows for a powerful combination
-    to help fix even the most badly mismanaged repositories and turn them
-    into nicely structured Mercurial repositories. The branchmap contains
-    lines of the form "original_branch_name new_branch_name".
-    "original_branch_name" is the name of the branch in the source
-    repository, and "new_branch_name" is the name of the branch is the
-    destination repository. This can be used to (for instance) move code
-    in one repository from "default" to a named branch.
+    conjunction with a splicemap, it allows for a powerful combination to help
+    fix even the most badly mismanaged repositories and turn them into nicely
+    structured Mercurial repositories. The branchmap contains lines of the
+    form "original_branch_name new_branch_name". "original_branch_name" is the
+    name of the branch in the source repository, and "new_branch_name" is the
+    name of the branch is the destination repository. This can be used to (for
+    instance) move code in one repository from "default" to a named branch.
 
     Mercurial Source
     -----------------
@@ -101,75 +98,73 @@
         repositories with missing revlogs, by converting from and to
         Mercurial.
     --config convert.hg.saverev=False         (boolean)
-        store original revision ID in changeset (forces target IDs to
-        change)
+        store original revision ID in changeset (forces target IDs to change)
     --config convert.hg.startrev=0            (hg revision identifier)
         convert start revision and its descendants
 
     CVS Source
     ----------
 
-    CVS source will use a sandbox (i.e. a checked-out copy) from CVS
-    to indicate the starting point of what will be converted. Direct
-    access to the repository files is not needed, unless of course the
-    repository is :local:. The conversion uses the top level directory
-    in the sandbox to find the CVS repository, and then uses CVS rlog
-    commands to find files to convert. This means that unless a
-    filemap is given, all files under the starting directory will be
-    converted, and that any directory reorganization in the CVS
-    sandbox is ignored.
+    CVS source will use a sandbox (i.e. a checked-out copy) from CVS to
+    indicate the starting point of what will be converted. Direct access to
+    the repository files is not needed, unless of course the repository is
+    :local:. The conversion uses the top level directory in the sandbox to
+    find the CVS repository, and then uses CVS rlog commands to find files to
+    convert. This means that unless a filemap is given, all files under the
+    starting directory will be converted, and that any directory
+    reorganization in the CVS sandbox is ignored.
 
     Because CVS does not have changesets, it is necessary to collect
-    individual commits to CVS and merge them into changesets. CVS
-    source uses its internal changeset merging code by default but can
-    be configured to call the external 'cvsps' program by setting:
+    individual commits to CVS and merge them into changesets. CVS source uses
+    its internal changeset merging code by default but can be configured to
+    call the external 'cvsps' program by setting:
+
         --config convert.cvsps='cvsps -A -u --cvs-direct -q'
+
     This option is deprecated and will be removed in Mercurial 1.4.
 
     The options shown are the defaults.
 
     Internal cvsps is selected by setting
+
         --config convert.cvsps=builtin
+
     and has a few more configurable options:
         --config convert.cvsps.cache=True     (boolean)
             Set to False to disable remote log caching, for testing and
             debugging purposes.
         --config convert.cvsps.fuzz=60        (integer)
-            Specify the maximum time (in seconds) that is allowed
-            between commits with identical user and log message in a
-            single changeset. When very large files were checked in as
-            part of a changeset then the default may not be long
-            enough.
+            Specify the maximum time (in seconds) that is allowed between
+            commits with identical user and log message in a single changeset.
+            When very large files were checked in as part of a changeset then
+            the default may not be long enough.
         --config convert.cvsps.mergeto='{{mergetobranch ([-\w]+)}}'
-            Specify a regular expression to which commit log messages
-            are matched. If a match occurs, then the conversion
-            process will insert a dummy revision merging the branch on
-            which this log message occurs to the branch indicated in
-            the regex.
+            Specify a regular expression to which commit log messages are
+            matched. If a match occurs, then the conversion process will
+            insert a dummy revision merging the branch on which this log
+            message occurs to the branch indicated in the regex.
         --config convert.cvsps.mergefrom='{{mergefrombranch ([-\w]+)}}'
-            Specify a regular expression to which commit log messages
-            are matched. If a match occurs, then the conversion
-            process will add the most recent revision on the branch
-            indicated in the regex as the second parent of the
-            changeset.
+            Specify a regular expression to which commit log messages are
+            matched. If a match occurs, then the conversion process will add
+            the most recent revision on the branch indicated in the regex as
+            the second parent of the changeset.
 
-    The hgext/convert/cvsps wrapper script allows the builtin
-    changeset merging code to be run without doing a conversion. Its
-    parameters and output are similar to that of cvsps 2.1.
+    The hgext/convert/cvsps wrapper script allows the builtin changeset
+    merging code to be run without doing a conversion. Its parameters and
+    output are similar to that of cvsps 2.1.
 
     Subversion Source
     -----------------
 
-    Subversion source detects classical trunk/branches/tags layouts.
-    By default, the supplied "svn://repo/path/" source URL is
-    converted as a single branch. If "svn://repo/path/trunk" exists it
-    replaces the default branch. If "svn://repo/path/branches" exists,
-    its subdirectories are listed as possible branches. If
-    "svn://repo/path/tags" exists, it is looked for tags referencing
-    converted branches. Default "trunk", "branches" and "tags" values
-    can be overridden with following options. Set them to paths
-    relative to the source URL, or leave them blank to disable auto
-    detection.
+    Subversion source detects classical trunk/branches/tags layouts. By
+    default, the supplied "svn://repo/path/" source URL is converted as a
+    single branch. If "svn://repo/path/trunk" exists it replaces the default
+    branch. If "svn://repo/path/branches" exists, its subdirectories are
+    listed as possible branches. If "svn://repo/path/tags" exists, it is
+    looked for tags referencing converted branches. Default "trunk",
+    "branches" and "tags" values can be overridden with following options. Set
+    them to paths relative to the source URL, or leave them blank to disable
+    auto detection.
 
     --config convert.svn.branches=branches    (directory name)
         specify the directory containing branches
@@ -178,9 +173,9 @@
     --config convert.svn.trunk=trunk          (directory name)
         specify the name of the trunk branch
 
-    Source history can be retrieved starting at a specific revision,
-    instead of being integrally converted. Only single branch
-    conversions are supported.
+    Source history can be retrieved starting at a specific revision, instead
+    of being integrally converted. Only single branch conversions are
+    supported.
 
     --config convert.svn.startrev=0           (svn revision number)
         specify start Subversion revision.
@@ -188,15 +183,14 @@
     Perforce Source
     ---------------
 
-    The Perforce (P4) importer can be given a p4 depot path or a
-    client specification as source. It will convert all files in the
-    source to a flat Mercurial repository, ignoring labels, branches
-    and integrations. Note that when a depot path is given you then
-    usually should specify a target directory, because otherwise the
-    target may be named ...-hg.
+    The Perforce (P4) importer can be given a p4 depot path or a client
+    specification as source. It will convert all files in the source to a flat
+    Mercurial repository, ignoring labels, branches and integrations. Note
+    that when a depot path is given you then usually should specify a target
+    directory, because otherwise the target may be named ...-hg.
 
-    It is possible to limit the amount of source history to be
-    converted by specifying an initial Perforce revision.
+    It is possible to limit the amount of source history to be converted by
+    specifying an initial Perforce revision.
 
     --config convert.p4.startrev=0            (perforce changelist number)
         specify initial Perforce revision.
--- a/tests/test-dispatch.out	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-dispatch.out	Wed Jul 08 17:03:50 2009 -0700
@@ -5,13 +5,13 @@
 
 output the current or given revision of files
 
-    Print the specified files as they were at the given revision. If
-    no revision is given, the parent of the working directory is used,
-    or tip if no revision is checked out.
+    Print the specified files as they were at the given revision. If no
+    revision is given, the parent of the working directory is used, 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
-    for the export command, with the following additions:
+    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 for the export
+    command, with the following additions:
 
     %s   basename of file being printed
     %d   dirname of file being printed, or '.' if in repository root
--- a/tests/test-dispatch.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-dispatch.py	Wed Jul 08 17:03:50 2009 -0700
@@ -15,14 +15,14 @@
 os.chdir('test1')
 
 # create file 'foo', add and commit
-f = file('foo', 'wb')
+f = open('foo', 'wb')
 f.write('foo\n')
 f.close()
 testdispatch("add foo")
 testdispatch("commit -m commit1 -d 2000-01-01 foo")
 
 # append to file 'foo' and commit
-f = file('foo', 'ab')
+f = open('foo', 'ab')
 f.write('bar\n')
 f.close()
 testdispatch("commit -m commit2 -d 2000-01-02 foo")
--- a/tests/test-extdiff.out	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-extdiff.out	Wed Jul 08 17:03:50 2009 -0700
@@ -7,14 +7,13 @@
 
 use 'echo' to diff repository (or selected files)
 
-            Show differences between revisions for the specified
-            files, using the 'echo' program.
+    Show differences between revisions for the specified files, using the
+    'echo' program.
 
-            When two revision arguments are given, then changes are
-            shown between those revisions. If only one revision is
-            specified then that revision is compared to the working
-            directory, and, when no revisions are specified, the
-            working directory files are compared to its parent.
+    When two revision arguments are given, then changes are shown between
+    those revisions. If only one revision is specified then that revision is
+    compared to the working directory, and, when no revisions are specified,
+    the working directory files are compared to its parent.
 
 options:
 
--- a/tests/test-gpg	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-gpg	Wed Jul 08 17:03:50 2009 -0700
@@ -7,7 +7,7 @@
 gpg=
 
 [gpg]
-cmd=gpg --no-permission-warning --homedir $TESTDIR/gpg
+cmd=gpg --no-permission-warning --no-secmem-warning --homedir $TESTDIR/gpg
 EOF
 
 hg init r
--- a/tests/test-help.out	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-help.out	Wed Jul 08 17:03:50 2009 -0700
@@ -170,11 +170,10 @@
 
 add the specified files on the next commit
 
-    Schedule files to be version controlled and added to the
-    repository.
+    Schedule files to be version controlled and added to the repository.
 
-    The files will be added to the repository at the next commit. To
-    undo an add before that, see hg forget.
+    The files will be added to the repository at the next commit. To undo an
+    add before that, see hg forget.
 
     If no names are given, add all files to the repository.
 
@@ -190,11 +189,10 @@
 
 add the specified files on the next commit
 
-    Schedule files to be version controlled and added to the
-    repository.
+    Schedule files to be version controlled and added to the repository.
 
-    The files will be added to the repository at the next commit. To
-    undo an add before that, see hg forget.
+    The files will be added to the repository at the next commit. To undo an
+    add before that, see hg forget.
 
     If no names are given, add all files to the repository.
 
@@ -213,22 +211,21 @@
 
     Differences between files are shown using the unified diff format.
 
-    NOTE: diff may generate unexpected results for merges, as it will
-    default to comparing against the working directory's first parent
-    changeset if no revisions are specified.
+    NOTE: diff may generate unexpected results for merges, as it will default
+    to comparing against the working directory's first parent changeset if no
+    revisions are specified.
 
-    When two revision arguments are given, then changes are shown
-    between those revisions. If only one revision is specified then
-    that revision is compared to the working directory, and, when no
-    revisions are specified, the working directory files are compared
-    to its parent.
+    When two revision arguments are given, then changes are shown between
+    those revisions. If only one revision is specified then that revision is
+    compared to the working directory, and, when no revisions are specified,
+    the working directory files are compared to its parent.
 
-    Without the -a/--text option, diff will avoid generating diffs of
-    files it detects as binary. With -a, diff will generate a diff
-    anyway, probably with undesirable results.
+    Without the -a/--text option, diff will avoid generating diffs of files it
+    detects as binary. With -a, diff will generate a diff anyway, probably
+    with undesirable results.
 
-    Use the -g/--git option to generate diffs in the git extended diff
-    format. For more information, read 'hg help diffs'.
+    Use the -g/--git option to generate diffs in the git extended diff format.
+    For more information, read 'hg help diffs'.
 
 options:
 
@@ -252,24 +249,22 @@
 
 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
-    the source of a copy/move operation, are not listed unless
-    -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
-    Unless options described with "show only ..." are given, the
-    options -mardu are used.
+    Show status of files in the repository. If names are given, only files
+    that match are shown. Files that are clean or ignored or the source of a
+    copy/move operation, are not listed unless -c/--clean, -i/--ignored,
+    -C/--copies or -A/--all are given. Unless options described with "show
+    only ..." are given, the options -mardu are used.
 
-    Option -q/--quiet hides untracked (unknown and ignored) files
-    unless explicitly requested with -u/--unknown or -i/--ignored.
+    Option -q/--quiet hides untracked (unknown and ignored) files unless
+    explicitly requested with -u/--unknown or -i/--ignored.
 
-    NOTE: status may appear to disagree with diff if permissions have
-    changed or a merge has occurred. The standard diff format does not
-    report permission changes and diff only reports changes relative
-    to one merge parent.
+    NOTE: status may appear to disagree with diff if permissions have changed
+    or a merge has occurred. The standard diff format does not report
+    permission changes and diff only reports changes relative to one merge
+    parent.
 
-    If one revision is given, it is used as the base revision.
-    If two revisions are given, the differences between them are
-    shown.
+    If one revision is given, it is used as the base revision. If two
+    revisions are given, the differences between them are shown.
 
     The codes used to show the status of files are:
     M = modified
--- a/tests/test-hook	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-hook	Wed Jul 08 17:03:50 2009 -0700
@@ -230,4 +230,22 @@
 
 hg showconfig hooks | sed -e 's/ at .*>/>/'
 
+echo '# test python hook configured with python:[file]:[hook] syntax'
+cd ..
+mkdir d
+cd d
+hg init repo
+mkdir hooks
+
+cd hooks
+cat > testhooks.py <<EOF
+def testhook(**args):
+    print 'hook works'
+EOF
+echo '[hooks]' > ../repo/.hg/hgrc
+echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
+
+cd ../repo
+hg commit
+
 exit 0
--- a/tests/test-hook.out	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-hook.out	Wed Jul 08 17:03:50 2009 -0700
@@ -160,3 +160,6 @@
 Automatically installed hook
 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
 hooks.commit.auto=<function autohook>
+# test python hook configured with python:[file]:[hook] syntax
+hook works
+nothing changed
--- a/tests/test-keyword.out	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-keyword.out	Wed Jul 08 17:03:50 2009 -0700
@@ -1,15 +1,15 @@
 % help
 keyword extension - expand keywords in tracked files
 
-This extension expands RCS/CVS-like or self-customized $Keywords$ in
-tracked text files selected by your configuration.
+This extension expands RCS/CVS-like or self-customized $Keywords$ in tracked
+text files selected by your configuration.
 
-Keywords are only expanded in local repositories and not stored in the
-change history. The mechanism can be regarded as a convenience for the
-current user or for archive distribution.
+Keywords are only expanded in local repositories and not stored in the change
+history. The mechanism can be regarded as a convenience for the current user
+or for archive distribution.
 
-Configuration is done in the [keyword] and [keywordmaps] sections of
-hgrc files.
+Configuration is done in the [keyword] and [keywordmaps] sections of hgrc
+files.
 
 Example:
 
@@ -18,33 +18,32 @@
     **.py =
     x*    = ignore
 
-Note: the more specific you are in your filename patterns
-      the less you lose speed in huge repositories.
+Note: the more specific you are in your filename patterns the less you lose
+      speed in huge repositories.
 
-For [keywordmaps] template mapping and expansion demonstration and
-control run "hg kwdemo".
+For [keywordmaps] template mapping and expansion demonstration and control run
+"hg kwdemo".
 
 An additional date template filter {date|utcdate} is provided.
 
-The default template mappings (view with "hg kwdemo -d") can be
-replaced with customized keywords and templates. Again, run "hg
-kwdemo" to control the results of your config changes.
+The default template mappings (view with "hg kwdemo -d") can be replaced with
+customized keywords and templates. Again, run "hg kwdemo" to control the
+results of your config changes.
 
-Before changing/disabling active keywords, run "hg kwshrink" to avoid
-the risk of inadvertently storing expanded keywords in the change
-history.
+Before changing/disabling active keywords, run "hg kwshrink" to avoid the risk
+of inadvertently storing expanded keywords in the change history.
 
-To force expansion after enabling it, or a configuration change, run
-"hg kwexpand".
+To force expansion after enabling it, or a configuration change, run "hg
+kwexpand".
 
-Also, when committing with the record extension or using mq's qrecord,
-be aware that keywords cannot be updated. Again, run "hg kwexpand" on
-the files in question to update keyword expansions after all changes
-have been checked in.
+Also, when committing with the record extension or using mq's qrecord, be
+aware that keywords cannot be updated. Again, run "hg kwexpand" on the files
+in question to update keyword expansions after all changes have been checked
+in.
 
-Expansions spanning more than one line and incremental expansions,
-like CVS' $Log$, are not supported. A keyword template map
-"Log = {desc}" expands to the first line of the changeset description.
+Expansions spanning more than one line and incremental expansions, like CVS'
+$Log$, are not supported. A keyword template map "Log = {desc}" expands to the
+first line of the changeset description.
 
 list of commands:
 
--- a/tests/test-mq.out	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-mq.out	Wed Jul 08 17:03:50 2009 -0700
@@ -2,11 +2,11 @@
 mq extension - manage a stack of patches
 
 This extension lets you work with a stack of patches in a Mercurial
-repository. It manages two stacks of patches - all known patches, and
-applied patches (subset of known patches).
+repository. It manages two stacks of patches - all known patches, and applied
+patches (subset of known patches).
 
-Known patches are represented as patch files in the .hg/patches
-directory. Applied patches are both patch files and changesets.
+Known patches are represented as patch files in the .hg/patches directory.
+Applied patches are both patch files and changesets.
 
 Common tasks (use "hg help command" for more details):
 
--- a/tests/test-notify.out	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-notify.out	Wed Jul 08 17:03:50 2009 -0700
@@ -1,7 +1,7 @@
 notify extension - hooks for sending email notifications at commit/push time
 
-Subscriptions can be managed through hgrc. Default mode is to print
-messages to stdout, for testing and configuring.
+Subscriptions can be managed through hgrc. Default mode is to print messages
+to stdout, for testing and configuring.
 
 To use, configure notify extension and enable in hgrc like this:
 
@@ -40,9 +40,8 @@
    [web]
    baseurl = http://hgserver/... # root of hg web site for browsing commits
 
- notify config file has same format as regular hgrc. it has two
- sections so you can express subscriptions in whatever way is handier
- for you.
+ notify config file has same format as regular hgrc. it has two sections so
+ you can express subscriptions in whatever way is handier for you.
 
    [usersubs]
    # key is subscriber email, value is ","-separated list of glob patterns
@@ -54,8 +53,8 @@
 
  glob patterns are matched against path to repository root.
 
- if you like, you can put notify config file in repository that users
- can push changes to, they can manage their own subscriptions.
+ if you like, you can put notify config file in repository that users can push
+ changes to, they can manage their own subscriptions.
 
 no commands defined
 % commit
--- a/tests/test-patchbomb.out	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-patchbomb.out	Wed Jul 08 17:03:50 2009 -0700
@@ -10,7 +10,7 @@
 X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
 Message-Id: <8580ff50825a50c8f716.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -42,7 +42,7 @@
 Subject: [PATCH 0 of 2] test
 Message-Id: <patchbomb.120@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:02:00 -0000
+Date: Thu, 01 Jan 1970 00:02:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -58,7 +58,7 @@
 In-Reply-To: <patchbomb.120@
 References: <patchbomb.120@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:02:01 -0000
+Date: Thu, 01 Jan 1970 00:02:01 +0000
 From: quux
 To: foo
 Cc: bar
@@ -86,7 +86,7 @@
 In-Reply-To: <patchbomb.120@
 References: <patchbomb.120@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:02:02 -0000
+Date: Thu, 01 Jan 1970 00:02:02 +0000
 From: quux
 To: foo
 Cc: bar
@@ -124,7 +124,7 @@
 Subject: test
 Message-Id: <patchbomb.180@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:03:00 -0000
+Date: Thu, 01 Jan 1970 00:03:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -157,13 +157,13 @@
 adding utf
 % no mime encoding for email --test
 % md5sum of 8-bit output
-1b28ee86c937a1f9e2bf6fc5eabd00a5  mailtest
+e726c29b3008e77994c7572563e57c34  mailtest
 % mime encoded mbox (base64)
 This patch series consists of 1 patches.
 
 
 Writing [PATCH] charset=utf-8; content-transfer-encoding: base64 ...
-From quux Thu Jan 01 00:04:01 1970
+From quux Thu Jan  1 00:04:01 1970
 Content-Type: text/plain; charset="utf-8"
 MIME-Version: 1.0
 Content-Transfer-Encoding: base64
@@ -171,7 +171,7 @@
 X-Mercurial-Node: c3c9e37db9f4fe4882cda39baf42fed6bad8b15a
 Message-Id: <c3c9e37db9f4fe4882cd.240@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:04:00 -0000
+Date: Thu, 01 Jan 1970 00:04:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -192,13 +192,13 @@
 adding qp
 % no mime encoding for email --test
 % md5sum of qp output
-7b5f11d50349b32eff4a9b2daaa82e7f  mailtest
+0402c7d033e04044e423bb04816f9dae  mailtest
 % mime encoded mbox (quoted-printable)
 This patch series consists of 1 patches.
 
 
 Writing [PATCH] charset=utf-8; content-transfer-encoding: quoted-printable ...
-From quux Thu Jan 01 00:04:01 1970
+From quux Thu Jan  1 00:04:01 1970
 Content-Type: text/plain; charset="us-ascii"
 MIME-Version: 1.0
 Content-Transfer-Encoding: quoted-printable
@@ -206,7 +206,7 @@
 X-Mercurial-Node: c655633f8c87700bb38cc6a59a2753bdc5a6c376
 Message-Id: <c655633f8c87700bb38c.240@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:04:00 -0000
+Date: Thu, 01 Jan 1970 00:04:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -249,7 +249,7 @@
 
 Writing [PATCH] charset=us-ascii; content-transfer-encoding: 8bit ...
 % md5sum of 8-bit output
-e61684fc0bcccba4204714be37951893  mboxfix
+0920ef519c29b6a1742047ad9f203fc5  mboxfix
 % test diffstat for single patch
 This patch series consists of 1 patches.
 
@@ -267,7 +267,7 @@
 X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
 Message-Id: <ff2c9fa2018b15fa74b3.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -319,7 +319,7 @@
 Subject: [PATCH 0 of 2] test
 Message-Id: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -339,7 +339,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:01 -0000
+Date: Thu, 01 Jan 1970 00:01:01 +0000
 From: quux
 To: foo
 Cc: bar
@@ -371,7 +371,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:02 -0000
+Date: Thu, 01 Jan 1970 00:01:02 +0000
 From: quux
 To: foo
 Cc: bar
@@ -404,7 +404,7 @@
 X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
 Message-Id: <ff2c9fa2018b15fa74b3.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -440,7 +440,7 @@
 X-Mercurial-Node: c655633f8c87700bb38cc6a59a2753bdc5a6c376
 Message-Id: <c655633f8c87700bb38c.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -495,7 +495,7 @@
 Subject: [PATCH 0 of 3] test
 Message-Id: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -510,7 +510,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:01 -0000
+Date: Thu, 01 Jan 1970 00:01:01 +0000
 From: quux
 To: foo
 Cc: bar
@@ -544,7 +544,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:02 -0000
+Date: Thu, 01 Jan 1970 00:01:02 +0000
 From: quux
 To: foo
 Cc: bar
@@ -579,7 +579,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:03 -0000
+Date: Thu, 01 Jan 1970 00:01:03 +0000
 From: quux
 To: foo
 Cc: bar
@@ -631,7 +631,7 @@
 X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
 Message-Id: <ff2c9fa2018b15fa74b3.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -676,7 +676,7 @@
 X-Mercurial-Node: c655633f8c87700bb38cc6a59a2753bdc5a6c376
 Message-Id: <c655633f8c87700bb38c.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -740,7 +740,7 @@
 Subject: [PATCH 0 of 3] test
 Message-Id: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -755,7 +755,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:01 -0000
+Date: Thu, 01 Jan 1970 00:01:01 +0000
 From: quux
 To: foo
 Cc: bar
@@ -798,7 +798,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:02 -0000
+Date: Thu, 01 Jan 1970 00:01:02 +0000
 From: quux
 To: foo
 Cc: bar
@@ -842,7 +842,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:03 -0000
+Date: Thu, 01 Jan 1970 00:01:03 +0000
 From: quux
 To: foo
 Cc: bar
@@ -906,7 +906,7 @@
 Subject: [PATCH 0 of 1] test
 Message-Id: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -922,7 +922,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:01 -0000
+Date: Thu, 01 Jan 1970 00:01:01 +0000
 From: quux
 To: foo
 Cc: bar
@@ -954,7 +954,7 @@
 Subject: [PATCH 0 of 2] test
 Message-Id: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -970,7 +970,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:01 -0000
+Date: Thu, 01 Jan 1970 00:01:01 +0000
 From: quux
 To: foo
 Cc: bar
@@ -998,7 +998,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:02 -0000
+Date: Thu, 01 Jan 1970 00:01:02 +0000
 From: quux
 To: foo
 Cc: bar
@@ -1028,7 +1028,7 @@
 X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
 Message-Id: <ff2c9fa2018b15fa74b3.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -1067,7 +1067,7 @@
 Subject: [PATCH 0 of 2] test
 Message-Id: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -1082,7 +1082,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:01 -0000
+Date: Thu, 01 Jan 1970 00:01:01 +0000
 From: quux
 To: foo
 Cc: bar
@@ -1116,7 +1116,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:02 -0000
+Date: Thu, 01 Jan 1970 00:01:02 +0000
 From: quux
 To: foo
 Cc: bar
@@ -1155,7 +1155,7 @@
 In-Reply-To: <baz>
 References: <baz>
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -1192,7 +1192,7 @@
 In-Reply-To: <baz>
 References: <baz>
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:00 -0000
+Date: Thu, 01 Jan 1970 00:01:00 +0000
 From: quux
 To: foo
 Cc: bar
@@ -1208,7 +1208,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:01 -0000
+Date: Thu, 01 Jan 1970 00:01:01 +0000
 From: quux
 To: foo
 Cc: bar
@@ -1236,7 +1236,7 @@
 In-Reply-To: <patchbomb.60@
 References: <patchbomb.60@
 User-Agent: Mercurial-patchbomb
-Date: Thu, 01 Jan 1970 00:01:02 -0000
+Date: Thu, 01 Jan 1970 00:01:02 +0000
 From: quux
 To: foo
 Cc: bar
--- a/tests/test-qrecord.out	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-qrecord.out	Wed Jul 08 17:03:50 2009 -0700
@@ -28,8 +28,7 @@
 
 interactively record a new patch
 
-    See 'hg help qnew' & 'hg help record' for more information and
-    usage.
+    See 'hg help qnew' & 'hg help record' for more information and usage.
 
 options:
 
--- a/tests/test-rebase-parameters.out	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-rebase-parameters.out	Wed Jul 08 17:03:50 2009 -0700
@@ -6,9 +6,9 @@
 
 move changeset (and descendants) to a different branch
 
-    Rebase uses repeated merging to graft changesets from one part of
-    history onto another. This can be useful for linearizing local
-    changes relative to a master development tree.
+    Rebase uses repeated merging to graft changesets from one part of history
+    onto another. This can be useful for linearizing local changes relative to
+    a master development tree.
 
     If a rebase is interrupted to manually resolve a merge, it can be
     continued with --continue/-c or aborted with --abort/-a.
@@ -34,9 +34,9 @@
 
 move changeset (and descendants) to a different branch
 
-    Rebase uses repeated merging to graft changesets from one part of
-    history onto another. This can be useful for linearizing local
-    changes relative to a master development tree.
+    Rebase uses repeated merging to graft changesets from one part of history
+    onto another. This can be useful for linearizing local changes relative to
+    a master development tree.
 
     If a rebase is interrupted to manually resolve a merge, it can be
     continued with --continue/-c or aborted with --abort/-a.
@@ -62,9 +62,9 @@
 
 move changeset (and descendants) to a different branch
 
-    Rebase uses repeated merging to graft changesets from one part of
-    history onto another. This can be useful for linearizing local
-    changes relative to a master development tree.
+    Rebase uses repeated merging to graft changesets from one part of history
+    onto another. This can be useful for linearizing local changes relative to
+    a master development tree.
 
     If a rebase is interrupted to manually resolve a merge, it can be
     continued with --continue/-c or aborted with --abort/-a.
@@ -90,9 +90,9 @@
 
 move changeset (and descendants) to a different branch
 
-    Rebase uses repeated merging to graft changesets from one part of
-    history onto another. This can be useful for linearizing local
-    changes relative to a master development tree.
+    Rebase uses repeated merging to graft changesets from one part of history
+    onto another. This can be useful for linearizing local changes relative to
+    a master development tree.
 
     If a rebase is interrupted to manually resolve a merge, it can be
     continued with --continue/-c or aborted with --abort/-a.
--- a/tests/test-record.out	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-record.out	Wed Jul 08 17:03:50 2009 -0700
@@ -3,15 +3,14 @@
 
 interactively select changes to commit
 
-    If a list of files is omitted, all changes reported by "hg status"
-    will be candidates for recording.
+    If a list of files is omitted, all changes reported by "hg status" will be
+    candidates for recording.
 
     See 'hg help dates' for a list of formats valid for -d/--date.
 
-    You will be prompted for whether to record changes to each
-    modified file, and for files with multiple changes, for each
-    change to use. For each query, the following responses are
-    possible:
+    You will be prompted for whether to record changes to each modified file,
+    and for files with multiple changes, for each change to use. For each
+    query, the following responses are possible:
 
     y - record this change
     n - skip this change
--- a/tests/test-revlog-ancestry.py	Wed Jul 08 17:03:16 2009 -0700
+++ b/tests/test-revlog-ancestry.py	Wed Jul 08 17:03:50 2009 -0700
@@ -10,7 +10,7 @@
     repo.commit(text=text, date="%d 0" % time)
 
 def addcommit(name, time):
-    f = file(name, 'w')
+    f = open(name, 'w')
     f.write('%s\n' % name)
     f.close()
     repo.add([name])