[PATCH] mq: add -d/--delete option to qpop that deletes after popping
Idan Kamara
idankk86 at gmail.com
Thu Jun 2 16:17:46 UTC 2011
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1307031405 -10800
# Node ID 970d8d9b69004d550ec5e33f529de118033047ab
# Parent 30506b89435921bf2e7622613044cca2acab4196
mq: add -d/--delete option to qpop that deletes after popping
diff -r 30506b894359 -r 970d8d9b6900 hgext/mq.py
--- a/hgext/mq.py Wed Jun 01 19:12:18 2011 -0500
+++ b/hgext/mq.py Thu Jun 02 19:16:45 2011 +0300
@@ -1220,7 +1220,8 @@
finally:
wlock.release()
- def pop(self, repo, patch=None, force=False, update=True, all=False):
+ def pop(self, repo, patch=None, force=False, update=True, all=False,
+ delete=False):
wlock = repo.wlock()
try:
if patch:
@@ -1307,10 +1308,20 @@
repo.wwrite(f, fctx.data(), fctx.flags())
repo.dirstate.normal(f)
repo.dirstate.setparents(qp, nullid)
+
+ if delete:
+ msg = "popping and deleting"
+ else:
+ msg = "popping"
+
+ patchnames = []
for patch in reversed(self.applied[start:end]):
- self.ui.status(_("popping %s\n") % patch.name)
+ self.ui.status(_("%s %s\n") % (msg, patch.name))
+ patchnames.append(patch.name)
del self.applied[start:end]
self.strip(repo, [rev], update=False, backup='strip')
+ if delete:
+ self._cleanup(patchnames, 0)
if self.applied:
self.ui.write(_("now at: %s\n") % self.applied[-1].name)
else:
@@ -2543,8 +2554,9 @@
[('a', 'all', None, _('pop all patches')),
('n', 'name', '',
_('queue name to pop (DEPRECATED)'), _('NAME')),
+ ('d', 'delete', False, _('delete patch after popping')),
('f', 'force', None, _('forget any local changes to patched files'))],
- _('hg qpop [-a] [-f] [PATCH | INDEX]'))
+ _('hg qpop [-a] [-d] [-f] [PATCH | INDEX]'))
def pop(ui, repo, patch=None, **opts):
"""pop the current patch off the stack
@@ -2562,7 +2574,7 @@
else:
q = repo.mq
ret = q.pop(repo, patch, force=opts.get('force'), update=localupdate,
- all=opts.get('all'))
+ all=opts.get('all'), delete=opts.get('delete'))
q.save_dirty()
return ret
diff -r 30506b894359 -r 970d8d9b6900 tests/test-mq.t
--- a/tests/test-mq.t Wed Jun 01 19:12:18 2011 -0500
+++ b/tests/test-mq.t Thu Jun 02 19:16:45 2011 +0300
@@ -449,14 +449,59 @@
applying test2.patch
now at: test2.patch
+test qpop --delete
-qpush --move
+ $ hg qnew test3.patch
+ $ hg qpop -d
+ popping and deleting test3.patch
+ now at: test2.patch
+ $ hg qnext
+ all patches applied
+ [1]
+
+popping with -d doesn't keep the patch file
+
+ $ hg qimport -e test3.patch
+ abort: patch test3.patch does not exist
+ [255]
+popd -d when popping more than one patch
$ hg qpop -a
popping test2.patch
popping test1b.patch
popping test.patch
patch queue now empty
+ $ hg qnew one
+ $ hg qnew two
+ $ hg qpop -d -a
+ popping and deleting two
+ popping and deleting one
+ patch queue now empty
+ $ hg qseries
+ test.patch
+ test1b.patch
+ test2.patch
+ $ hg qnew one
+ $ hg qnew two
+ $ hg qpop -d 1
+ qpop: two is already at the top
+ $ hg qpop two
+ qpop: two is already at the top
+ $ hg qtop
+ two
+ $ hg qpop -d 0
+ popping and deleting two
+ now at: one
+ $ hg qpop -d
+ popping and deleting one
+ patch queue now empty
+ $ hg qseries
+ test.patch
+ test1b.patch
+ test2.patch
+
+qpush --move
+
$ hg qguard test1b.patch -- -negguard
$ hg qguard test2.patch -- +posguard
$ hg qpush --move test2.patch # can't move guarded patch
More information about the Mercurial-devel
mailing list