# HG changeset patch # User Vishakh H # Date 1279638449 -19800 # Node ID 64f284da1278968bbe04f1a42ec47b35f38eae86 # Parent c10eaf1210cde64dd2690952d442eff25577495a 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. diff -r c10eaf1210cd -r 64f284da1278 hgext/mq.py --- 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 diff -r c10eaf1210cd -r 64f284da1278 tests/test-mq-strip --- a/tests/test-mq-strip Tue Jul 20 18:29:00 2010 +0900 +++ b/tests/test-mq-strip Tue Jul 20 20:37:29 2010 +0530 @@ -53,3 +53,19 @@ hg strip 4 2>&1 | hidebackup echo % after strip of merge parent hg parents + +#strip of applied mq should cleanup status file +hg up -C 3 +echo fooagain >> bar +hg ci -mf +hg qimport -r tip:2 +echo % applied patches before strip +hg qapplied +echo % stripping revision in queue +hg strip 3 | hidebackup +echo % applied patches after stripping rev in queue +hg qapplied +echo % stripping ancestor of queue +hg strip 1 | hidebackup +echo % applied patches after stripping ancestor of queue +hg qapplied diff -r c10eaf1210cd -r 64f284da1278 tests/test-mq-strip.out --- a/tests/test-mq-strip.out Tue Jul 20 18:29:00 2010 +0900 +++ b/tests/test-mq-strip.out Tue Jul 20 20:37:29 2010 +0530 @@ -165,3 +165,17 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: b +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +% applied patches before strip +2.diff +3.diff +4.diff +% stripping revision in queue +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +saved backup bundle to +% applied patches after stripping rev in queue +2.diff +% stripping ancestor of queue +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +saved backup bundle to +% applied patches after stripping ancestor of queue diff -r c10eaf1210cd -r 64f284da1278 tests/test-mq.out --- a/tests/test-mq.out Tue Jul 20 18:29:00 2010 +0900 +++ b/tests/test-mq.out Tue Jul 20 20:37:29 2010 +0530 @@ -400,15 +400,13 @@ popping bar now at: foo changeset: 0:cb9a9f314b8b -mq status file refers to unknown node tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: a -mq status file refers to unknown node default 0:cb9a9f314b8b -abort: trying to pop unknown node +no patches applied new file diff --git a/new b/new