# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 2005-07-08 21:21:22
# Node ID 94cdd02792b51f52d40a6786eb566e6d61794244
# Parent  a54a1c101a9a8670f0d0c12e2c3464cc038deac8

Fix corruption resulting from skipping parts of a revision group

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fix corruption resulting from skipping parts of a revision group

We were occassionally losing track of what revision a delta applied to
when we skipped over deltas we already had and applying the delta
against the wrong base. This could result in coredumps from mpatch,
consistency errors, or failed verify.

manifest hash: fcf20a8abfd81f08fae2398136b2ed66216b2083
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCzu5SywK+sNU5EO8RAi10AJ9cqIfQzOzbcdH36t1LR/rY+UMtHwCeM79p
Dtv+Jh0McLZr6nf4iJyhDgI=
=5o6U
-----END PGP SIGNATURE-----


diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -475,8 +475,8 @@ class revlog:
         t = r - 1
         node = nullid
 
-        base = prev = -1
-        start = end = 0
+        base = -1
+        start = end = measure = 0
         if r:
             start = self.start(self.base(t))
             end = self.end(t)
@@ -491,6 +491,7 @@ class revlog:
 
         # loop through our set of deltas
         chain = None
+        prev = self.tip()
         for chunk in revs:
             node, p1, p2, cs = struct.unpack("20s20s20s20s", chunk[:80])
             link = linkmapper(cs)
@@ -498,6 +499,7 @@ class revlog:
                 # this can happen if two branches make the same change
                 if unique:
                     raise "already have %s" % hex(node[:4])
+                chain = node
                 continue
             delta = chunk[80:]