shelve: only save mq state if enabled
authorSean Farley <sean.michael.farley@gmail.com>
Wed, 09 Oct 2013 14:15:20 -0700
changeset 19885 6cc696179869
parent 19884 fc3fbca35085
child 19886 e828975722c8
shelve: only save mq state if enabled Test coverage has been added.
hgext/shelve.py
tests/test-shelve.t
--- 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