2018-06-09 00:30:12 +03:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
|
|
|
# Copyright (c) 2016-present, Facebook, Inc.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# This source code is licensed under the BSD-style license found in the
|
|
|
|
# LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
# of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
|
|
|
|
from ..lib import hgrepo
|
|
|
|
from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
|
|
|
|
|
|
|
|
|
|
|
|
@hg_test
|
|
|
|
class SparseTest(EdenHgTestCase):
|
|
|
|
def populate_backing_repo(self, repo):
|
|
|
|
repo.write_file("a_file.txt", "")
|
|
|
|
repo.commit("first commit")
|
|
|
|
|
|
|
|
def test_sparse(self):
|
|
|
|
"""Verify that we show a reasonable error if someone has managed
|
|
|
|
to load the sparse extension, rather than an ugly stack trace"""
|
|
|
|
|
|
|
|
for sub in [
|
|
|
|
"clear",
|
|
|
|
"cwd",
|
|
|
|
"delete",
|
2018-10-19 16:49:04 +03:00
|
|
|
"disable",
|
|
|
|
"enable",
|
2018-06-09 00:30:12 +03:00
|
|
|
"exclude",
|
|
|
|
"explain",
|
2018-10-19 16:49:03 +03:00
|
|
|
"files someprofile",
|
2018-06-09 00:30:12 +03:00
|
|
|
"importrules",
|
|
|
|
"include",
|
2018-10-19 16:49:04 +03:00
|
|
|
"show",
|
2018-06-09 00:30:12 +03:00
|
|
|
"list",
|
|
|
|
"refresh",
|
|
|
|
"reset",
|
|
|
|
]:
|
|
|
|
with self.assertRaises(hgrepo.HgError) as context:
|
2018-10-19 16:49:03 +03:00
|
|
|
self.hg("--config", "extensions.sparse=", "sparse", *sub.split())
|
2018-06-09 00:30:12 +03:00
|
|
|
self.assertIn(
|
|
|
|
"don't need sparse profiles",
|
|
|
|
context.exception.stderr.decode("utf-8", errors="replace"),
|
|
|
|
)
|