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
92 lines
3.3 KiB
Python
92 lines
3.3 KiB
Python
# no-check-code -- see T24862348
|
|
|
|
import shutil
|
|
|
|
import test_hgsubversion_util
|
|
from edenscm.hgext.hgsubversion import compathacks
|
|
|
|
|
|
class TestSingleDirClone(test_hgsubversion_util.TestBase):
|
|
stupid_mode_tests = True
|
|
|
|
def test_clone_single_dir_simple(self):
|
|
repo = self._load_fixture_and_fetch(
|
|
"branch_from_tag.svndump", layout="single", subdir=""
|
|
)
|
|
self.assertEqual(compathacks.branchset(repo), set(["default"]))
|
|
self.assertEqual(
|
|
sorted(repo["tip"].manifest().keys()),
|
|
[
|
|
"branches/branch_from_tag/alpha",
|
|
"branches/branch_from_tag/beta",
|
|
"tags/copied_tag/alpha",
|
|
"tags/copied_tag/beta",
|
|
"tags/tag_r3/alpha",
|
|
"tags/tag_r3/beta",
|
|
"trunk/alpha",
|
|
"trunk/beta",
|
|
],
|
|
)
|
|
|
|
def test_auto_detect_single(self):
|
|
repo = self._load_fixture_and_fetch("branch_from_tag.svndump", layout="auto")
|
|
self.assertEqual(
|
|
compathacks.branchset(repo), set(["default", "branch_from_tag"])
|
|
)
|
|
oldmanifest = test_hgsubversion_util.filtermanifest(
|
|
repo["default"].manifest().keys()
|
|
)
|
|
# remove standard layout
|
|
shutil.rmtree(self.wc_path)
|
|
# try again with subdir to get single dir clone
|
|
repo = self._load_fixture_and_fetch(
|
|
"branch_from_tag.svndump", layout="auto", subdir="trunk"
|
|
)
|
|
self.assertEqual(compathacks.branchset(repo), set(["default"]))
|
|
self.assertEqual(repo["default"].manifest().keys(), oldmanifest)
|
|
|
|
def test_clone_subdir_is_file_prefix(self):
|
|
FIXTURE = "subdir_is_file_prefix.svndump"
|
|
repo = self._load_fixture_and_fetch(
|
|
FIXTURE, layout="single", subdir=test_hgsubversion_util.subdir[FIXTURE]
|
|
)
|
|
self.assertEqual(compathacks.branchset(repo), set(["default"]))
|
|
self.assertEqual(repo["tip"].manifest().keys(), ["flaf.txt"])
|
|
|
|
def test_externals_single(self):
|
|
repo = self._load_fixture_and_fetch("externals.svndump", layout="single")
|
|
for rev in repo:
|
|
assert ".hgsvnexternals" not in repo[rev].manifest()
|
|
return # TODO enable test when externals in single are fixed
|
|
expect = """[.]
|
|
-r2 ^/externals/project2@2 deps/project2
|
|
[subdir]
|
|
^/externals/project1 deps/project1
|
|
[subdir2]
|
|
^/externals/project1 deps/project1
|
|
"""
|
|
test = 2
|
|
self.assertEqual(self.repo[test][".hgsvnexternals"].data(), expect)
|
|
|
|
def test_externals_single_whole_repo(self):
|
|
# This is the test which demonstrates the brokenness of externals
|
|
return # TODO enable test when externals in single are fixed
|
|
repo = self._load_fixture_and_fetch(
|
|
"externals.svndump", layout="single", subdir=""
|
|
)
|
|
for rev in repo:
|
|
rc = repo[rev]
|
|
if ".hgsvnexternals" in rc:
|
|
extdata = rc[".hgsvnexternals"].data()
|
|
assert "[.]" not in extdata
|
|
print(extdata)
|
|
expect = "" # Not honestly sure what this should be...
|
|
test = 4
|
|
self.assertEqual(self.repo[test][".hgsvnexternals"].data(), expect)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import silenttestrunner
|
|
|
|
silenttestrunner.main(__name__)
|