Summary:
Since september (D9840431) rcutil.rccomponents is no longer source of truth
about which config files we load. In fact we use it only in the
`hg config --debug`. This leads to situations where the debug command mentions
loading a specific config file and then ignores it completely which is very
confusing.
Let's remove it.
Reviewed By: suitingtseng
Differential Revision: D14083220
fbshipit-source-id: 362fd9bf574e24639f99a1203206184da42d1e24
Summary:
Update pest to 2.1.0.
This version has a new behaviour for parser error messages: the line feed at
the end of the line is shown in the error output.
Reviewed By: wez
Differential Revision: D13671099
fbshipit-source-id: b8d1142a44a56a0b21b3b72cf027f3f8a30f421e
Summary: pest was upgraded by me to version 2.x which introduced the concept of End Of Input in the parsin rules. Modify the test case to be aware of this.
Reviewed By: singhsrb
Differential Revision: D10255598
fbshipit-source-id: 31ecf56f5cf75a16c799a93aefe7df9a3837b902
Summary:
Be more permissive about spaces. Namely:
- Spaces after a section name like `[foo] ` are allowed.
- Spaces in config names are allowed.
- Spaces at trailing lines are ignored and no longer insert an `\n` to the previous config.
This makes it closer to the older config parser behavior. But it's still
different on some cases, like `[foo]]`, `[foo] # bar`, `[foo]]` still do not
parse.
Benchmark shows no obvious (within 10%) slowdown. So this is probably fine.
Reviewed By: strager
Differential Revision: D9620253
fbshipit-source-id: 8489ef8e83606d0557db56e8da0a017d55ff1514
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
Summary:
Previously, the following config will generate "b", "a" order.
[section]
a=1
b=2
a=3
It actually makes implementation harder and less efficient (ex. removing an
element from a list is O(N)). The behavior traces back to 2009 [1] where
there is no clue about the above behavior is more desirable.
Let's just change it so the above config will generate "a", "b" order, to
make implementation easier and more efficient.
The old `sortdict` behavior is moved to a different class and used by
http header logic to avoid break them.
[1]: https://www.mercurial-scm.org/repo/hg/rev/fca54469480e
Reviewed By: DurhamG, mitrandir77
Differential Revision: D8767902
fbshipit-source-id: 9fa7baae3b89c3680314e70a674098dd073f5e2b
# skip-blame because this was mechanically rewritten the following script. I
ran it on both *.t and *.py, but none of the *.py changes were proper. All *.t
ones appear to be, and they run without addition failures on both Windows and
Linux.
import argparse
import os
import re
ap = argparse.ArgumentParser()
ap.add_argument('path', nargs='+')
opts = ap.parse_args()
globre = re.compile(r'^(.*) \(glob\)(.*)$')
for p in opts.path:
tmp = p + '.tmp'
with open(p, 'rb') as src, open(tmp, 'wb') as dst:
for line in src:
m = globre.match(line)
if not m or '$LOCALIP' in line or '*' in line:
dst.write(line)
continue
if '?' in line[:-3] or ('?' in line[:-3] and line[-3:] != '(?)'):
dst.write(line)
continue
dst.write(m.group(1) + m.group(2) + '\n')
os.unlink(p)
os.rename(tmp, p)
Aliases define optional alternatives to existing options. For example the old
option ui.user was deprecated and replaced by ui.username. With this mechanism,
it's even possible to create an alias to an option in a different section.
Add ui.user as alias to ui.username as an example of this concept.
The old alternates principle in ui.config is removed as it was used only for
this option.
As explained by the previous patch, we need to set "web.ipv6=True" if we
decide to use IPv6. Otherwise "hg serve" will still try to listen on IPv4.
This patch makes it so by appending web.ipv6 to "extra configs".
This patch was tested in a Linux system with IPv6, by the following steps:
1. Change hgweb/server.py temporarily to write a file if
IPv6HTTPServer.__init__ is called.
2. run-tests.py -l --keep-tmpdir test-serve.t
3. Check the generated .hgrc, make sure it sets web.ipv6=1.
4. Check the log file to make sure IPv6HTTPServer.__init__ is called.
V2:
- Limit escaping to plain formatting only
- Use the formatter consistently (no more ui.debug)
- Always include 'name' and 'value'
V3:
- Always convert 'value' to string (this also makes sure we handle functions)
- Keep real debug message as ui.debug for now
- Add additional tests.
Note: I'm not quite sure about the best approach to handling
the 'print the full config' case.
For me, it printed the 'ui.promptecho' key at the end.
I went with globs there as that at least tests the json display reliably.
Example output:
[
{
"name": "ui.username",
"source": "/home/mathias/.hgrc:2",
"value": "Mathias De Maré <mathias.demare@gmail.com>"
}
]
As part of developing a subsequent patch I discovered that sub-option
values like "." were getting converted to paths. This is because the
[paths] section is treated specially during config loading.
This patch prevents post-processing sub-options from the [paths]
section.
test-largefiles-update.t, test-subrepo.t, test-tag.t, and
test-rename-dir-merge.t still warn about no result returned because of
unnecessary globs that test-check-code-hg.t wants, relating to output for
pushing to, pulling from and moving X to Y.
Added "unexpected leading whitespace" message to parse error
when .hgrc has a line that starts with whitespace.
Helps new users unfamiliar with syntax of rc file.
Before this patch, "%unset" can't unset values defined in the other
files read in previously, even though online help document says that
it can. It can unset only values defined in the same configuration
file.
For example, the value defined in "~/.hgrc" can't be unset by "%unset"
in ".hg/hgrc" of the repository.
This patch records "%unset"-ed values in "config.parse()", and
discards corresponding values in "config.update()".
Before this patch, there is no test script testing configuration
handling generally. "test-config-case.t" seems to be specific for
testing case sensitive configuration.
This patch renames from "test-config-case.t" to "test-config.t" for
centralization of tests around configuration handling.