mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 09:17:30 +03:00
9dc21f8d0b
Summary: D13853115 adds `edenscm/` to `sys.path` and code still uses `import mercurial`. That has nasty problems if both `import mercurial` and `import edenscm.mercurial` are used, because Python would think `mercurial.foo` and `edenscm.mercurial.foo` are different modules so code like `try: ... except mercurial.error.Foo: ...`, or `isinstance(x, mercurial.foo.Bar)` would fail to handle the `edenscm.mercurial` version. There are also some module-level states (ex. `extensions._extensions`) that would cause trouble if they have multiple versions in a single process. Change imports to use the `edenscm` so ideally the `mercurial` is no longer imported at all. Add checks in extensions.py to catch unexpected extensions importing modules from the old (wrong) locations when running tests. Reviewed By: phillco Differential Revision: D13868981 fbshipit-source-id: f4e2513766957fd81d85407994f7521a08e4de48
57 lines
1.1 KiB
Perl
57 lines
1.1 KiB
Perl
create verbosemmap.py
|
|
$ cat << EOF > verbosemmap.py
|
|
> # extension to make util.mmapread verbose
|
|
>
|
|
> from __future__ import absolute_import
|
|
>
|
|
> from edenscm.mercurial import (
|
|
> extensions,
|
|
> pycompat,
|
|
> util,
|
|
> )
|
|
>
|
|
> def extsetup(ui):
|
|
> def mmapread(orig, fp):
|
|
> ui.write(b"mmapping %s\n" % pycompat.bytestr(fp.name))
|
|
> ui.flush()
|
|
> return orig(fp)
|
|
>
|
|
> extensions.wrapfunction(util, 'mmapread', mmapread)
|
|
> EOF
|
|
|
|
setting up base repo
|
|
$ hg init a
|
|
$ cd a
|
|
$ touch a
|
|
$ hg add a
|
|
$ hg commit -qm base
|
|
$ for i in `$TESTDIR/seq.py 1 100` ; do
|
|
> echo $i > a
|
|
> hg commit -qm $i
|
|
> done
|
|
|
|
set up verbosemmap extension
|
|
$ cat << EOF >> $HGRCPATH
|
|
> [extensions]
|
|
> verbosemmap=$TESTTMP/verbosemmap.py
|
|
> EOF
|
|
|
|
mmap index which is now more than 4k long
|
|
$ hg log -l 5 -T '{rev}\n' --config experimental.mmapindexthreshold=4k
|
|
mmapping $TESTTMP/a/.hg/store/00changelog.i
|
|
100
|
|
99
|
|
98
|
|
97
|
|
96
|
|
|
|
do not mmap index which is still less than 32k
|
|
$ hg log -l 5 -T '{rev}\n' --config experimental.mmapindexthreshold=32k
|
|
100
|
|
99
|
|
98
|
|
97
|
|
96
|
|
|
|
$ cd ..
|