Пример #1
0
    def test_config_override(self, repo: Repo, wc: WorkingCopy) -> None:
        wc.file(path="sparse/base", content="sparse/\n")
        wc.file(path="a")
        wc.file(path="b")
        commit1 = wc.commit()

        wc.hg.push(rev=commit1.hash, to="master", create=True)

        # We support sparse rules coming from dynamic config.
        self.config.add("sparseprofile", "include.blah.sparse/base", "a")

        sparse_wc = WorkingCopy(repo, new_dir())
        repo.hg.clone(repo.url, sparse_wc.root, enable_profile="sparse/base")

        self.assertEqual(
            sorted(sparse_wc.hg.files().stdout.rstrip().split("\n")),
            ["a", "sparse/base"],
        )

        self.assertTrue(sparse_wc.status().empty())

        # Make sure Python agrees what files we should have.
        sparse_wc.hg.sparse("refresh")
        self.assertEqual(
            sorted(sparse_wc.hg.files().stdout.rstrip().split("\n")),
            ["a", "sparse/base"],
        )
Пример #2
0
    def test_resume(self, repo: Repo, wc: WorkingCopy) -> None:
        wc.file(path="foo")
        commit1 = wc.commit()

        wc.hg.push(rev=commit1.hash, to="master", create=True)

        clone_wc = WorkingCopy(repo, new_dir())

        with self.assertRaises(CommandFailure):
            repo.hg.clone(
                repo.url,
                clone_wc.root,
                env={"FAILPOINTS": "checkout-post-progress=return"},
            )

        self.assertEqual(len(clone_wc.status().untracked), 1)

        # Make sure "checkout --continue" works and skips the file.
        self.assertRegex(
            clone_wc.hg.checkout(**{
                "continue": True,
                "env": {
                    "EDENSCM_LOG": "checkout=debug"
                }
            }).stderr,
            "Skipping checking out 1 files since they're already written",
        )
        self.assertTrue(clone_wc.status().empty())
Пример #3
0
    def test_simple(self, repo: Repo, wc: WorkingCopy) -> None:
        wc.file(path="sparse/base", content="sparse/\ninc/\n")
        wc.file(path="inc/foo")
        wc.file(path="inc/bar")
        wc.file(path="exc/foo")
        commit1 = wc.commit()

        wc.hg.push(rev=commit1.hash, to="master", create=True)

        sparse_wc = WorkingCopy(repo, new_dir())
        repo.hg.clone(repo.url, sparse_wc.root, enable_profile="sparse/base")

        self.assertEqual(
            sorted(sparse_wc.hg.files().stdout.rstrip().split("\n")),
            ["inc/bar", "inc/foo", "sparse/base"],
        )

        self.assertTrue(sparse_wc.status().empty())

        # Make sure Python agrees what files we should have.
        sparse_wc.hg.sparse("refresh")
        self.assertEqual(
            sorted(sparse_wc.hg.files().stdout.rstrip().split("\n")),
            ["inc/bar", "inc/foo", "sparse/base"],
        )
Пример #4
0
    def test_clone_within_repo(self, repo: Repo, wc: WorkingCopy) -> None:
        repo.config.add("commands", "force-rust", "\0oops")

        other_repo = self.server.clone(1)
        other_wc = WorkingCopy(other_repo, new_dir())

        # clone repo1 from within repo0
        # we shouldn't see the invalid config value from repo0's config
        wc.hg.clone(other_repo.url, other_wc.root)
Пример #5
0
    def test_repo_specific_config(self, repo: Repo, _: WorkingCopy) -> None:
        config_dir = new_dir()
        config_dir.joinpath(f"{repo.name}.rc").write_text("[foo]\nbar=baz\n")

        self.config.add("clone", "repo-specific-config-dir", str(config_dir))

        cloned_repo = self.server.clone()

        self.assertEqual(
            cloned_repo.hg.config("foo.bar").stdout.strip(),
            "baz",
        )
Пример #6
0
    def test_dirstate_mtime_race(self, repo: Repo, wc: WorkingCopy) -> None:
        wc.file(path="foo", content="foo")
        commit1 = wc.commit()

        wc.hg.push(rev=commit1.hash, to="master", create=True)

        other_wc = WorkingCopy(repo, new_dir())
        other_wc.hg.clone(repo.url, other_wc.root)

        # Try to update our file in the same second the checkout finished.
        other_wc["foo"].write("bar")

        # Make sure we pick up "foo" as modified.
        self.assertEqual(
            other_wc.status().modified,
            ["foo"],
        )
Пример #7
0
    def test_multiple_profiles(self, repo: Repo, wc: WorkingCopy) -> None:
        wc.file(path="sparse/a", content="sparse/a\na\n")
        wc.file(path="sparse/b", content="sparse/b\nb\n")
        wc.file(path="a")
        wc.file(path="b")
        wc.file(path="c")
        commit1 = wc.commit()

        wc.hg.push(rev=commit1.hash, to="master", create=True)

        sparse_wc = WorkingCopy(repo, new_dir())
        repo.hg.clone(repo.url,
                      sparse_wc.root,
                      enable_profile=["sparse/a", "sparse/b"])

        self.assertEqual(
            sorted(sparse_wc.hg.files().stdout.rstrip().split("\n")),
            ["a", "b", "sparse/a", "sparse/b"],
        )
        self.assertTrue(sparse_wc.status().empty())