changeset 19885:6cc696179869

shelve: only save mq state if enabled Test coverage has been added.
author Sean Farley <sean.michael.farley@gmail.com>
date Wed, 09 Oct 2013 14:15:20 -0700
parents fc3fbca35085
children e828975722c8
files hgext/shelve.py tests/test-shelve.t
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/shelve.py	Mon Oct 07 11:45:01 2013 -0700
+++ b/hgext/shelve.py	Wed Oct 09 14:15:20 2013 -0700
@@ -156,11 +156,14 @@
         # 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]
--- a/tests/test-shelve.t	Mon Oct 07 11:45:01 2013 -0700
+++ b/tests/test-shelve.t	Wed Oct 09 14:15:20 2013 -0700
@@ -438,3 +438,18 @@
   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 test
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg --config extensions.mq=! shelve --list
+  test            (1s ago)    create conflict
+  $ hg --config extensions.mq=! unshelve
+  unshelving change 'test'
+  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