Skip to content

Commit 675de5a

Browse files
committed
Hook hgdemandimport to fix Mercurial in intercepted terminals
Without this, 'hg' fails with: ModuleNotFoundError: No module named 'http.cookiejar Not totally clear why, but it's fairly clearly an interaction between our funky import hooks and their funky import hooks. This module appears to be a startup time optimization, and it's certainly optional (there's an env var to disable it, and a built-in list of modules it doesn't support) so best to just no-op it's enable() function.
1 parent 96c5894 commit 675de5a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from httptoolkit_intercept import preload_real_module
2+
3+
preload_real_module('hgdemandimport')
4+
5+
import hgdemandimport
6+
7+
# Re-export all other public fields
8+
from hgdemandimport import *
9+
10+
# Disable hgdemandimport entirely. This is an optional optimization used by hg, which doesn't play
11+
# nicely with HTTP Toolkit's import hooks, making hg unusable.
12+
hgdemandimport.enable = lambda: None

0 commit comments

Comments
 (0)