mq: qpop: remove added files before re-adding removed files stable
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Fri, 11 Dec 2009 15:09:52 +0900
branchstable
changeset 10048 46de82e50790
parent 10047 27267b1f68b4
child 10049 5b9709f81986
child 10051 a02d43acbc04
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".
hgext/mq.py
tests/test-mq
tests/test-mq.out
--- 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