hgfixes: added a fixer to convert changes in the email package
This patch adds a fixer that accounts for changes in python packages, as the
framework provided by lib2to3 is only able to track changes in module names.
This fixer (hopefully) can fix any change in one-level hierarchies.
To exemplify, this fixer can successfully change an import from
"email.MIMEMultipart" to "email.mime.multipart".
contrib/setup3k.py: added script to build hg with py3k
This patch implements a script that inherits most of its functionality from
hg's setup.py and adds support to calling 2to3 during invocation with python3.
The motivation of having this script around is twofold:
1) It enables py3k crazies to test mercurial in py3k and, hopefully, patch it
more easily, so it can improve the py3k support to eventually run there.
2) Being separated from the main setup.py eliminates the need to make hg's
setup.py even more cluttered, and enables "independent" development until
the port is done.
Some considerations about the structure of this patch:
Mercurial already overrides the behavior of build_py, this patch tweaks it a bit
more to add support to call 2to3 with a custom fixer* location for Mercurial.
There is also a need of having the core C modules built *before* the
translation process starts, otherwise 2to3 will think those are global modules.
* A fixer is a python module that transforms python 2.x code in python 3.x
code.
mq: save qrefresh message for easy recovery in case it fails (
issue2062)
Currently, if you start editing a commit message from qrefresh -e and, for any
reason: forget you were editing it, leave the editor open and start qpopping
and qpushing, when you decide to save your commit message, it is going to fail.
This patch copies the commit behavior of saving the message contents in
$HGROOT/.hg/last-message.txt before continuing.
util: avoid using hashlib on Python < 2.5 (
issue2278)
The following patch allows the use of python2.4 with a standalone
hashlib rather than assuming that python2.5 is in use when hashlib is
imported successfully.
revset: predicate to avoid lookup errors
A query like
head() and (descendants("bad") and not descendants("fix"))
(testing if repo heads are affected by a bug) will abort with a
RepoLookupError if either badrev or fixrev aren't found inside
the repository, which is not very informative.
The new predicate returns an empty set for lookup errors, so
head() and (descendants(present("bad")) and not descendants(present("fix")))
will behave as wanted even if those revisions are not found.
demandimport: store level argument on _demandmod instances
The 'level' argument to __import__ was added in Python 2.6, and is
specified for either relative or absolute imports. The fix introduced
in
e160f2312815 allowed such imports to proceed without failure, but
effectively disabled demandimport for them. This is particularly
unfortunate in Python 3.x, where *all* imports are either relative or
absolute.
The solution introduced here is to store the level argument on the
demandimport instance, and propagate it to _origimport() when its
value isn't None.
Please note that this patch hasn't been tested in Python 3.x, and thus
may not be complete. I'm worried about how sub-imports are handled; I
don't know what they are, or whether the level argument should be
modified for them. I've added 'TODO' notes to these cases; hopefully,
someone more knowledgable of these issues will deal with them.