revlog: move size limit check to addrevision
authorMatt Mackall <mpm@selenic.com>
Thu, 04 Jun 2015 14:57:58 -0500
changeset 25459 0bda5bfaf0b1
parent 25458 4642f0b803ae
child 25461 6fabde6ef445
revlog: move size limit check to addrevision This lets us add the name of the indexfile to the message.
mercurial/revlog.py
--- 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