annotate tests/test-cat.t @ 19933:621a26eb3a99

demandimport: allow extensions to import own modules by absolute name Before this patch, python modules of each extensions can't import another one in own extension by absolute name, because root modules of each extensions are loaded with "hgext_" prefix. For example, "import extroot.bar" in "extroot/foo.py" of "extroot" extension fails, even though "import bar" in it succeeds. Installing extensions into site-packages of python library path can avoid this problem, but this solution is not reasonable in some cases: using binary package of Mercurial on Windows, for example. This patch retries to import with "hgext_" prefix after ImportError, if the module in the extension may try to import another one in own extension. This patch doesn't change some "_import()"/"_origimport()" invocations below, because ordinary extensions shouldn't cause such invocations. - invocation of "_import()" when root module imports sub-module by absolute path without "fromlist" for example, "import a.b" in "a.__init__.py". extensions are loaded with "hgext_" prefix, and this causes execution of another (= fixed by this patch) code path. - invocation of "_origimport()" when "level != -1" with "fromlist" for example, importing after "from __future__ import absolute_import" (level == 0), or "from . import b" or "from .a import b" (0 < level), for portability between python versions and environments, extensions shouldn't cause "level != -1".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 05 Oct 2013 01:02:22 +0900
parents 1310489eb5d6
children 50107a4b32e7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11874
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
1 $ hg init
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
2 $ echo 0 > a
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
3 $ echo 0 > b
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 12070
diff changeset
4 $ hg ci -A -m m
11874
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
5 adding a
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
6 adding b
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
7 $ hg rm a
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
8 $ hg cat a
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
9 0
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
10 $ hg cat --decode a # more tests in test-encode
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
11 0
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
12 $ echo 1 > b
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 12070
diff changeset
13 $ hg ci -m m
11874
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
14 $ echo 2 > b
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
15 $ hg cat -r 0 a
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
16 0
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
17 $ hg cat -r 0 b
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
18 0
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
19 $ hg cat -r 1 a
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 12070
diff changeset
20 a: no such file in rev 7040230c159c
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12156
diff changeset
21 [1]
11874
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
22 $ hg cat -r 1 b
a3c1234b3761 tests: unify test-cat
Martin Geisler <mg@lazybytes.net>
parents: 6328
diff changeset
23 1
17371
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
24
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
25 Test fileset
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
26
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
27 $ echo 3 > c
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
28 $ hg ci -Am addmore c
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
29 $ hg cat 'set:not(b) or a'
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
30 3
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
31 $ hg cat 'set:c or b'
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
32 1
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
33 3
1310489eb5d6 fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents: 12316
diff changeset
34