sapling/eden/testlib/config.py
Durham Goode 44dc946468 backout: add test for maintain move info across a backout
Summary:
There's a bug here, so let's add a test exposing it. A future diff will
fix the bug and update the test.

Reviewed By: jordanwebster

Differential Revision: D37771384

fbshipit-source-id: f482cf6d07ba4f16d833b9337a61b9dd7a85d7ac
2022-07-13 14:17:40 -07:00

32 lines
858 B
Python

# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# pyre-strict
import os
from pathlib import Path
from .util import trace
class Config:
path: Path
def __init__(self, path: Path) -> None:
assert os.path.isabs(path), f"config path {path} is not absolute"
self.path = path
def add(self, section: str, key: str, value: str) -> None:
trace(f"set config: {section}.{key}={value}")
self.append(f"[{section}]\n{key}={value}")
def append(self, text: str) -> None:
with open(self.path, mode="a+") as f:
f.write("\n" + text + "\n")
def enable(self, extension: str) -> None:
trace(f"enable extension: {extension}")
self.add("extensions", extension, "")