2017-12-20 08:38:43 +03:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
2019-06-20 02:58:25 +03:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
2017-12-20 08:38:43 +03:00
|
|
|
#
|
2019-06-20 02:58:25 +03:00
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
2017-12-20 08:38:43 +03:00
|
|
|
|
|
|
|
import os
|
2018-05-10 07:33:49 +03:00
|
|
|
|
|
|
|
from eden.integration.hg.lib.hg_extension_test_base import EdenHgTestCase, hg_test
|
2017-12-20 08:38:43 +03:00
|
|
|
from eden.integration.lib import hgrepo
|
|
|
|
|
|
|
|
|
|
|
|
@hg_test
|
|
|
|
class NonEdenOperationTest(EdenHgTestCase):
|
|
|
|
def populate_backing_repo(self, repo: hgrepo.HgRepository) -> None:
|
2018-05-10 07:33:49 +03:00
|
|
|
repo.write_file("hello.txt", "hola")
|
2017-12-20 08:38:43 +03:00
|
|
|
|
|
|
|
def test_hg_clone_non_eden_repo_within_eden_repo(self):
|
2018-05-10 07:33:49 +03:00
|
|
|
"""Regression test to ensure that running `hg` commands from an
|
|
|
|
Eden-backed Hg repo on a non-Eden-backed Hg repo work as expected."""
|
|
|
|
non_eden_hg_repo = os.path.join(self.tmp_dir, "non-eden-hg-repo")
|
2017-12-20 08:38:43 +03:00
|
|
|
os.mkdir(non_eden_hg_repo)
|
|
|
|
|
|
|
|
# Create the non-Eden Hg repo.
|
2018-05-10 07:33:49 +03:00
|
|
|
self.hg("init", cwd=non_eden_hg_repo)
|
|
|
|
first_file = os.path.join(non_eden_hg_repo, "first.txt")
|
|
|
|
with open(first_file, "w") as f:
|
|
|
|
f.write("First file in non-Eden-backed Hg repo.\n")
|
2017-12-20 08:38:43 +03:00
|
|
|
self.hg(
|
2018-05-10 07:33:49 +03:00
|
|
|
"commit",
|
|
|
|
"--config",
|
|
|
|
"ui.username=Kevin Flynn <lightcyclist@example.com>",
|
|
|
|
"-Am",
|
|
|
|
"first commit",
|
|
|
|
cwd=non_eden_hg_repo,
|
2017-12-20 08:38:43 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
# Run `hg clone` from the Eden repo.
|
2018-05-10 07:33:49 +03:00
|
|
|
clone_of_non_eden_hg_repo = os.path.join(self.tmp_dir, "clone-target")
|
2017-12-20 08:38:43 +03:00
|
|
|
self.hg(
|
2018-05-10 07:33:49 +03:00
|
|
|
"clone", non_eden_hg_repo, clone_of_non_eden_hg_repo, cwd=self.repo.path
|
2017-12-20 08:38:43 +03:00
|
|
|
)
|
|
|
|
|
2018-05-10 07:33:49 +03:00
|
|
|
dest_first_file = os.path.join(clone_of_non_eden_hg_repo, "first.txt")
|
|
|
|
with open(dest_first_file, "r") as f:
|
2017-12-20 08:38:43 +03:00
|
|
|
contents = f.read()
|
2018-05-10 07:33:49 +03:00
|
|
|
self.assertEqual("First file in non-Eden-backed Hg repo.\n", contents)
|