Patchwork [1,of,2,V2] manifest: allow specifying the revlog filename

login
register
mail settings
Submitter via Mercurial-devel
Date March 1, 2017, 6:25 a.m.
Message ID <CAESOdVDgqXtY5LFGzM+qJNkPFiYzcbnieOyW0GHpT5dr_4eu+w@mail.gmail.com>
Download mbox | patch
Permalink /patch/18851/
State Deferred, archived
Headers show

Comments

via Mercurial-devel - March 1, 2017, 6:25 a.m.
On Tue, Feb 28, 2017 at 11:44 AM, Durham Goode <durham@fb.com> wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1488304382 28800
> #      Tue Feb 28 09:53:02 2017 -0800
> # Node ID 0a5e6ad0a25c348384bb6c14a51057b3587e2857
> # Parent  88203f26ea57627cabd7cf9c4f7843661d6c43ae
> manifest: allow specifying the revlog filename
>
> Previously we had hardcoded the manifest filename to be 00manifest.i. In our
> external treemanifest extension, we want to allow writing a treemanifest side by
> side with a flat manifest, so we need to be able to store the root revisions at
> a different location (in our extension we use 00manifesttree.i).
>
> This patches moves the revlog name to a parameter so we can adjust it.
>
> diff --git a/mercurial/manifest.py b/mercurial/manifest.py
> --- a/mercurial/manifest.py
> +++ b/mercurial/manifest.py
> @@ -1132,7 +1132,13 @@ class manifestrevlog(revlog.revlog):
>      '''A revlog that stores manifest texts. This is responsible for caching the
>      full-text manifest contents.
>      '''
> -    def __init__(self, opener, dir='', dirlogcache=None):
> +    def __init__(self, opener, dir='', dirlogcache=None,
> +                 indexfile='00manifest.i'):
> +        """Constructs a new manifest revlog
> +
> +        `indexfile` - used by extensions to have two manifests at once, like
> +        when transitioning between flatmanifeset and treemanifests.
> +        """
>          # During normal operations, we expect to deal with not more than four
>          # revs at a time (such as during commit --amend). When rebasing large
>          # stacks of commits, the number can go up, hence the config knob below.
> @@ -1150,12 +1156,11 @@ class manifestrevlog(revlog.revlog):
>
>          self._fulltextcache = util.lrucachedict(cachesize)
>
> -        indexfile = "00manifest.i"
>          if dir:
>              assert self._treeondisk, 'opts is %r' % opts
>              if not dir.endswith('/'):
>                  dir = dir + '/'
> -            indexfile = "meta/" + dir + "00manifest.i"
> +            indexfile = "meta/" + dir + indexfile
>          self._dir = dir
>          # The dirlogcache is kept on the root manifest log
>          if dir:

What I meant was for indexfile==None to be the default. I think it's
easier to follow if indexfile being set means that that's the exact
name to use. It also gives more flexibility to put the subdirectory
files in a different place. The patch would then look as follows. I
think that means your extension will pass None where it would pass
"00manifest.i" with your version above, so I assume it's similarly
simple. What do you think?

Patch

diff -r 0bb3089fe735 mercurial/manifest.py
--- a/mercurial/manifest.py     Sat Feb 25 14:09:55 2017 +0900
+++ b/mercurial/manifest.py     Tue Feb 28 22:17:28 2017 -0800
@@ -1132,7 +1132,12 @@  class manifestrevlog(revlog.revlog):
     '''A revlog that stores manifest texts. This is responsible for caching the
     full-text manifest contents.
     '''
-    def __init__(self, opener, dir='', dirlogcache=None):
+    def __init__(self, opener, dir='', dirlogcache=None, indexfile=None):
+        """Constructs a new manifest revlog
+
+        `indexfile` - used by extensions to have two manifests at once, like
+        when transitioning between flatmanifeset and treemanifests.
+        """
         # During normal operations, we expect to deal with not more than four
         # revs at a time (such as during commit --amend). When rebasing large
         # stacks of commits, the number can go up, hence the config knob below.
@@ -1150,12 +1155,15 @@  class manifestrevlog(revlog.revlog):

         self._fulltextcache = util.lrucachedict(cachesize)

-        indexfile = "00manifest.i"
         if dir:
             assert self._treeondisk, 'opts is %r' % opts
             if not dir.endswith('/'):
                 dir = dir + '/'
-            indexfile = "meta/" + dir + "00manifest.i"
+
+        if indexfile is None:
+            indexfile = "00manifest.i"
+            if dir:
+                indexfile = "meta/" + dir + "00manifest.i"
         self._dir = dir
         # The dirlogcache is kept on the root manifest log
         if dir: