sapling/tests/test-hgsubversion-fetch-truncated.py
Jun Wu 9dc21f8d0b codemod: import from the edenscm package
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
2019-01-29 17:25:32 -08:00

34 lines
1.1 KiB
Python

import test_hgsubversion_util
from edenscm.mercurial import commands, hg
class TestFetchTruncatedHistory(test_hgsubversion_util.TestBase):
stupid_mode_tests = True
def test_truncated_history(self):
# Test repository does not follow the usual layout
repo_path = self.load_svndump("truncatedhistory.svndump")
svn_url = test_hgsubversion_util.fileurl(repo_path + "/project2")
commands.clone(self.ui(), svn_url, self.wc_path, noupdate=True)
repo = hg.repository(self.ui(), self.wc_path)
# We are converting /project2/trunk coming from:
#
# Changed paths:
# D /project1
# A /project2/trunk (from /project1:2)
#
# Here a full fetch should be performed since we are starting
# the conversion on an already filled branch.
tip = repo["tip"]
files = tip.manifest().keys()
files.sort()
self.assertEqual(files, ["a", "b"])
self.assertEqual(repo["tip"]["a"].data(), "a\n")
if __name__ == "__main__":
import silenttestrunner
silenttestrunner.main(__name__)