[PATCH] lazyindex: handle __delitem__ in loadblock

Brendan Cully brendan at kublai.com
Sat Feb 3 21:56:26 UTC 2007


While working on overlay repositories, I noticed that lazyindex's
loadblock may attempt to load index entries that have been
deleted. Since lazyindex supports __delitem__, I think loadblock needs
something like the attached patch.

Any objections?
-------------- next part --------------
# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1170539614 28800
# Node ID 35742f35fb0c415357e00d100106fee48e3805ef
# Parent  82eb0fafb56d5767af52ed60cd272311675b547f
lazyindex: handle __delitem__ in loadblock

diff -r 82eb0fafb56d -r 35742f35fb0c mercurial/revlog.py
--- a/mercurial/revlog.py	Tue Jan 30 21:11:10 2007 -0200
+++ b/mercurial/revlog.py	Sat Feb 03 13:53:34 2007 -0800
@@ -146,6 +146,9 @@ class lazyparser(object):
         lend = len(data) / self.s
         i = blockstart / self.s
         off = 0
+        # lazyindex supports __delitem__
+        if lend > len(self.index) - i:
+            lend = len(self.index) - i
         for x in xrange(lend):
             if self.index[i + x] == None:
                 b = data[off : off + self.s]


More information about the Mercurial-devel mailing list