Skip to content

Commit

Permalink
Allow no Mercurial installed
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Dec 18, 2024
1 parent 34abd63 commit 934a1ee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: |
python .github/debug_which_hg.py
- if: runner.os != 'Windows'
name: Mercurial installation
name: Check Mercurial installation
run: |
hg version -v
hg debuginstall
Expand Down
3 changes: 0 additions & 3 deletions src/hg_setup/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
"""hg-setup package"""

import os
import sys

from pathlib import Path

import rich_click as click

from .init_cmd import init_tui, init_auto
Expand Down
34 changes: 22 additions & 12 deletions src/hg_setup/hgrcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

from pathlib import Path

from textwrap import dedent
from shutil import which

import rich_click as click


name_default = ".hgrc" if os.name != "nt" else "mercurial.ini"

Expand All @@ -32,18 +33,27 @@ def check_hg_conf_file():
class HgrcCodeMaker:
def __init__(self):
# get pythonexe to be able to check installation of
process = subprocess.run(
["hg", "debuginstall", "-T", "{pythonexe}"],
capture_output=True,
# cannot use check=True
check=False,
text=True,
)
pythonexe = process.stdout
if not Path(pythonexe).exists():
raise ValueError(str(process))
try:
process = subprocess.run(
["hg", "debuginstall", "-T", "{pythonexe}"],
capture_output=True,
# cannot use check=True
check=False,
text=True,
)
except FileNotFoundError:
click.secho("hg not found", fg="red")
hg_error = True
else:
hg_error = False
pythonexe = process.stdout
if not Path(pythonexe).exists():
raise ValueError(str(process))

if pythonexe.endswith("hg.exe"):
hg_error = True

if pythonexe.endswith("hg.exe"):
if hg_error:
# this can happen on Windows!
self.enable_hggit = self.enable_topic = True
else:
Expand Down

0 comments on commit 934a1ee

Please sign in to comment.