[PATCH 2 of 2 STABLE] mq: make qprev return the previous applied patch (issue3245)
Patrick Mezard
pmezard at gmail.com
Fri Feb 3 18:49:15 UTC 2012
# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1328294829 -3600
# Branch stable
# Node ID 7e5a281a082cdbff4ae9553e01b5ff36dc2c11ee
# Parent c36db39b3fee5dbdea15d92ad5d62657524ea447
mq: make qprev return the previous applied patch (issue3245)
The current behaviour is to return the previous one in the series but at the
same time the implementation is buggy because it does not take guarded patches
in account.
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -2217,7 +2217,7 @@
@command("qprev", seriesopts, _('hg qprev [-s]'))
def prev(ui, repo, **opts):
- """print the name of the previous patch
+ """print the name of the previous applied patch
Returns 0 on success."""
q = repo.mq
@@ -2228,7 +2228,8 @@
if not l:
ui.write(_("no patches applied\n"))
return 1
- q.qseries(repo, start=l - 2, length=1, status='A',
+ idx = q.series.index(q.applied[-2].name)
+ q.qseries(repo, start=idx, length=1, status='A',
summary=opts.get('summary'))
def setupheaderopts(ui, opts):
diff --git a/tests/test-mq-guards.t b/tests/test-mq-guards.t
--- a/tests/test-mq-guards.t
+++ b/tests/test-mq-guards.t
@@ -172,6 +172,8 @@
$ hg qpush -a
applying c.patch
now at: c.patch
+ $ hg qprev
+ b.patch
Used to be an issue with holes in the patch sequence
So, put one hole on the base and ask for topmost patch.
diff --git a/tests/test-mq.t b/tests/test-mq.t
--- a/tests/test-mq.t
+++ b/tests/test-mq.t
@@ -74,7 +74,7 @@
qnew create a new patch
qnext print the name of the next pushable patch
qpop pop the current patch off the stack
- qprev print the name of the previous patch
+ qprev print the name of the previous applied patch
qpush push the next patch onto the stack
qqueue manage multiple patch queues
qrefresh update the current patch
More information about the Mercurial-devel
mailing list