[PATCH 07 of 11] revlog: fix many file handle opens to explicitly use bytes mode

Augie Fackler raf at durin42.com
Mon Mar 27 10:09:03 EDT 2017


On Mon, Mar 27, 2017 at 10:54:08PM +0900, Yuya Nishihara wrote:
> On Sun, 26 Mar 2017 18:36:41 -0400, Augie Fackler wrote:
> > # HG changeset patch
> > # User Augie Fackler <raf at durin42.com>
> > # Date 1490567324 14400
> > #      Sun Mar 26 18:28:44 2017 -0400
> > # Node ID e7fe3ab60132647a9c3b86b2960b385e61b9dcf0
> > # Parent  48144fe2d912b7d9fc300955d0c881aceead6930
> > revlog: fix many file handle opens to explicitly use bytes mode
> >
> > This broke on Python 3, but we've probably been getting lucky that
> > this hasn't caused EOL corruption on Windows or something for
> > years. :(
> >
> > diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> > --- a/mercurial/revlog.py
> > +++ b/mercurial/revlog.py
> > @@ -1467,8 +1467,8 @@ class revlog(object):
> >
> >          dfh = None
> >          if not self._inline:
> > -            dfh = self.opener(self.datafile, "a+")
> > -        ifh = self.opener(self.indexfile, "a+", checkambig=self._checkambig)
> > +            dfh = self.opener(self.datafile, "a+b")
> > +        ifh = self.opener(self.indexfile, "a+b", checkambig=self._checkambig)
>
> 'b' shouldn't be needed since vfs adds 'b' unless text=True is explicitly
> specified.

Huh. I swear this fixed some problems for me. I'll keep it around in
reserve in case the problem crops up again.


More information about the Mercurial-devel mailing list