Patchwork revlog: converting from inline to non-inline works after a strip

login
register
mail settings
Submitter adgar@google.com
Date March 25, 2015, 7:59 p.m.
Message ID <a34e493f59fb430c1945.1427313587@adgar.nyc.corp.google.com>
Download mbox | patch
Permalink /patch/8266/
State Accepted
Headers show

Comments

adgar@google.com - March 25, 2015, 7:59 p.m.
# HG changeset patch
# User Mike Edgar <adgar@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.
Matt Mackall - March 25, 2015, 8:55 p.m.
On Wed, 2015-03-25 at 15:59 -0400, Mike Edgar wrote:
> # HG changeset patch
> # User Mike Edgar <adgar@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

This style of summary is confusing since it's just describing a state
rather than a change. I'm guessing you mean:

revlog: make converting from inline to non-line work after a strip

..yes?

In general, without looking at the code, I'm confused about whether the
rest of your description refers to the before state or the after state
or even both, since it uses words like "currently":

> 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)
>  
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

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)