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

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Wed Sep 25 16:26:52 CDT 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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


More information about the Mercurial-devel mailing list