Patchwork [5,of,8] caches: introduce a 'debugwarmcaches' command

login
register
mail settings
Submitter Pierre-Yves David
Date May 2, 2017, 11:43 p.m.
Message ID <7f3e26f6d05f0d651706.1493768622@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20362/
State Accepted
Headers show

Comments

Pierre-Yves David - May 2, 2017, 11:43 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1493753706 -7200
#      Tue May 02 21:35:06 2017 +0200
# Branch stable
# Node ID 7f3e26f6d05f0d65170616d77c38fd064911718f
# Parent  a3dc2747c4e0eea11d6fce071d444e93bcde50c3
# EXP-Topic obscache
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 7f3e26f6d05f
caches: introduce a 'debugwarmcaches' command

That command make sure caches are updated. This is based on
'localrepo.updatecaches' so when we move support for new cache in that function this
command will benefit from it.
Yuya Nishihara - May 3, 2017, 7:52 a.m.
On Wed, 03 May 2017 01:43:42 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1493753706 -7200
> #      Tue May 02 21:35:06 2017 +0200
> # Branch stable
> # Node ID 7f3e26f6d05f0d65170616d77c38fd064911718f
> # Parent  a3dc2747c4e0eea11d6fce071d444e93bcde50c3
> # EXP-Topic obscache
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 7f3e26f6d05f
> caches: introduce a 'debugwarmcaches' command
> 
> That command make sure caches are updated. This is based on
> 'localrepo.updatecaches' so when we move support for new cache in that function this
> command will benefit from it.
> 
> diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
> --- a/mercurial/debugcommands.py
> +++ b/mercurial/debugcommands.py
> @@ -2050,6 +2050,13 @@ def debugtemplate(ui, repo, tmpl, **opts
>              displayer.show(repo[r], **props)
>          displayer.close()
>  
> +@command('debugupdatecaches', [])
> +def debugwalk(ui, repo, *pats, **opts):
       ^^^^^^^^^

Nit. could be fixed in flight.

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2050,6 +2050,13 @@  def debugtemplate(ui, repo, tmpl, **opts
             displayer.show(repo[r], **props)
         displayer.close()
 
+@command('debugupdatecaches', [])
+def debugwalk(ui, repo, *pats, **opts):
+    """warm all known caches in the repository"""
+    with repo.wlock():
+        with repo.lock():
+            repo.updatecaches()
+
 @command('debugupgraderepo', [
     ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
     ('', 'run', False, _('performs an upgrade')),
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -110,6 +110,7 @@  Show debug commands if there are no othe
   debugsub
   debugsuccessorssets
   debugtemplate
+  debugupdatecaches
   debugupgraderepo
   debugwalk
   debugwireargs
@@ -283,6 +284,7 @@  Show all commands + options
   debugsub: rev
   debugsuccessorssets: 
   debugtemplate: rev, define
+  debugupdatecaches: 
   debugupgraderepo: optimize, run
   debugwalk: include, exclude
   debugwireargs: three, four, five, ssh, remotecmd, insecure
diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t
--- a/tests/test-debugcommands.t
+++ b/tests/test-debugcommands.t
@@ -109,6 +109,16 @@  Test max chain len
       6     5    -1   ???   ???        ???  ???  ???    0     ???      ????           ?     1        1 (glob)
       7     6    -1   ???   ???        ???  ???  ???    0     ???      ????           ?     1        2 (glob)
       8     7    -1   ???   ???        ???  ???  ???    0     ???      ????           ?     1        3 (glob)
+
+Test cache warming command
+
+  $ rm -rf .hg/cache/
+  $ hg debugupdatecaches --debug
+  $ ls -r .hg/cache/*
+  .hg/cache/rbc-revs-v1
+  .hg/cache/rbc-names-v1
+  .hg/cache/branch2-served
+
   $ cd ..
 
 Test internal debugstacktrace command
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -929,6 +929,8 @@  Test list of internal help commands
                  show set of successors for revision
    debugtemplate
                  parse and apply a template
+   debugupdatecaches
+                 warm all known caches in the repository
    debugupgraderepo
                  upgrade a repository to use different features
    debugwalk     show how files match on given patterns