changeset 32305:ccef71de7d41

caches: introduce a 'debugupdatecaches' 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.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 02 May 2017 21:35:06 +0200
parents a72caf0af38e
children 2b6692df1bdf
files mercurial/debugcommands.py tests/test-completion.t tests/test-debugcommands.t tests/test-help.t
diffstat 4 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Tue May 02 19:05:58 2017 +0200
+++ b/mercurial/debugcommands.py	Tue May 02 21:35:06 2017 +0200
@@ -2130,6 +2130,13 @@
             displayer.show(repo[r], **props)
         displayer.close()
 
+@command('debugupdatecaches', [])
+def debugupdatecaches(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')),
--- a/tests/test-completion.t	Tue May 02 19:05:58 2017 +0200
+++ b/tests/test-completion.t	Tue May 02 21:35:06 2017 +0200
@@ -111,6 +111,7 @@
   debugsub
   debugsuccessorssets
   debugtemplate
+  debugupdatecaches
   debugupgraderepo
   debugwalk
   debugwireargs
@@ -285,6 +286,7 @@
   debugsub: rev
   debugsuccessorssets: 
   debugtemplate: rev, define
+  debugupdatecaches: 
   debugupgraderepo: optimize, run
   debugwalk: include, exclude
   debugwireargs: three, four, five, ssh, remotecmd, insecure
--- a/tests/test-debugcommands.t	Tue May 02 19:05:58 2017 +0200
+++ b/tests/test-debugcommands.t	Tue May 02 21:35:06 2017 +0200
@@ -109,6 +109,16 @@
       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
--- a/tests/test-help.t	Tue May 02 19:05:58 2017 +0200
+++ b/tests/test-help.t	Tue May 02 21:35:06 2017 +0200
@@ -931,6 +931,8 @@
                  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