https://bz.mercurial-scm.org/show_bug.cgi?id=5807

            Bug ID: 5807
           Summary: Convert throws "ValueError: I/O operation on closed
                    file"
           Product: Mercurial
           Version: 4.2
          Hardware: PC
                OS: Linux
            Status: UNCONFIRMED
          Severity: bug
          Priority: wish
         Component: convert
          Assignee: bugzi...@mercurial-scm.org
          Reporter: neme...@wienfluss.net
                CC: duri...@gmail.com, mercurial-devel@mercurial-scm.org

= Background =

Due to a recent system upgrade on one of our machines (openSuSE 42.2 -> 42.3),
mercurial was updated from 3.8.3 to 4.2.3. After that, our script to fetch,
update and convert a remote SVN repo into our local HG mirror throws the
following error:

> ** Unknown exception encountered with possibly-broken third-party extension 
> prompt
> ** which supports versions unknown of Mercurial.
> ** Please disable prompt and try your action again.
> ** If that fixes the bug please report it to the extension author.
> ** Python 2.7.13 (default, Jan 03 2017, 17:41:54) [GCC]
> ** Mercurial Distributed SCM (version 4.2.3)
> ** Extensions loaded: convert, extdiff, churn, prompt
> Traceback (most recent call last):
>   File "/usr/bin/hg", line 45, in <module>
>     mercurial.dispatch.run()
>   File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 83, 
> in run
>     status = (dispatch(req) or 0) & 255
>   File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 178, 
> in dispatch
>     req.ui.flush()
>   File "/usr/lib64/python2.7/site-packages/mercurial/ui.py", line 823, in 
> flush
>     self.fout.flush()
> ValueError: I/O operation on closed file


= Findings =

1. Disabling the prompt extension did not improve the situation (same error
persists).

2. We tested with the following versions:
   - 3.8.3-2.11.1: worked prior upgrade
   - 4.2-1.2:      throws error shown above
   - 4.2.3-7.1:    throws error shown above
   - 4.5-202.2:    throws error shown above

3. Error suggests that the targeted file or buffer is closed prematurely. Even
when inserting a python debug before the self.fout.flush() statement, the error
is triggered.

4. After investigating the code, I think the problem stems from changeset
30261:6bed17ba00a1 (see
https://www.mercurial-scm.org/repo/hg/rev/6bed17ba00a1). It replaced sys.stdin
/ sys.stdout with ui.fin / ui.fout. But it did not take into consideration,
that the buffer automatically is closed in "get_log_child()".


= Proposed change =

In "get_log_child()", I would simply replace the fp.close() with fp.flush().
This will ensure that the buffer is still available.

I'll submit a patch to mercurial-devel@mercurial-scm.org soonish.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to