def test_status_with_non_parent(self) -> None: # This confirms that an error is thrown if getScmStatusV2 is called # with a commit that is not the parent commit initial_commit_hex = self.repo.get_head_hash() initial_commit = binascii.unhexlify(initial_commit_hex) config = """\ ["hg"] enforce-parents = false """ edenrc = os.path.join(self.home_dir, ".edenrc") with self.get_thrift_client() as client: # Add file to commit self.touch("new_tracked.txt") self.hg("add", "new_tracked.txt") # Commit the modifications self.repo.commit("committing changes") # Test calling getScmStatusV2() with a commit that is not the parent commit with self.assertRaises(EdenError) as context: client.getScmStatusV2( GetScmStatusParams( mountPoint=bytes(self.mount, encoding="utf-8"), commit=initial_commit, listIgnored=False, ) ) self.assertEqual( EdenErrorType.OUT_OF_DATE_PARENT, context.exception.errorType ) with open(edenrc, "w") as f: f.write(config) # Makes sure that EdenFS picks up our updated config, # since we wrote it out after EdenFS started. client.reloadConfig() try: client.getScmStatusV2( GetScmStatusParams( mountPoint=bytes(self.mount, encoding="utf-8"), commit=initial_commit, listIgnored=False, ) ) except EdenError as ex: self.fail( "getScmStatusV2 threw after setting enforce-parents to false with {}".format( ex ) )
def _eden_status(self, listIgnored: bool = False): with self.eden.get_thrift_client() as client: status = client.getScmStatusV2( GetScmStatusParams( mountPoint=self.mount.encode(), commit=self.initial_commit.encode(), listIgnored=listIgnored, ) ) return status.status.entries
def checkout_in_progress() -> Optional[bool]: try: client.getScmStatusV2( GetScmStatusParams( mountPoint=bytes(self.mount, encoding="utf-8"), commit=bytes(hg_parent, encoding="utf-8"), listIgnored=False, )) except EdenError as ex: if ex.errorType == EdenErrorType.CHECKOUT_IN_PROGRESS: return True else: raise ex return None
def thoroughly_get_scm_status(self, client, mountPoint, commit, listIgnored, expected_status) -> None: status_from_get_scm_status = client.getScmStatus( mountPoint=bytes(mountPoint, encoding="utf-8"), commit=commit, listIgnored=False, ) status_from_get_scm_status_v2 = client.getScmStatusV2( GetScmStatusParams( mountPoint=bytes(mountPoint, encoding="utf-8"), commit=commit, listIgnored=False, )).status self.assertEqual( status_from_get_scm_status, status_from_get_scm_status_v2, "getScmStatus and getScmStatusV2 should agree", )