Patchwork D8975: genosxversion: don't give up if we can't find a path to hg libraries

login
register
mail settings
Submitter phabricator
Date Sept. 1, 2020, 2:34 p.m.
Message ID <differential-rev-PHID-DREV-brt5laldsldpylh4c2py-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47079/
State Superseded
Headers show

Comments

phabricator - Sept. 1, 2020, 2:34 p.m.
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This doesn't work if you have a PyOxidized hg on $PATH, but everything
  is fine if you just ignore that problem.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D8975

AFFECTED FILES
  contrib/genosxversion.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/contrib/genosxversion.py b/contrib/genosxversion.py
--- a/contrib/genosxversion.py
+++ b/contrib/genosxversion.py
@@ -6,9 +6,14 @@ 
 import subprocess
 import sys
 
-# Always load hg libraries from the hg we can find on $PATH.
-hglib = subprocess.check_output(['hg', 'debuginstall', '-T', '{hgmodules}'])
-sys.path.insert(0, os.path.dirname(hglib))
+try:
+    # Always load hg libraries from the hg we can find on $PATH.
+    hglib = subprocess.check_output(['hg', 'debuginstall', '-T', '{hgmodules}'])
+    sys.path.insert(0, os.path.dirname(hglib))
+except subprocess.CalledProcessError:
+    # We're probably running with a PyOxidized Mercurial, so just
+    # proceed and hope it works out okay.
+    pass
 
 from mercurial import util