changeset 25459:0bda5bfaf0b1

revlog: move size limit check to addrevision This lets us add the name of the indexfile to the message.
author Matt Mackall <mpm@selenic.com>
date Thu, 04 Jun 2015 14:57:58 -0500
parents 4642f0b803ae
children 6fabde6ef445
files mercurial/revlog.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Wed May 20 11:55:59 2015 -0500
+++ b/mercurial/revlog.py	Thu Jun 04 14:57:58 2015 -0500
@@ -167,12 +167,6 @@
         return index, getattr(index, 'nodemap', None), cache
 
     def packentry(self, entry, node, version, rev):
-        uncompressedlength = entry[2]
-        if uncompressedlength > _maxentrysize:
-            raise RevlogError(
-                _("size of %d bytes exceeds maximum revlog storage of 2GiB")
-                % uncompressedlength)
-
         p = _pack(indexformatng, *entry)
         if rev == 0:
             p = _pack(versionformat, version) + p[4:]
@@ -1190,6 +1184,12 @@
         if link == nullrev:
             raise RevlogError(_("attempted to add linkrev -1 to %s")
                               % self.indexfile)
+
+        if len(text) > _maxentrysize:
+            raise RevlogError(
+                _("%s: size of %d bytes exceeds maximum revlog storage of 2GiB")
+                % (self.indexfile, len(text)))
+
         node = node or self.hash(text, p1, p2)
         if node in self.nodemap:
             return node