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
113 lines
3.5 KiB
Python
113 lines
3.5 KiB
Python
# no-check-code -- see T24862348
|
|
|
|
import os
|
|
import sys
|
|
|
|
import test_hgsubversion_util
|
|
from edenscm.hgext.hgsubversion import verify
|
|
|
|
|
|
# these fixtures contain no files at HEAD and would result in empty clones
|
|
_skipshallow = set(
|
|
[
|
|
"binaryfiles.svndump",
|
|
"binaryfiles-broken.svndump",
|
|
"emptyrepo.svndump",
|
|
"correct.svndump",
|
|
"corrupt.svndump",
|
|
]
|
|
)
|
|
|
|
_skipall = set(["project_root_not_repo_root.svndump", "movetotrunk.svndump"])
|
|
|
|
_skipstandard = set(
|
|
[
|
|
"subdir_is_file_prefix.svndump",
|
|
"correct.svndump",
|
|
"corrupt.svndump",
|
|
"emptyrepo2.svndump",
|
|
"dir_removal.svndump",
|
|
]
|
|
)
|
|
|
|
|
|
def _do_case(self, name, layout):
|
|
subdir = test_hgsubversion_util.subdir.get(name, "")
|
|
config = {}
|
|
for branch, path in test_hgsubversion_util.custom.get(name, {}).iteritems():
|
|
config["hgsubversionbranch.%s" % branch] = path
|
|
repo, svnpath = self.load_and_fetch(
|
|
name, subdir=subdir, layout=layout, config=config
|
|
)
|
|
assert test_hgsubversion_util.repolen(self.repo) > 0
|
|
for i in repo:
|
|
ctx = repo[i]
|
|
self.assertEqual(verify.verify(repo.ui, repo, rev=ctx.node(), stupid=True), 0)
|
|
self.assertEqual(verify.verify(repo.ui, repo, rev=ctx.node(), stupid=False), 0)
|
|
|
|
# check a startrev clone
|
|
if layout == "single" and name not in _skipshallow:
|
|
self.wc_path += "_shallow"
|
|
shallowrepo = self.fetch(
|
|
svnpath, subdir=subdir, layout="single", startrev="HEAD"
|
|
)
|
|
|
|
self.assertEqual(
|
|
test_hgsubversion_util.repolen(shallowrepo),
|
|
1,
|
|
"shallow clone should have just one revision, not %d"
|
|
% test_hgsubversion_util.repolen(shallowrepo),
|
|
)
|
|
|
|
fulltip = repo["tip"]
|
|
shallowtip = shallowrepo["tip"]
|
|
|
|
repo.ui.pushbuffer()
|
|
self.assertEqual(
|
|
0, verify.verify(repo.ui, shallowrepo, rev=shallowtip.node(), stupid=True)
|
|
)
|
|
self.assertEqual(
|
|
0, verify.verify(repo.ui, shallowrepo, rev=shallowtip.node(), stupid=False)
|
|
)
|
|
|
|
stupidui = test_hgsubversion_util.testui(stupid=True)
|
|
self.assertEqual(verify.verify(stupidui, repo, rev=ctx.node(), stupid=True), 0)
|
|
self.assertEqual(verify.verify(stupidui, repo, rev=ctx.node(), stupid=False), 0)
|
|
|
|
# viewing diff's of lists of files is easier on the eyes
|
|
self.assertMultiLineEqual(
|
|
"\n".join(fulltip), "\n".join(shallowtip), repo.ui.popbuffer()
|
|
)
|
|
|
|
for f in fulltip:
|
|
self.assertMultiLineEqual(fulltip[f].data(), shallowtip[f].data())
|
|
|
|
|
|
def buildmethod(case, name, layout):
|
|
m = lambda self: self._do_case(case, layout)
|
|
m.__name__ = name
|
|
m.__doc__ = "Test verify on %s (%s)" % (case, layout)
|
|
return m
|
|
|
|
|
|
attrs = {"_do_case": _do_case, "stupid_mode_tests": True}
|
|
fixtures = [
|
|
f for f in os.listdir(test_hgsubversion_util.FIXTURES) if f.endswith(".svndump")
|
|
]
|
|
for case in fixtures:
|
|
if case in _skipall:
|
|
continue
|
|
bname = "test_" + case[: -len(".svndump")]
|
|
if case not in _skipstandard:
|
|
attrs[bname] = buildmethod(case, bname, "standard")
|
|
attrs[bname + "_single"] = buildmethod(case, bname + "_single", "single")
|
|
if case in test_hgsubversion_util.custom:
|
|
attrs[bname + "_custom"] = buildmethod(case, bname + "_custom", "custom")
|
|
|
|
VerifyTests = type("VerifyTests", (test_hgsubversion_util.TestBase,), attrs)
|
|
|
|
if __name__ == "__main__":
|
|
import silenttestrunner
|
|
|
|
silenttestrunner.main(__name__)
|