Patchwork [3,of,3] cmdserver: recreate mq object on runcommand in case queue path was changed

login
register
mail settings
Submitter Yuya Nishihara
Date March 3, 2014, 12:50 p.m.
Message ID <de7a4b2066c05cb3f675.1393851042@gimlet>
Download mbox | patch
Permalink /patch/3835/
State Accepted
Commit 277dc5f27310f146f9b4dc14bb73c04630561d00
Headers show

Comments

Yuya Nishihara - March 3, 2014, 12:50 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1393843290 -32400
#      Mon Mar 03 19:41:30 2014 +0900
# Node ID de7a4b2066c05cb3f6758e76578c3cdc6d796f4f
# Parent  30ea14789423bde5aef83a16118556b288a68e4a
cmdserver: recreate mq object on runcommand in case queue path was changed

repo.mq needs to be recreated after queue path change.  Since there is little
benefit to keep invalidated mq object, it always delete repo.mq.
Matt Mackall - March 3, 2014, 6:31 p.m.
On Mon, 2014-03-03 at 21:50 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1393843290 -32400
> #      Mon Mar 03 19:41:30 2014 +0900
> # Node ID de7a4b2066c05cb3f6758e76578c3cdc6d796f4f
> # Parent  30ea14789423bde5aef83a16118556b288a68e4a
> cmdserver: recreate mq object on runcommand in case queue path was changed

Queued for default, thanks.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -3272,7 +3272,8 @@  def reposetup(ui, repo):
         def invalidateall(self):
             super(mqrepo, self).invalidateall()
             if localrepo.hasunfilteredcache(self, 'mq'):
-                self.mq.invalidate()
+                # recreate mq in case queue path was changed
+                delattr(self.unfiltered(), 'mq')
 
         def abortifwdirpatched(self, errmsg, force=False):
             if self.mq.applied and self.mq.checkapplied and not force:
diff --git a/tests/test-commandserver.py b/tests/test-commandserver.py
--- a/tests/test-commandserver.py
+++ b/tests/test-commandserver.py
@@ -289,6 +289,11 @@  def mqoutsidechanges(server):
     # repo.mq should be invalidated
     runcommand(server, ['qapplied'])
 
+    runcommand(server, ['qpop', '--all'])
+    os.system('hg qqueue --create foo')
+    # repo.mq should be recreated to point to new queue
+    runcommand(server, ['qqueue', '--active'])
+
 if __name__ == '__main__':
     os.system('hg init')
 
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
@@ -232,3 +232,8 @@  testing mqoutsidechanges:
  runcommand qapplied
  runcommand qapplied
 0.diff
+ runcommand qpop --all
+popping 0.diff
+patch queue now empty
+ runcommand qqueue --active
+foo