Mercurial > hg
view contrib/mercurial.spec @ 32024:ad41739c6b2b
bundle2: ignore errors seeking a bundle after an exception (issue4784)
Many have seen a "stream ended unexpectedly" error. This message is
raised from changegroup.readexactly() when a read(n) operation fails
to return exactly N bytes.
I believe most occurrences of this error in the wild stem from
the code changed in this patch. Before, if bundle2's part applicator
raised an Exception when processing/applying parts, the exception
handler would attempt to iterate the remaining parts. If I/O
during this iteration failed, it would likely raise the
"stream ended unexpectedly" exception.
The problem with this approach is that if we already encountered
an I/O error iterating the bundle2 data during application, then
any further I/O would almost certainly fail. If the original stream
were closed, changegroup.readexactly() would obtain an empty
string, triggering "stream ended unexpectedly" with "got 0." This is
the error message that users would see. What's worse is that the
original I/O related exception would be lost since a new exception
would be raised. This made debugging the actual I/O failure
effectively impossible.
This patch changes the exception handler for bundle2 application to
ignore errors when seeking the underlying stream. When the underlying
error is I/O related, the seek should fail fast and the original
exception will be re-raised. The output changes in
test-http-bad-server.t demonstrate this.
When the underlying error is not I/O related and the stream can be
seeked, the old behavior is preserved.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 16 Apr 2017 11:55:08 -0700 |
parents | b927fe8bf0b9 |
children | feb910d2f59b |
line wrap: on
line source
%global emacs_lispdir %{_datadir}/emacs/site-lisp %define withpython %{nil} %if "%{?withpython}" %global pythonver %{withpython} %global pythonname Python-%{withpython} %global docutilsname docutils-0.12 %global docutilsmd5 4622263b62c5c771c03502afa3157768 %global pythonhg python-hg %global hgpyprefix /opt/%{pythonhg} # byte compilation will fail on some some Python /test/ files %global _python_bytecompile_errors_terminate_build 0 %else %global pythonver %(python -c 'import sys;print ".".join(map(str, sys.version_info[:2]))') %endif Summary: A fast, lightweight Source Control Management system Name: mercurial Version: snapshot Release: 0 License: GPLv2+ Group: Development/Tools URL: https://mercurial-scm.org/ Source0: %{name}-%{version}-%{release}.tar.gz %if "%{?withpython}" Source1: %{pythonname}.tgz Source2: %{docutilsname}.tar.gz %endif BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: make, gcc, gettext %if "%{?withpython}" BuildRequires: readline-devel, openssl-devel, ncurses-devel, zlib-devel, bzip2-devel %else BuildRequires: python >= 2.6, python-devel, python-docutils >= 0.5 Requires: python >= 2.6 %endif # The hgk extension uses the wish tcl interpreter, but we don't enforce it #Requires: tk %description Mercurial is a fast, lightweight source control management system designed for efficient handling of very large distributed projects. %prep %if "%{?withpython}" %setup -q -n mercurial-%{version}-%{release} -a1 -a2 # despite the comments in cgi.py, we do this to prevent rpmdeps from picking /usr/local/bin/python up sed -i '1c#! /usr/bin/env python' %{pythonname}/Lib/cgi.py %else %setup -q -n mercurial-%{version}-%{release} %endif %build %if "%{?withpython}" PYPATH=$PWD/%{pythonname} cd $PYPATH ./configure --prefix=%{hgpyprefix} make all %{?_smp_mflags} cd - cd %{docutilsname} LD_LIBRARY_PATH=$PYPATH $PYPATH/python setup.py build cd - # verify Python environment LD_LIBRARY_PATH=$PYPATH PYTHONPATH=$PWD/%{docutilsname} $PYPATH/python -c 'import sys, zlib, bz2, ssl, curses, readline' # set environment for make export PATH=$PYPATH:$PATH export LD_LIBRARY_PATH=$PYPATH export CFLAGS="-L $PYPATH" export PYTHONPATH=$PWD/%{docutilsname} %endif make all %install rm -rf $RPM_BUILD_ROOT %if "%{?withpython}" PYPATH=$PWD/%{pythonname} cd $PYPATH make install DESTDIR=$RPM_BUILD_ROOT # these .a are not necessary and they are readonly and strip fails - kill them! rm -f %{buildroot}%{hgpyprefix}/lib/{,python2.*/config}/libpython2.*.a cd - cd %{docutilsname} LD_LIBRARY_PATH=$PYPATH $PYPATH/python setup.py install --root="$RPM_BUILD_ROOT" cd - PATH=$PYPATH:$PATH LD_LIBRARY_PATH=$PYPATH make install DESTDIR=$RPM_BUILD_ROOT PREFIX=%{hgpyprefix} MANDIR=%{_mandir} mkdir -p $RPM_BUILD_ROOT%{_bindir} ( cd $RPM_BUILD_ROOT%{_bindir}/ && ln -s ../..%{hgpyprefix}/bin/hg . ) ( cd $RPM_BUILD_ROOT%{_bindir}/ && ln -s ../..%{hgpyprefix}/bin/python2.? %{pythonhg} ) %else make install DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} MANDIR=%{_mandir} %endif install -m 755 contrib/hgk $RPM_BUILD_ROOT%{_bindir}/ install -m 755 contrib/hg-ssh $RPM_BUILD_ROOT%{_bindir}/ bash_completion_dir=$RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d mkdir -p $bash_completion_dir install -m 644 contrib/bash_completion $bash_completion_dir/mercurial.sh zsh_completion_dir=$RPM_BUILD_ROOT%{_datadir}/zsh/site-functions mkdir -p $zsh_completion_dir install -m 644 contrib/zsh_completion $zsh_completion_dir/_mercurial mkdir -p $RPM_BUILD_ROOT%{emacs_lispdir} install -m 644 contrib/mercurial.el $RPM_BUILD_ROOT%{emacs_lispdir}/ install -m 644 contrib/mq.el $RPM_BUILD_ROOT%{emacs_lispdir}/ mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/mercurial/hgrc.d %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %doc CONTRIBUTORS COPYING doc/README doc/hg*.txt doc/hg*.html *.cgi contrib/*.fcgi %doc %attr(644,root,root) %{_mandir}/man?/hg* %doc %attr(644,root,root) contrib/*.svg %dir %{_datadir}/zsh/ %dir %{_datadir}/zsh/site-functions/ %{_datadir}/zsh/site-functions/_mercurial %dir %{_datadir}/emacs/site-lisp/ %{_datadir}/emacs/site-lisp/mercurial.el %{_datadir}/emacs/site-lisp/mq.el %{_bindir}/hg %{_bindir}/hgk %{_bindir}/hg-ssh %dir %{_sysconfdir}/bash_completion.d/ %config(noreplace) %{_sysconfdir}/bash_completion.d/mercurial.sh %dir %{_sysconfdir}/mercurial %dir %{_sysconfdir}/mercurial/hgrc.d %if "%{?withpython}" %{_bindir}/%{pythonhg} %{hgpyprefix} %else %if "%{?pythonver}" != "2.4" %{_libdir}/python%{pythonver}/site-packages/%{name}-*-py%{pythonver}.egg-info %endif %{_libdir}/python%{pythonver}/site-packages/%{name} %{_libdir}/python%{pythonver}/site-packages/hgext %{_libdir}/python%{pythonver}/site-packages/hgext3rd %endif