[ANNOUNCE] hg "shell" extension
Shun-ichi GOTO
shunichi.goto at gmail.com
Tue Feb 5 20:46:43 CST 2008
2008/2/6, Mark Williamson <mark.williamson at cl.cam.ac.uk>:
> > > My current development code has much better context-sensitive
> > > intelligence, things are coming along nice and quickly.
> >
> > It would definitely be a boon to be able to embed an hg-shell into
> > TortoiseHg. Any chance you could get it to work with this package?
> >
> > http://newcenturycomputers.net/projects/readline.html
>
> I'd taken a look at that package already... It sounded like the sort of thing
> one would want. Unfortunately I don't currently have a Windows system to
> test on so I can't comment on whether it would work in practice.
I've tried with pyreadline which is a part of IPython:
http://ipython.scipy.org/moin/
http://ipython.scipy.org/dist/
I need following patch to play with it because mercurial replaces
sys.stdout for mercurial.util.winstdout.
# I don't know this is right way to go...
------------------
diff -r 282eb46a6503 hgext/shell.py
--- a/hgext/shell.py Wed Feb 06 11:28:48 2008 +0900
+++ b/hgext/shell.py Wed Feb 06 11:30:38 2008 +0900
@@ -5,8 +5,8 @@
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
-import readline, shlex
-from mercurial import dispatch, commands, cmdutil
+import sys, readline, shlex
+from mercurial import dispatch, commands, cmdutil, util
from itertools import ifilter, chain, islice
'''
@@ -90,6 +90,8 @@
def shell(ui, repo, *extras, **opts):
'''Run an interactive hg shell interface.'''
+ if isinstance(sys.stdout, util.winstdout):
+ sys.stdout = sys.stdout.fp
globals()['hg_ui'] = ui
try:
while True:
----------------------------
By this patch, completion works.
But there's a problem of filename completion which uses os.sep ('\')
and shell extension passes such filenames to mercurial commands as-is.
As result, command not work correctly.
We need to replace os.sep char to '/' (using util.normpath()) before execution.
--
Shun-ichi GOTO
More information about the Mercurial
mailing list