Patchwork [9,of,9,standalone-strip] mq: have the strip command functionnal on repo without mq

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 25, 2013, 9:26 p.m.
Message ID <72982741c525e1d0b060.1380144412@vulgaris>
Download mbox | patch
Permalink /patch/2638/
State Accepted
Commit 8cf0e2c329013d71608a095c70e7487510638041
Headers show

Comments

Pierre-Yves David - Sept. 25, 2013, 9:26 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1380111411 -7200
#      Wed Sep 25 14:16:51 2013 +0200
# Node ID 72982741c525e1d0b06096bc7eafc780a4f2274f
# Parent  80275daf409fb1712ee1448b3d74e9f005dc369d
mq: have the strip command functionnal on repo without mq

This is the last step before being able to extract `strip` in its own extension.
The changes are made in mq to allow a move only extraction without touching a
line of code.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -3040,12 +3040,12 @@  def stripcmd(ui, repo, *revs, **opts):
             update = True
             break
 
     rootnodes = set(cl.node(r) for r in roots)
 
-    q = repo.mq
-    if q.applied:
+    q = getattr(repo, 'mq', None)
+    if q is not None and q.applied:
         # refresh queue state if we're about to strip
         # applied patches
         if cl.rev(repo.lookup('qtip')) in strippedrevs:
             q.applieddirty = True
             start = 0
@@ -3062,11 +3062,12 @@  def stripcmd(ui, repo, *revs, **opts):
     revs = sorted(rootnodes)
     if update and opts.get('keep'):
         wlock = repo.wlock()
         try:
             urev, p2 = repo.changelog.parents(revs[0])
-            if p2 != nullid and p2 in [x.node for x in repo.mq.applied]:
+            if (util.safehasattr(repo, 'mq') and p2 != nullid
+                and p2 in [x.node for x in repo.mq.applied]):
                 urev = p2
             uctx = repo[urev]
 
             # only reset the dirstate for files that would actually change
             # between the working context and uctx