Last active
August 10, 2016 12:25
-
-
Save junkycoder/f5ef22621269b6cf39875ff1a61ece9f to your computer and use it in GitHub Desktop.
Make mercurial_keyring work on OS X with homebrew mercurial 2.7.2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#brew install python | |
#brew install mercurial | |
#/usr/local/bin/pip install mercurial_keyring | |
# patch from http://selenic.com/repo/hg/rev/e3a5922e18c3 | |
cat <<-EOF | patch -p2 /usr/local/Cellar/mercurial/3.8.4/lib/python2.7/site-packages/mercurial/demandimport.py | |
diff -r 8bbe208c1812 -r e3a5922e18c3 mercurial/demandimport.py | |
--- a/mercurial/demandimport.py Sat Oct 05 01:02:22 2013 +0900 | |
+++ b/mercurial/demandimport.py Sat Oct 05 01:02:22 2013 +0900 | |
@@ -40,22 +40,23 @@ | |
class _demandmod(object): | |
"""module demand-loader and proxy""" | |
- def __init__(self, name, globals, locals): | |
+ def __init__(self, name, globals, locals, level=-1): | |
if '.' in name: | |
head, rest = name.split('.', 1) | |
after = [rest] | |
else: | |
head = name | |
after = [] | |
- object.__setattr__(self, "_data", (head, globals, locals, after)) | |
+ object.__setattr__(self, "_data", | |
+ (head, globals, locals, after, level)) | |
object.__setattr__(self, "_module", None) | |
def _extend(self, name): | |
"""add to the list of submodules to load""" | |
self._data[3].append(name) | |
def _load(self): | |
if not self._module: | |
- head, globals, locals, after = self._data | |
- mod = _origimport(head, globals, locals) | |
+ head, globals, locals, after, level = self._data | |
+ mod = _import(head, globals, locals, None, level) | |
# load submodules | |
def subload(mod, p): | |
h, t = p, None | |
@@ -105,7 +106,7 @@ | |
if isinstance(locals[base], _demandmod): | |
locals[base]._extend(rest) | |
return locals[base] | |
- return _demandmod(name, globals, locals) | |
+ return _demandmod(name, globals, locals, level) | |
else: | |
if level != -1: | |
# from . import b,c,d or from .a import b,c,d | |
EOF | |
# Make homebrew mercurial use homebrew python | |
sed -i -e 's|/usr/bin/python|/usr/local/bin/python|' /usr/local/Cellar/mercurial/2.7.2/bin/hg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment