def __init__()

in libmozevent/mercurial.py [0:0]


    def __init__(self, config, cache_root):
        assert isinstance(config, dict)
        self.name = config["name"]
        self.url = config["url"]
        self.dir = os.path.join(cache_root, config["name"])
        self.checkout_mode = config.get("checkout", "batch")
        self.batch_size = config.get("batch_size", 10000)
        self.try_url = config["try_url"]
        self.try_mode = TryMode(config.get("try_mode", "json"))
        self.try_syntax = config.get("try_syntax")
        self.try_name = config.get("try_name", "try")
        self.default_revision = config.get("default_revision", "tip")

        # Apply patches to the latest revision when `True`.
        self.use_latest_revision = config.get("use_latest_revision", False)

        if self.try_mode == TryMode.syntax:
            assert self.try_syntax, "Missing try syntax"
        self._repo = None

        # Write ssh key from secret
        _, self.ssh_key_path = tempfile.mkstemp(suffix=".key")
        with open(self.ssh_key_path, "w") as f:
            f.write(config["ssh_key"])

        # Build ssh conf
        conf = {
            "StrictHostKeyChecking": "no",
            "User": config["ssh_user"],
            "IdentityFile": self.ssh_key_path,
        }
        self.ssh_conf = "ssh {}".format(
            " ".join('-o {}="{}"'.format(k, v) for k, v in conf.items())
        ).encode("utf-8")

        # Remove key when finished
        atexit.register(self.end_of_life)