changeset 10048:46de82e50790 stable

mq: qpop: remove added files before re-adding removed files We need to do this to avoid file/directories conflicts. This causes patches removing a committed file and replacing it with a directory to be "unpoppable".
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Fri, 11 Dec 2009 15:09:52 +0900
parents 27267b1f68b4
children 5b9709f81986 a02d43acbc04
files hgext/mq.py tests/test-mq tests/test-mq.out
diffstat 3 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Thu Dec 10 09:35:43 2009 -0500
+++ b/hgext/mq.py	Fri Dec 11 15:09:52 2009 +0900
@@ -1096,12 +1096,6 @@
                 m, a, r, d = repo.status(qp, top)[:4]
                 if d:
                     raise util.Abort(_("deletions found between repo revs"))
-                for f in m:
-                    getfile(f, mmap[f], mmap.flags(f))
-                for f in r:
-                    getfile(f, mmap[f], mmap.flags(f))
-                for f in m + r:
-                    repo.dirstate.normal(f)
                 for f in a:
                     try:
                         os.unlink(repo.wjoin(f))
@@ -1111,6 +1105,12 @@
                     try: os.removedirs(os.path.dirname(repo.wjoin(f)))
                     except: pass
                     repo.dirstate.forget(f)
+                for f in m:
+                    getfile(f, mmap[f], mmap.flags(f))
+                for f in r:
+                    getfile(f, mmap[f], mmap.flags(f))
+                for f in m + r:
+                    repo.dirstate.normal(f)
                 repo.dirstate.setparents(qp, nullid)
             for patch in reversed(self.applied[start:end]):
                 self.ui.status(_("popping %s\n") % patch.name)
--- a/tests/test-mq	Thu Dec 10 09:35:43 2009 -0500
+++ b/tests/test-mq	Fri Dec 11 15:09:52 2009 +0900
@@ -561,3 +561,23 @@
 hg qseries -v
 hg up qparent
 hg qpop
+
+cd ..
+hg init deletion-order
+cd deletion-order
+
+touch a
+hg ci -Aqm0
+
+hg qnew rename-dir
+hg rm a
+hg qrefresh
+
+mkdir a b
+touch a/a b/b
+hg add -q a b
+hg qrefresh
+
+echo % test popping must remove files added in subdirectories first
+hg qpop
+cd ..
--- a/tests/test-mq.out	Thu Dec 10 09:35:43 2009 -0500
+++ b/tests/test-mq.out	Fri Dec 11 15:09:52 2009 +0900
@@ -612,3 +612,6 @@
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 popping empty
 patch queue now empty
+% test popping must remove files added in subdirectories first
+popping rename-dir
+patch queue now empty