Patchwork [1,of,2] unionrepo: fill in uncompressed length of revlog entry

login
register
mail settings
Submitter Yuya Nishihara
Date May 26, 2018, 2:49 a.m.
Message ID <31143eaaf90624060f7b.1527302974@mimosa>
Download mbox | patch
Permalink /patch/31879/
State Accepted
Headers show

Comments

Yuya Nishihara - May 26, 2018, 2:49 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1527301911 -32400
#      Sat May 26 11:31:51 2018 +0900
# Node ID 31143eaaf90624060f7bd894421daafa5226605c
# Parent  2ce1e9bdc7157948fa799888009cc4c20c113d8c
unionrepo: fill in uncompressed length of revlog entry

It can be either -1 or a valid length, but shouldn't be None. IIUC, we can
simply trust the length retrieved from the revlog to be overlaid. I don't
bother thinking whether the compressed length can be copied as well. We'll
need to fix it later.
Gregory Szorc - May 31, 2018, 1:19 a.m.
On Fri, May 25, 2018 at 7:49 PM, Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1527301911 -32400
> #      Sat May 26 11:31:51 2018 +0900
> # Node ID 31143eaaf90624060f7bd894421daafa5226605c
> # Parent  2ce1e9bdc7157948fa799888009cc4c20c113d8c
> unionrepo: fill in uncompressed length of revlog entry
>

Queued, thanks.


>
> It can be either -1 or a valid length, but shouldn't be None. IIUC, we can
> simply trust the length retrieved from the revlog to be overlaid. I don't
> bother thinking whether the compressed length can be copied as well. We'll
> need to fix it later.
>
> diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
> --- a/mercurial/unionrepo.py
> +++ b/mercurial/unionrepo.py
> @@ -49,7 +49,7 @@ class unionrevlog(revlog.revlog):
>          for rev2 in self.revlog2:
>              rev = self.revlog2.index[rev2]
>              # rev numbers - in revlog2, very different from self.rev
> -            _start, _csize, _rsize, base, linkrev, p1rev, p2rev, node =
> rev
> +            _start, _csize, rsize, base, linkrev, p1rev, p2rev, node = rev
>              flags = _start & 0xFFFF
>
>              if linkmapper is None: # link is to same revlog
> @@ -69,7 +69,9 @@ class unionrevlog(revlog.revlog):
>              p1node = self.revlog2.node(p1rev)
>              p2node = self.revlog2.node(p2rev)
>
> -            e = (flags, None, None, base,
> +            # TODO: it's probably wrong to set compressed length to None,
> but
> +            # I have no idea if csize is valid in the base revlog context.
> +            e = (flags, None, rsize, base,
>                   link, self.rev(p1node), self.rev(p2node), node)
>              self.index.insert(-1, e)
>              self.nodemap[node] = n
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
--- a/mercurial/unionrepo.py
+++ b/mercurial/unionrepo.py
@@ -49,7 +49,7 @@  class unionrevlog(revlog.revlog):
         for rev2 in self.revlog2:
             rev = self.revlog2.index[rev2]
             # rev numbers - in revlog2, very different from self.rev
-            _start, _csize, _rsize, base, linkrev, p1rev, p2rev, node = rev
+            _start, _csize, rsize, base, linkrev, p1rev, p2rev, node = rev
             flags = _start & 0xFFFF
 
             if linkmapper is None: # link is to same revlog
@@ -69,7 +69,9 @@  class unionrevlog(revlog.revlog):
             p1node = self.revlog2.node(p1rev)
             p2node = self.revlog2.node(p2rev)
 
-            e = (flags, None, None, base,
+            # TODO: it's probably wrong to set compressed length to None, but
+            # I have no idea if csize is valid in the base revlog context.
+            e = (flags, None, rsize, base,
                  link, self.rev(p1node), self.rev(p2node), node)
             self.index.insert(-1, e)
             self.nodemap[node] = n