mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 06:47:41 +03:00
tests: change HgRepository.status() to return a dictionary
Summary: Update the HgRepository.status() function in the integration tests to return the status information as a dictionary instead of a string. Only one test was still using the old string API. Reviewed By: chadaustin Differential Revision: D10503168 fbshipit-source-id: 574e4438d23bf6612a70ae5ae3174db3d464d198
This commit is contained in:
parent
daa882b16f
commit
d08f63df8f
@ -208,10 +208,6 @@ class EdenHgTestCase(testcase.EdenTestCase):
|
||||
os.chmod(editor, 0o755)
|
||||
return editor
|
||||
|
||||
def status(self):
|
||||
"""Returns the output of `hg status` as a string."""
|
||||
return self.repo.status()
|
||||
|
||||
def assert_status(
|
||||
self,
|
||||
expected: Dict[str, str],
|
||||
@ -227,19 +223,7 @@ class EdenHgTestCase(testcase.EdenTestCase):
|
||||
|
||||
'C' is not currently supported.
|
||||
"""
|
||||
args = ["status", "--print0"]
|
||||
if check_ignored:
|
||||
args.append("-mardui")
|
||||
|
||||
output = self.hg(*args)
|
||||
actual_status = {}
|
||||
for entry in output.split("\0"):
|
||||
if not entry:
|
||||
continue
|
||||
flag = entry[0]
|
||||
path = entry[2:]
|
||||
actual_status[path] = flag
|
||||
|
||||
actual_status = self.repo.status(include_ignored=check_ignored)
|
||||
self.assertDictEqual(expected, actual_status, msg=msg)
|
||||
self.assert_unfinished_operation(op)
|
||||
|
||||
|
@ -19,8 +19,8 @@ class SymlinkTest(EdenHgTestCase):
|
||||
repo.commit("Initial commit.")
|
||||
|
||||
def test_changed_symlink_shows_up_in_status(self):
|
||||
self.assertEqual("", self.repo.status())
|
||||
self.assert_status_empty()
|
||||
|
||||
self.repo.symlink("symlink", "contents2")
|
||||
|
||||
self.assertEqual("M symlink\n", self.repo.status())
|
||||
self.assert_status({"symlink": "M"})
|
||||
|
@ -238,9 +238,25 @@ class HgRepository(repobase.Repository):
|
||||
output = self.hg("journal", "-T", "json")
|
||||
return json.loads(output)
|
||||
|
||||
def status(self) -> str:
|
||||
"""Returns the output of `hg status` as a string."""
|
||||
return self.hg("status")
|
||||
def status(self, include_ignored: bool = False) -> Dict[str, str]:
|
||||
"""Returns the output of `hg status` as a dictionary of {path: status char}.
|
||||
|
||||
The status characters are the same as the ones documented by `hg help status`
|
||||
"""
|
||||
args = ["status", "--print0"]
|
||||
if include_ignored:
|
||||
args.append("-mardui")
|
||||
|
||||
output = self.hg(*args)
|
||||
status = {}
|
||||
for entry in output.split("\0"):
|
||||
if not entry:
|
||||
continue
|
||||
flag = entry[0]
|
||||
path = entry[2:]
|
||||
status[path] = flag
|
||||
|
||||
return status
|
||||
|
||||
def update(self, rev: str, clean: bool = False, merge: bool = False) -> None:
|
||||
args = ["update"]
|
||||
|
Loading…
Reference in New Issue
Block a user