sapling/tests/test-legacy.t
Jun Wu a987ecb9b2 ui: use Rust config parser in Mercurial
Summary:
Switch `ui.load` and `ui.readconfig` to use the Rust config parser.
`ui` now no longer depends on `config.config` or `rcutil`.

Pest's error messages are fancier, thus most test changes.

For the fbsource repo, debugshell shows the new code is 10+x faster:

On laptop:

Before:

  In [1]: %timeit m.ui.ui.load()
  10 loops, best of 3: 27.8 ms per loop

After:

  In [1]: %timeit m.ui.ui.load()
  100 loops, best of 3: 1.85 ms per loop

On devserver:

Before:

  In [1]: %timeit m.ui.ui.load()
  100 loops, best of 3: 16.8 ms per loop

After:

  In [1]: %timeit m.ui.ui.load()
  1000 loops, best of 3: 1.28 ms per loop

Since `ui._rcfg` is no longer copy-on-write, there is concern about `ui.copy()`
performance. It is faster too (on devserver):

Before:

  In [1]: %timeit ui.copy()
  1000 loops, best of 3: 198 µs per loop

After:

  In [1]: %timeit ui.copy()
  10000 loops, best of 3: 157 µs per loop

The old `ui.py` was copied to `legacyui.py` and can replace the new `ui.py` if
a config file exists on the system.  This provides a way to switch back to the
old config parser in case of emergency.

Reviewed By: mitrandir77

Differential Revision: D8887375

fbshipit-source-id: 2951ca622c77bf41187ad5c5cab3445cda0dc519
2018-08-23 17:52:52 -07:00

10 lines
445 B
Raku

$ HGLEGACY= hg debugshell -c 'print(type(ui)); print(m.ui); print(__import__("mercurial.ui").ui)'
<class 'mercurial.ui.ui'>
<module 'mercurial.ui' from '*'> (glob)
<module 'mercurial.ui' from '*'> (glob)
$ HGLEGACY=ui hg debugshell -c 'print(type(ui)); print(m.ui); print(__import__("mercurial.ui").ui)'
<class 'mercurial.legacyui.ui'>
<module 'mercurial.legacyui' from '*'> (glob)
<module 'mercurial.legacyui' from '*'> (glob)