[Commented On] D10784: revlog: simplify "partial read" error message
baymax (Baymax, Your Personal Patch-care Companion)
phabricator at mercurial-scm.org
Wed Jun 2 03:11:51 UTC 2021
baymax added a comment.
baymax updated this revision to Diff 28394.
â
refresh by Heptapod after a successful CI run (ð ð)
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10784?vs=28297&id=28394
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10784/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D10784
AFFECTED FILES
mercurial/revlog.py
CHANGE DETAILS
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -256,6 +256,10 @@
# signed integer)
_maxentrysize = 0x7FFFFFFF
+PARTIAL_READ_MSG = _(
+ b'partial read of revlog %s; expected %d bytes from offset %d, got %d'
+)
+
class revlog(object):
"""
@@ -1709,34 +1713,17 @@
if offset != realoffset or reallength != length:
startoffset = offset - realoffset
if len(d) - startoffset < length:
- raise error.RevlogError(
- _(
- b'partial read of revlog %s; expected %d bytes from '
- b'offset %d, got %d'
- )
- % (
- self._indexfile if self._inline else self._datafile,
- length,
- offset,
- len(d) - startoffset,
- )
- )
-
+ filename = self._indexfile if self._inline else self._datafile
+ got = len(d) - startoffset
+ m = PARTIAL_READ_MSG % (filename, length, offset, got)
+ raise error.RevlogError(m)
return util.buffer(d, startoffset, length)
if len(d) < length:
- raise error.RevlogError(
- _(
- b'partial read of revlog %s; expected %d bytes from offset '
- b'%d, got %d'
- )
- % (
- self._indexfile if self._inline else self._datafile,
- length,
- offset,
- len(d),
- )
- )
+ filename = self._indexfile if self._inline else self._datafile
+ got = len(d) - startoffset
+ m = PARTIAL_READ_MSG % (filename, length, offset, got)
+ raise error.RevlogError(m)
return d
To: marmoute, indygreg, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210602/19afcff7/attachment-0001.html>
More information about the Mercurial-patches
mailing list