mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +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
59 lines
1.4 KiB
Python
59 lines
1.4 KiB
Python
from __future__ import absolute_import, print_function
|
|
|
|
import os
|
|
|
|
from edenscm.mercurial import commands, extensions, ui as uimod
|
|
|
|
|
|
ignore = {
|
|
b"",
|
|
b"factotum",
|
|
b"fbconduit",
|
|
b"globalrevs",
|
|
b"hgsql",
|
|
b"highlight",
|
|
b"lz4revlog",
|
|
b"remotenames",
|
|
b"shelve",
|
|
b"win32text",
|
|
}
|
|
|
|
if os.name != "nt":
|
|
ignore.add(b"win32mbcs")
|
|
|
|
disabled = [ext for ext in extensions.disabled().keys() if ext not in ignore]
|
|
|
|
hgrc = open(os.environ["HGRCPATH"], "wb")
|
|
hgrc.write(b"[extensions]\n")
|
|
|
|
for ext in disabled:
|
|
hgrc.write(ext + b"=\n")
|
|
|
|
hgrc.close()
|
|
|
|
u = uimod.ui.load()
|
|
|
|
# Some extensions may print useful warning messages when they are loaded without
|
|
# the necessary config options. Let's capture that output since it does not
|
|
# matter for this test.
|
|
u.pushbuffer(error=True)
|
|
extensions.loadall(u)
|
|
u.popbuffer()
|
|
|
|
globalshort = set()
|
|
globallong = set()
|
|
for option in commands.globalopts:
|
|
option[0] and globalshort.add(option[0])
|
|
option[1] and globallong.add(option[1])
|
|
|
|
for cmd, entry in commands.table.items():
|
|
seenshort = globalshort.copy()
|
|
seenlong = globallong.copy()
|
|
for option in entry[1]:
|
|
if (option[0] and option[0] in seenshort) or (
|
|
option[1] and option[1] in seenlong
|
|
):
|
|
print("command '" + cmd + "' has duplicate option " + str(option))
|
|
seenshort.add(option[0])
|
|
seenlong.add(option[1])
|