Patchwork shelve: only save mq state if enabled

login
register
mail settings
Submitter Sean Farley
Date Oct. 5, 2013, 12:46 p.m.
Message ID <cce5cf72140d65e3943d.1380977176@laptop.local>
Download mbox | patch
Permalink /patch/2735/
State Superseded
Commit 6cc696179869b7cafda6321221840f3f3d0e6748
Headers show

Comments

Sean Farley - Oct. 5, 2013, 12:46 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1380977034 -28800
#      Sat Oct 05 20:43:54 2013 +0800
# Node ID cce5cf72140d65e3943d2450a68051afd5babed4
# Parent  a69a77a80900eabe1257c935818d0910217e9702
shelve: only save mq state if enabled

A little bit hacky but I wanted to keep mq out of my hgrc.
Augie Fackler - Oct. 7, 2013, 9:13 p.m.
On Sat, Oct 05, 2013 at 08:46:16PM +0800, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1380977034 -28800
> #      Sat Oct 05 20:43:54 2013 +0800
> # Node ID cce5cf72140d65e3943d2450a68051afd5babed4
> # Parent  a69a77a80900eabe1257c935818d0910217e9702
> shelve: only save mq state if enabled
>
> A little bit hacky but I wanted to keep mq out of my hgrc.

Can you add a test that verifies shelve works when mq is disabled? --config extensions.mq=! should help there.

>
> 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)'
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Sean Farley - Oct. 9, 2013, 8:32 a.m.
On Tue, Oct 8, 2013 at 5:13 AM, Augie Fackler <raf@durin42.com> wrote:
> On Sat, Oct 05, 2013 at 08:46:16PM +0800, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1380977034 -28800
>> #      Sat Oct 05 20:43:54 2013 +0800
>> # Node ID cce5cf72140d65e3943d2450a68051afd5babed4
>> # Parent  a69a77a80900eabe1257c935818d0910217e9702
>> shelve: only save mq state if enabled
>>
>> A little bit hacky but I wanted to keep mq out of my hgrc.
>
> Can you add a test that verifies shelve works when mq is disabled? --config extensions.mq=! should help there.

Ok, resent V2 just now.

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)'