[Updated] D10784: revlog: simplify "partial read" error message

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Mon Jun 7 09:23:16 UTC 2021


Closed by commit rHG0d0fb091c49f: revlog: simplify "partial read" error message (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10784?vs=28443&id=28487

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/20210607/aaeffada/attachment-0001.html>


More information about the Mercurial-patches mailing list