diff hgext/mq.py @ 6635:d90d83ebea9e

mq: don't update the working copy on strip if parents aren't stripped * * *
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Tue, 03 Jun 2008 12:10:14 +0200
parents d6caebe9c293
children 8c01ce1f2530 2519976a998b
line wrap: on
line diff
--- a/hgext/mq.py	Tue Jun 03 09:31:36 2008 +0200
+++ b/hgext/mq.py	Tue Jun 03 12:10:14 2008 +0200
@@ -2060,14 +2060,28 @@
     return 0
 
 def strip(ui, repo, rev, **opts):
-    """strip a revision and all later revs on the same branch"""
-    rev = repo.lookup(rev)
+    """strip a revision and all its descendants from the repository
+
+    If one of the working dir's parent revisions is stripped, the working
+    directory will be updated to the parent of the stripped revision.
+    """
     backup = 'all'
     if opts['backup']:
         backup = 'strip'
     elif opts['nobackup']:
         backup = 'none'
-    update = repo.dirstate.parents()[0] != revlog.nullid
+
+    rev = repo.lookup(rev)
+    p = repo.dirstate.parents()
+    cl = repo.changelog
+    update = True
+    if p[0] == revlog.nullid:
+        update = False
+    elif p[1] == revlog.nullid and rev != cl.ancestor(p[0], rev):
+        update = False
+    elif rev not in (cl.ancestor(p[0], rev), cl.ancestor(p[1], rev)):
+        update = False
+
     repo.mq.strip(repo, rev, backup=backup, update=update)
     return 0