Patchwork [V2] shelve: only save mq state if enabled

login
register
mail settings
Submitter Sean Farley
Date Oct. 9, 2013, 8:31 a.m.
Message ID <2ebe73c0c7ccda480367.1381307519@laptop.local>
Download mbox | patch
Permalink /patch/2738/
State Accepted
Commit 6cc696179869b7cafda6321221840f3f3d0e6748
Headers show

Comments

Sean Farley - Oct. 9, 2013, 8:31 a.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1381285744 -28800
#      Wed Oct 09 10:29:04 2013 +0800
# Node ID 2ebe73c0c7ccda4803674008f60bea094924503c
# Parent  7032dcff290ce49c9e2c0a78ddc003e1520cfcce
shelve: only save mq state if enabled

Test coverage has been added.
Matt Mackall - Oct. 9, 2013, 7:12 p.m.
On Wed, 2013-10-09 at 16:31 +0800, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1381285744 -28800
> #      Wed Oct 09 10:29:04 2013 +0800
> # Node ID 2ebe73c0c7ccda4803674008f60bea094924503c
> # Parent  7032dcff290ce49c9e2c0a78ddc003e1520cfcce
> shelve: only save mq state if enabled

Queued for default, thanks.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -154,15 +154,18 @@ 
 
     def commitfunc(ui, repo, message, match, opts):
         # check modified, added, removed, deleted only
         for flist in repo.status(match=match)[:4]:
             shelvedfiles.extend(flist)
-        saved, repo.mq.checkapplied = repo.mq.checkapplied, False
+        hasmq = util.safehasattr(repo, 'mq')
+        if hasmq:
+            saved, repo.mq.checkapplied = repo.mq.checkapplied, False
         try:
             return repo.commit(message, user, opts.get('date'), match)
         finally:
-            repo.mq.checkapplied = saved
+            if hasmq:
+                repo.mq.checkapplied = saved
 
     if parent.node() != nullid:
         desc = parent.description().split('\n', 1)[0]
     else:
         desc = '(empty repository)'
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -436,5 +436,20 @@ 
   adding file changes
   added 1 changesets with 1 changes to 7 files
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg bookmark
    * test                      5:01ba9745dc5a
+
+shelve should still work even if mq is disabled
+
+  $ hg --config extensions.mq=! shelve
+  shelved as default
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg --config extensions.mq=! shelve --list
+  default         (*)    create conflict (glob)
+  $ hg --config extensions.mq=! unshelve
+  unshelving change 'default'
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 7 files
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved