# HG changeset patch # User Nicolas Dumazet # Date 2009-12-11 06:09:52 # Node ID 46de82e50790517740448bcab0f893e3d961d6ab # Parent 27267b1f68b432de9aecd66f487bd9dd1c3f204c 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". diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1096,12 +1096,6 @@ class queue(object): 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 @@ class queue(object): 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) diff --git a/tests/test-mq b/tests/test-mq --- a/tests/test-mq +++ b/tests/test-mq @@ -561,3 +561,23 @@ echo % test popping revisions not in wor 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 .. diff --git a/tests/test-mq.out b/tests/test-mq.out --- a/tests/test-mq.out +++ b/tests/test-mq.out @@ -612,3 +612,6 @@ 0 A empty 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