Commit 5d57dfba authored by Laurent Peuch's avatar Laurent Peuch
Browse files

init

parents
#!/usr/bin/env python3
import argh
from pathlib import Path
from urllib.parse import urlparse
from configparser import ConfigParser
from argh.decorators import named
def _grab_current_project_hgrc():
path = Path(".")
while path != Path("/"):
if (path / ".hg/hgrc").exists():
return path / ".hg/hgrc"
path = path.parent
raise Exception()
def _grab_current_project():
path = _grab_current_project_hgrc()
config = ConfigParser()
config.read(path)
url = config["paths"]["default"]
# this handle both ssh://git@forge.extranet.logilab.fr/group/project
# and https://forge.extranet.logilab.fr/group/project patterns
url = urlparse(config["paths"]["default"])
url = f"https://{url.hostname}"
@named("list")
def mr_list():
print(_grab_current_project_hgrc())
parser = argh.ArghParser()
argh.add_commands(parser, [mr_list], namespace="mr")
if __name__ == '__main__':
parser.dispatch()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment