diff hgext/mq.py @ 11637:64f284da1278 stable

mq: cleanup status if applied mq is stripped (issue1881) stripping of applied mq patches leads to wrong state recorded in status file. find all mq patches that will be affected and clean up status file before strip.
author Vishakh H <vsh426@gmail.com>
date Tue, 20 Jul 2010 20:37:29 +0530
parents 134eb1c97e94
children c4f6f0a1bd5a 3e561b6af810
line wrap: on
line diff
--- a/hgext/mq.py	Tue Jul 20 18:29:00 2010 +0900
+++ b/hgext/mq.py	Tue Jul 20 20:37:29 2010 +0530
@@ -2418,6 +2418,18 @@
     elif rev not in (cl.ancestor(p[0], rev), cl.ancestor(p[1], rev)):
         update = False
 
+    q = repo.mq
+    if q.applied:
+        if rev == cl.ancestor(repo.lookup('qtip'), rev):
+            q.applied_dirty = True
+            start = 0
+            end = len(q.applied)
+            applied_list = [i.node for i in q.applied]
+            if rev in applied_list:
+                start = applied_list.index(rev)
+            del q.applied[start:end]
+            q.save_dirty()
+
     repo.mq.strip(repo, rev, backup=backup, update=update, force=opts['force'])
     return 0