Patchwork [1,of,3] localrepo: add hook point to invalidate everything on each command-server run

login
register
mail settings
Submitter Yuya Nishihara
Date March 3, 2014, 12:50 p.m.
Message ID <ca6451d4deaad5f65776.1393851040@gimlet>
Download mbox | patch
Permalink /patch/3833/
State Accepted
Commit a42ea6d209e6ea777c9f0c2a8407ec943c0c6cb8
Headers show

Comments

Yuya Nishihara - March 3, 2014, 12:50 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1393843283 -32400
#      Mon Mar 03 19:41:23 2014 +0900
# Node ID ca6451d4deaad5f657763df45dd9619f45a157eb
# Parent  e9b1daa0dd45da91343b1466792b875d24543e09
localrepo: add hook point to invalidate everything on each command-server run

MQ extension will wrap this function to invalidate its state.

repo.invalidate cannot be wrapped for this purpose because qpush obtains
repo.lock in the middle of the operation, triggering repo.invalidate.  Also,
it seems wrong to obtain lock earlier because mq data is non-store parts.

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -188,8 +188,7 @@  class server(object):
         repoui = self.repoui.__class__(self.repoui)
         repoui.copy = copiedui.copy # redo copy protection
         self.repo.ui = self.repo.dirstate._ui = repoui
-        self.repo.invalidate()
-        self.repo.invalidatedirstate()
+        self.repo.invalidateall()
 
         req = dispatch.request(args[:], copiedui, self.repo, self.cin,
                                self.cout, self.cerr)
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -993,6 +993,13 @@  class localrepository(object):
                 pass
         self.invalidatecaches()
 
+    def invalidateall(self):
+        '''Fully invalidates both store and non-store parts, causing the
+        subsequent operation to reread any outside changes.'''
+        # extension should hook this to invalidate its caches
+        self.invalidate()
+        self.invalidatedirstate()
+
     def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc):
         try:
             l = lockmod.lock(vfs, lockname, 0, releasefn, desc=desc)