[PATCH] pure parsers: properly detect corrupt index files

Augie Fackler durin42 at gmail.com
Tue May 24 14:01:25 CDT 2011


# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1306261810 18000
# Node ID 8455611a17c564b3881b8c4f60bd8d3e271d1475
# Parent  ede7cea1550f3745da21ebc462129f4d5046af8a
pure parsers: properly detect corrupt index files

This new Python code should be equivalent in behavior to the if
statement at line 312 of parsers.c. Without this, the pure-python
parsers improperly ignore truncated revlogs as created in
test-verify.t.

diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -56,6 +56,9 @@
             n += 1
             off += s
 
+    if off != len(data):
+        raise ValueError('corrupt index file')
+
     if index:
         e = list(index[0])
         type = gettype(e[0])


More information about the Mercurial-devel mailing list