mq: have the strip command functionnal on repo without mq
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Wed, 25 Sep 2013 14:16:51 +0200
changeset 19820 8cf0e2c32901
parent 19819 f0fc4d5797e1
child 19821 baab785e3ecf
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.
hgext/mq.py
--- a/hgext/mq.py	Wed Sep 25 14:07:37 2013 +0200
+++ b/hgext/mq.py	Wed Sep 25 14:16:51 2013 +0200
@@ -3042,8 +3042,8 @@
 
     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:
@@ -3064,7 +3064,8 @@
         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]