Patchwork [07,of,10] bundlerepo: store validated deltabase rev in basemap instead of node

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 16, 2013, 7:57 p.m.
Message ID <f58e4e7dc9819af9b076.1358366251@mk-desktop>
Download mbox | patch
Permalink /patch/667/
State Accepted
Commit 87f370c5fef5fca60fbefbfb4f093ef8baa52357
Headers show

Comments

Mads Kiilerich - Jan. 16, 2013, 7:57 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1358365301 -3600
# Node ID f58e4e7dc9819af9b0766fc98472435208bdc1b5
# Parent  d99799fc4f359b6f756c1a147523b1eaf3cc084f
bundlerepo: store validated deltabase rev in basemap instead of node

This avoids some lookups and aligns bundlerepo more with what revlog do.
tonfa - Jan. 16, 2013, 8:29 p.m.
Ok, I see you fixed PATCH 06 here.

LGTM, but please fix patch 06 and changed this patch accordingly.


On Wed, Jan 16, 2013 at 8:57 PM, Mads Kiilerich <mads@kiilerich.com> wrote:

> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1358365301 -3600
> # Node ID f58e4e7dc9819af9b0766fc98472435208bdc1b5
> # Parent  d99799fc4f359b6f756c1a147523b1eaf3cc084f
> bundlerepo: store validated deltabase rev in basemap instead of node
>
> This avoids some lookups and aligns bundlerepo more with what revlog do.
>
> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
> --- a/mercurial/bundlerepo.py
> +++ b/mercurial/bundlerepo.py
> @@ -31,7 +31,7 @@
>          opener = scmutil.readonlyvfs(opener)
>          revlog.revlog.__init__(self, opener, indexfile)
>          self.bundle = bundle
> -        self.basemap = {}
> +        self.basemap = {} # mapping rev to delta base rev
>          n = len(self)
>          chain = None
>          self.bundlerevs = set() # used by 'bundle()' revset expression
> @@ -60,10 +60,16 @@
>                  if p not in self.nodemap:
>                      raise error.LookupError(p, self.indexfile,
>                                              _("unknown parent"))
> +
> +            if deltabase not in self.nodemap:
> +                raise LookupError(deltabase, self.indexfile,
> +                                  _('unknown delta base'))
> +
> +            baserev = self.rev(deltabase)
>              # start, size, full unc. size, base (unused), link, p1, p2,
> node
>              e = (revlog.offset_type(start, 0), size, -1, -1, link,
>                   self.rev(p1), self.rev(p2), node)
> -            self.basemap[n] = deltabase
> +            self.basemap[n] = baserev
>              self.index.insert(-1, e)
>              self.nodemap[node] = n
>              self.bundlerevs.add(n)
> @@ -83,7 +89,7 @@
>          """return or calculate a delta between two revisions"""
>          if rev1 in self.basemap and rev2 in self.basemap:
>              # hot path for bundle
> -            revb = self.rev(self.basemap[rev2])
> +            revb = self.basemap[rev2]
>              if revb == rev1:
>                  return self._chunk(rev2)
>          elif rev1 not in self.basemap and rev2 not in self.basemap:
> @@ -115,7 +121,7 @@
>                  text = self._cache[2]
>                  break
>              chain.append(iterrev)
> -            iterrev = self.rev(self.basemap[rev])
> +            iterrev = self.basemap[iterrev]
>          if text is None:
>              text = revlog.revlog.revision(self, iterrev)
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -31,7 +31,7 @@ 
         opener = scmutil.readonlyvfs(opener)
         revlog.revlog.__init__(self, opener, indexfile)
         self.bundle = bundle
-        self.basemap = {}
+        self.basemap = {} # mapping rev to delta base rev
         n = len(self)
         chain = None
         self.bundlerevs = set() # used by 'bundle()' revset expression
@@ -60,10 +60,16 @@ 
                 if p not in self.nodemap:
                     raise error.LookupError(p, self.indexfile,
                                             _("unknown parent"))
+
+            if deltabase not in self.nodemap:
+                raise LookupError(deltabase, self.indexfile,
+                                  _('unknown delta base'))
+
+            baserev = self.rev(deltabase)
             # start, size, full unc. size, base (unused), link, p1, p2, node
             e = (revlog.offset_type(start, 0), size, -1, -1, link,
                  self.rev(p1), self.rev(p2), node)
-            self.basemap[n] = deltabase
+            self.basemap[n] = baserev
             self.index.insert(-1, e)
             self.nodemap[node] = n
             self.bundlerevs.add(n)
@@ -83,7 +89,7 @@ 
         """return or calculate a delta between two revisions"""
         if rev1 in self.basemap and rev2 in self.basemap:
             # hot path for bundle
-            revb = self.rev(self.basemap[rev2])
+            revb = self.basemap[rev2]
             if revb == rev1:
                 return self._chunk(rev2)
         elif rev1 not in self.basemap and rev2 not in self.basemap:
@@ -115,7 +121,7 @@ 
                 text = self._cache[2]
                 break
             chain.append(iterrev)
-            iterrev = self.rev(self.basemap[rev])
+            iterrev = self.basemap[iterrev]
         if text is None:
             text = revlog.revlog.revision(self, iterrev)