filemerge regression in 1.9
Adrian Buehlmann
adrian at cadifra.com
Wed Jul 6 03:14:29 CDT 2011
On 2011-07-06 06:12, Steve Borho wrote:
> On Tue, Jul 5, 2011 at 10:43 PM, Steve Borho <steve at borho.org> wrote:
>> Since Mercurial 1.9, TortoiseHg is no longer able launch external
>> merge tools from the resolve tool when our app is launched from the
>> shell extension. All we get is a meaningless error:
>>
>> % hg resolve --traceback -a
>> merging foo.c
>> abort: The handle is invalid
>>
>> Looking at the diffs, I'm fairly certain this was caused by
>> e3be7dc9a5e1, which passes sys.stdout to util.system as an output file
>> handle. When TortoiseHg is not launched from a command shell,
>> sys.stdout and sys.stderr are *not* valid file handles.
>>
>> I think to resolve this cleanly, ui.fout needs to be a
>> cStringIO.StringIO() or something similar when sys.stdout is not a
>> valid handle (ditto for sys.stderr). I'm curious how others feel
>> about this.
>
> I've validated that setting sys.stdout and sys.__stdout__ to point to
> a StringIO instance does make filemerge work again, but this doesn't
> seem like something TortoiseHg should need to do. We always give
> Mercurial a properly subclassed ui() instance that doesn't use stdout
> or stderr.
>
For reference purposes:
For those not familiar with the TortoiseHg sources and/or not following
TortoiseHg source code changes (which I guess are the majority here), this
is what Steve did in TortoiseHg:
https://bitbucket.org/tortoisehg/thg/changeset/88be472f12ff
# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1309929446 18000
# Branch stable
# Node ID 88be472f12ff804a5292a377bf45e0a6afc7e896
# Parent 9e2b4440fe62b6eefec2b4b34146f126c88873b9
thg: potential workaround for resolve tool bug (refs #891)
diff --git a/thg b/thg
--- a/thg
+++ b/thg
@@ -77,6 +77,9 @@
mystderr = cStringIO.StringIO()
origstderr = sys.stderr
sys.stderr = mystderr
+ sys.stdout = cStringIO.StringIO()
+ sys.__stdout__ = sys.stdout
+ sys.__stderr__ = sys.stderr
ret = 0
try:
ret = tortoisehg.hgqt.run.dispatch(sys.argv[1:])
"thg" is the front-end script for the TortoiseHg dialogs (launches all the
dialogs)
https://bitbucket.org/tortoisehg/thg/src/88be472f12ff/thg
Here is a reference to the related thread on the TortoiseHg developer
mailing list:
http://groups.google.com/group/thg-dev/browse_thread/thread/c51fe51f392e3cc5
And here is the TortoiseHg bug tracker entry:
https://bitbucket.org/tortoisehg/thg/issue/891
More information about the Mercurial-devel
mailing list