Exemplo n.º 1
0
    def repair(self) -> None:
        # If the .hg directory was missing entirely check_for_error() won't have been
        # called yet.  Call it now to compute self._new_parents
        if self._new_parents is None:
            self.check_for_error()
        assert self._new_parents is not None

        if self._new_parents != self._old_dirstate_parents:
            with self.path.open("wb") as f:
                eden.dirstate.write(
                    f,
                    # pyre-fixme[6]: Expected `Tuple[bytes, bytes]` for 2nd param
                    #  but got `Optional[Tuple[bytes, bytes]]`.
                    self._new_parents,
                    # pyre-fixme[6]: Expected `Dict[str, Tuple[str, int, int]]` for
                    #  3rd param but got `Dict[bytes, Tuple[str, int, int]]`.
                    self._tuples_dict,
                    # pyre-fixme[6]: Expected `Dict[str, str]` for 4th param but got
                    #  `Dict[bytes, bytes]`.
                    self._copymap,
                )

        # pyre-fixme[16]: `Optional` has no attribute `__getitem__`.
        if self._new_parents[0] != self._old_snapshot:
            parents = eden_ttypes.WorkingDirectoryParents(
                parent1=self._new_parents[0])
            if self._new_parents[1] != self._null_commit_id:
                parents.parent2 = self._new_parents[1]
            params = eden_ttypes.ResetParentCommitsParams()
            with self.checkout.instance.get_thrift_client_legacy() as client:
                client.resetParentCommits(bytes(self.checkout.path), parents,
                                          params)
Exemplo n.º 2
0
    def setHgParents(self, p1, p2, need_flush=True, p1manifest=None):
        if p2 == node.nullid:
            p2 = None

        if need_flush:
            self._flushPendingTransactions()

        parents = eden_ttypes.WorkingDirectoryParents(parent1=p1, parent2=p2)
        params = eden_ttypes.ResetParentCommitsParams(hgRootManifest=p1manifest)
        with self._get_client() as client:
            client.resetParentCommits(self._eden_root, parents, params)