revlog: deal with chunk ranges over 2G on Windows (issue4215) stable
authorMatt Mackall <mpm@selenic.com>
Mon, 07 Apr 2014 14:18:10 -0500
branchstable
changeset 20957 469d949a7cb8
parent 20938 e9725e18bdf8
child 20965 774ff56cbe34
child 21028 a0f437e2f5a9
revlog: deal with chunk ranges over 2G on Windows (issue4215) Python uses a C long (32 bits on Windows 64) rather than an ssize_t in read(), and thus has a 2G size limit. Work around this by falling back to reading one chunk at a time on overflow. This approximately doubles our headroom until we run back into the size limit on single reads.
mercurial/revlog.py
--- a/mercurial/revlog.py	Thu Apr 03 20:35:56 2014 -0500
+++ b/mercurial/revlog.py	Mon Apr 07 14:18:10 2014 -0500
@@ -909,8 +909,13 @@
         ladd = l.append
 
         # preload the cache
-        self._chunkraw(revs[0], revs[-1])
-        offset, data = self._chunkcache
+        try:
+            self._chunkraw(revs[0], revs[-1])
+            offset, data = self._chunkcache
+        except OverflowError:
+            # issue4215 - we can't cache a run of chunks greater than
+            # 2G on Windows
+            return [self._chunk(rev) for rev in revs]
 
         for rev in revs:
             chunkstart = start(rev)