2015-01-17 03:25:30 +03:00
|
|
|
#require test-repo
|
|
|
|
|
2013-11-18 03:13:55 +04:00
|
|
|
This code uses the ast module, which was new in 2.6, so we'll skip
|
|
|
|
this test on anything earlier.
|
2014-10-15 23:35:59 +04:00
|
|
|
$ $PYTHON -c 'import sys ; assert sys.version_info >= (2, 6)' || exit 80
|
2013-11-18 03:13:55 +04:00
|
|
|
|
2013-11-17 22:38:35 +04:00
|
|
|
$ import_checker="$TESTDIR"/../contrib/import-checker.py
|
2015-01-17 03:25:30 +03:00
|
|
|
|
2013-11-17 22:38:35 +04:00
|
|
|
Run the doctests from the import checker, and make sure
|
|
|
|
it's working correctly.
|
|
|
|
$ TERM=dumb
|
|
|
|
$ export TERM
|
|
|
|
$ python -m doctest $import_checker
|
|
|
|
|
|
|
|
$ cd "$TESTDIR"/..
|
|
|
|
|
|
|
|
There are a handful of cases here that require renaming a module so it
|
|
|
|
doesn't overlap with a stdlib module name. There are also some cycles
|
|
|
|
here that we should still endeavor to fix, and some cycles will be
|
|
|
|
hidden by deduplication algorithm in the cycle detector, so fixing
|
|
|
|
these may expose other cycles.
|
|
|
|
|
2015-05-13 19:49:10 +03:00
|
|
|
$ hg locate 'mercurial/**.py' | sed 's-\\-/-g' | python "$import_checker" -
|
2014-02-05 04:43:51 +04:00
|
|
|
mercurial/dispatch.py mixed imports
|
|
|
|
stdlib: commands
|
|
|
|
relative: error, extensions, fancyopts, hg, hook, util
|
|
|
|
mercurial/fileset.py mixed imports
|
|
|
|
stdlib: parser
|
|
|
|
relative: error, merge, util
|
|
|
|
mercurial/revset.py mixed imports
|
|
|
|
stdlib: parser
|
2015-04-14 19:54:16 +03:00
|
|
|
relative: error, hbisect, phases, util
|
2014-02-05 04:43:51 +04:00
|
|
|
mercurial/templater.py mixed imports
|
|
|
|
stdlib: parser
|
template: add revset() template function
Adds a template function that executes a revset and returns the list of
revisions as the result. It has the signature 'revset(query [, args...])'. The
args are optional and are applied to the query string using the standard
python string.format(args) pattern. This allows things like:
'{revset("parents({0})", rev)}' to produce the parents of each individual
commit in the log output. If no args are specified, the revset result is
cached for the duration of the templater; so it's better to not use args if
performance is a concern.
By itself, revset() can be used to print commit parents, print the common
ancestor of a commit with the main branch, etc.
It can be used with the ifcontains() function to do things like
'{ifcontains(rev, revset('.'), label(...), ...)}' to color the working copy
parent, to color certain branches, to color draft commits, etc.
2014-02-12 09:04:12 +04:00
|
|
|
relative: config, error, templatefilters, templatekw, util
|
2014-02-05 04:43:51 +04:00
|
|
|
mercurial/ui.py mixed imports
|
|
|
|
stdlib: formatter
|
|
|
|
relative: config, error, scmutil, util
|
2015-03-28 02:50:39 +03:00
|
|
|
Import cycle: mercurial.cmdutil -> mercurial.context -> mercurial.subrepo -> mercurial.cmdutil
|
import-checker: make imported_modules yield absolute dotted_name_of_path
This patch makes `imported_modules()` always yield absolute
`dotted_name_of_path()`-ed name by strict detection with
`fromlocal()`.
This change improves circular detection in some points:
- locally defined modules, of which name collides against one of
standard library, can be examined correctly
For example, circular import related to `commands` is overlooked
before this patch.
- names not useful for circular detection are ignored
Names below are also yielded before this patch:
- module names of standard library (= not locally defined one)
- non-module names (e.g. `node.nullid` of `from node import nullid`)
These redundant names decrease performance of circular detection.
For example, with files at 13dc86d189c9, average loops per file in
`checkmod()` is reduced from 165 to 109.
- `__init__` can be handled correctly in `checkmod()`
For example, current implementation has problems below:
- `from xxx import yyy` doesn't recognize `xxx.__init__` as imported
- `xxx.__init__` imported via `import xxx` is treated as `xxx`,
and circular detection is aborted, because `key` of such
module name is not `xxx` but `xxx.__init__`
- it is easy to enhance for `from . import xxx` style or so (in the
future)
Module name detection in `imported_modules()` can use information
in `ast.ImportFrom` fully.
It is assumed that all locally defined modules are correctly specified
to `import-checker.py` at once.
Strictly speaking, when `from foo.bar.baz import module1` imports
`foo.bar.baz.module1` module, current `imported_modules()` yields only
`foo.bar.baz.__init__`, even though also `foo.__init__` and
`foo.bar.__init__` should be yielded to detect circular import
exactly.
But this limitation is reasonable one for improvement in this patch,
because current `__init__` files in Mercurial seems to be implemented
carefully.
2015-05-17 20:52:55 +03:00
|
|
|
Import cycle: mercurial.commands -> mercurial.commandserver -> mercurial.dispatch -> mercurial.commands
|