mq: make qrefresh/qfold keep wlock until saving patch status
authorYuya Nishihara <yuya@tcha.org>
Wed, 15 Jun 2011 01:50:49 +0900
changeset 14620 2b9c32929e62
parent 14619 29f55c0e39e7
child 14621 84094c0d2724
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.
hgext/mq.py
--- 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'))],