[PATCH] revlog: converting from inline to non-inline works after a strip

Mike Edgar adgar at google.com
Wed Mar 25 19:59:47 UTC 2015


# HG changeset patch
# User Mike Edgar <adgar at google.com>
# Date 1427313511 14400
#      Wed Mar 25 15:58:31 2015 -0400
# Node ID a34e493f59fb430c1945f40212299fd7e9836297
# Parent  fe41722ee8e5a92447bb8a79f9b234fdfb098d05
revlog: converting from inline to non-inline works after a strip

The checkinlinesize function, which converts inline revlogs to non-inline,
uses the current transaction's contents to determine how to update the
transaction after the conversion. The transaction's "data" field for the
revlog file is used; for revlogs "data" typically contains the first new
revnum added in the transaction.

Conversion currently fails if the transaction begins by stripping the inline
revlog, as the strip operation does not have a new revnum to include as
transaction data. In lieu of this revnum, the revlog conversion code can use
the post-strip size of the revlog when updating the transaction.

This change should not impact recoverability because strip already produces
backup bundles to recover the data that transactions can't recover.

diff -r fe41722ee8e5 -r a34e493f59fb mercurial/revlog.py
--- a/mercurial/revlog.py	Tue Mar 24 12:52:53 2015 -0700
+++ b/mercurial/revlog.py	Wed Mar 25 15:58:31 2015 -0400
@@ -1126,7 +1126,12 @@
                               % self.indexfile)
 
         trindex = trinfo[2]
-        dataoff = self.start(trindex)
+        if trindex is not None:
+            dataoff = self.start(trindex)
+        else:
+            # revlog was stripped at start of transaction, use all leftover data
+            trindex = len(self) - 1
+            dataoff = self.end(-2)
 
         tr.add(self.datafile, dataoff)
 


More information about the Mercurial-devel mailing list