changeset 14620:2b9c32929e62

mq: make qrefresh/qfold keep wlock until saving patch status Because q.refresh() changes nodeid, .hg/patches/status gets invalid until q.savedirty(). This patch changes mq not to unlock repository of incomplete state.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 15 Jun 2011 01:50:49 +0900
parents 29f55c0e39e7
children 84094c0d2724
files hgext/mq.py
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Tue Jun 14 20:08:35 2011 -0300
+++ b/hgext/mq.py	Wed Jun 15 01:50:49 2011 +0900
@@ -2275,9 +2275,13 @@
         # We don't want to lose the patch message if qrefresh fails (issue2062)
         repo.savecommitmessage(message)
     setupheaderopts(ui, opts)
-    ret = q.refresh(repo, pats, msg=message, **opts)
-    q.savedirty()
-    return ret
+    wlock = repo.wlock()
+    try:
+        ret = q.refresh(repo, pats, msg=message, **opts)
+        q.savedirty()
+        return ret
+    finally:
+        wlock.release()
 
 @command("^qdiff",
          commands.diffopts + commands.diffopts2 + commands.walkopts,
@@ -2366,9 +2370,13 @@
         message = ui.edit(message, user or ui.username())
 
     diffopts = q.patchopts(q.diffopts(), *patches)
-    q.refresh(repo, msg=message, git=diffopts.git)
-    q.delete(repo, patches, opts)
-    q.savedirty()
+    wlock = repo.wlock()
+    try:
+        q.refresh(repo, msg=message, git=diffopts.git)
+        q.delete(repo, patches, opts)
+        q.savedirty()
+    finally:
+        wlock.release()
 
 @command("qgoto",
          [('f', 'force', None, _('overwrite any local changes'))],