diff unixSoft/bin/havepatch @ 436:97f12f43f73b

havepatch: always import hg libs from the hg we're using
author Augie Fackler <raf@durin42.com>
date Sun, 18 Jun 2017 22:45:40 -0400
parents d81eb79e4f4c
children
line wrap: on
line diff
--- a/unixSoft/bin/havepatch
+++ b/unixSoft/bin/havepatch
@@ -1,10 +1,16 @@
 #!/usr/bin/env python
 """Detect if a patch is already applied in a Mercurial repository."""
+import json
 import os
 import re
 import subprocess
 import sys
 
+# Always load hg libraries from the hg we can find on $PATH.
+hglib = json.loads(subprocess.check_output(
+    ['hg', 'debuginstall', '-Tjson']))[0]['hgmodules']
+sys.path.insert(0, os.path.dirname(hglib))
+
 from mercurial import util
 
 def main(argv):