Patchwork [2,of,3] cmdserver: reload mq on each runcommand request to avoid corruption

login
register
mail settings
Submitter Yuya Nishihara
Date March 3, 2014, 12:50 p.m.
Message ID <30ea14789423bde5aef8.1393851041@gimlet>
Download mbox | patch
Permalink /patch/3834/
State Accepted
Commit e3d1df48fcc671602f2797f70dff92ae4d55cc43
Headers show

Comments

Yuya Nishihara - March 3, 2014, 12:50 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1393843286 -32400
#      Mon Mar 03 19:41:26 2014 +0900
# Node ID 30ea14789423bde5aef83a16118556b288a68e4a
# Parent  ca6451d4deaad5f657763df45dd9619f45a157eb
cmdserver: reload mq on each runcommand request to avoid corruption

If mq was changed by another process, command server should invalidate caches.
Otherwise, mq status would go wrong.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -3269,6 +3269,11 @@  def reposetup(ui, repo):
         def mq(self):
             return queue(self.ui, self.baseui, self.path)
 
+        def invalidateall(self):
+            super(mqrepo, self).invalidateall()
+            if localrepo.hasunfilteredcache(self, 'mq'):
+                self.mq.invalidate()
+
         def abortifwdirpatched(self, errmsg, force=False):
             if self.mq.applied and self.mq.checkapplied and not force:
                 parents = self.dirstate.parents()
diff --git a/tests/test-commandserver.py b/tests/test-commandserver.py
--- a/tests/test-commandserver.py
+++ b/tests/test-commandserver.py
@@ -280,6 +280,15 @@  def obsolete(server):
     runcommand(server, ['log', '--hidden'])
     runcommand(server, ['log'])
 
+def mqoutsidechanges(server):
+    readchannel(server)
+
+    # load repo.mq
+    runcommand(server, ['qapplied'])
+    os.system('hg qnew 0.diff')
+    # repo.mq should be invalidated
+    runcommand(server, ['qapplied'])
+
 if __name__ == '__main__':
     os.system('hg init')
 
@@ -310,3 +319,7 @@  if __name__ == '__main__':
     hgrc.write('[extensions]\nobs=obs.py\n')
     hgrc.close()
     check(obsolete)
+    hgrc = open('.hg/hgrc', 'a')
+    hgrc.write('[extensions]\nmq=\n')
+    hgrc.close()
+    check(mqoutsidechanges)
diff --git a/tests/test-commandserver.py.out b/tests/test-commandserver.py.out
--- a/tests/test-commandserver.py.out
+++ b/tests/test-commandserver.py.out
@@ -226,3 +226,9 @@  user:        test
 date:        Thu Jan 01 00:00:00 1970 +0000
 summary:     1
 
+
+testing mqoutsidechanges:
+
+ runcommand qapplied
+ runcommand qapplied
+0.diff