Skip to content

Commit af8ac9b

Browse files
quark-zjufacebook-github-bot
authored andcommitted
debugshell: make globals() match locals() in interactive shell
Summary: This fixes issues like ipython/ipython#62. Reviewed By: zzl0 Differential Revision: D44759311 fbshipit-source-id: 5ce94040cef09ac67962c147e86711971c545f91
1 parent 6076c34 commit af8ac9b

2 files changed

Lines changed: 26 additions & 10 deletions

File tree

‎eden/scm/edenscm/ext/debugshell.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,15 @@ def _startipython(ui, repo, env) -> None:
159159
config.InteractiveShell.banner2 = bannermsg
160160
config.InteractiveShell.confirm_exit = False
161161

162-
shell = InteractiveShellEmbed.instance(config=config)
163-
_configipython(ui, shell)
162+
if util.istest():
163+
# Disable history during tests.
164+
config.HistoryAccessor.enabled = False
164165

165-
locals().update(env)
166+
globals().update(env)
167+
shell = InteractiveShellEmbed.instance(
168+
config=config, user_ns=globals(), user_module=sys.modules[__name__]
169+
)
170+
_configipython(ui, shell)
166171
shell()
167172

168173

‎eden/scm/tests/test-debugshell-namespace.t‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,29 @@
33

44
$ eagerepo
55
$ cat >> foo.py << EOF
6-
> def f(x): return x + 1
7-
> ui.write('%r\n' % [f(i) for i in [1]])
6+
> def f1(x): return x + 1
7+
> ui.write('OUT: %r\n' % [f1(i) for i in [1]])
88
> EOF
99

1010
$ hg debugshell < foo.py
11-
[2]
11+
OUT: [2]
1212

1313
$ hg debugshell foo.py
14-
[2]
14+
OUT: [2]
1515

16-
$ hg debugshell -c 'def f(x):
16+
$ hg debugshell -c 'def f2(x):
1717
> return x+1
18-
> ui.write("%r\n" % [f(i) for i in [1]])
18+
> ui.write("OUT: %r\n" % [f2(i) for i in [1]])
1919
> '
20-
[2]
20+
OUT: [2]
21+
22+
$ hg debugshell --config ui.interactive=true << 'EOF' | dos2unix
23+
> def f3(x): return x + 1
24+
> ui.write('OUT: %r\n' % [f3(i) for i in [1]])
25+
> ui.flush()
26+
> exit()
27+
> EOF
28+
...
29+
In [1]:
30+
In [2]: OUT: [2]
31+
...

0 commit comments

Comments
 (0)