[PATCH 2 of 2] mq: qtop was broken when holes appear within the patch sequence

Brendan Cully brendan at kublai.com
Thu Apr 12 17:09:27 CDT 2007


On Thursday, 12 April 2007 at 22:48, Patrick Mezard wrote:
> # HG changeset patch
> # User Patrick Mezard <pmezard at gmail.com>
> # Date 1176410532 -7200
> # Node ID b785bf3b04d661f0ce5c67890cb870c46f673e08
> # Parent  a6ecb9d1ae8d0e697c9171706ccb004dc1027b61
> mq: qtop was broken when holes appear within the patch sequence.
> 
> diff -r a6ecb9d1ae8d -r b785bf3b04d6 hgext/mq.py
> --- a/hgext/mq.py	Thu Apr 12 22:41:50 2007 +0200
> +++ b/hgext/mq.py	Thu Apr 12 22:42:12 2007 +0200
> @@ -1588,7 +1588,9 @@ def top(ui, repo, **opts):
>      q = repo.mq
>      t = len(q.applied)
>      if t:
> -        return q.qseries(repo, start=t-1, length=1, status='A',
> +        applied = dict.fromkeys([p.name for p in q.applied])
> +        topmost = [i for i,p in enumerate(q.series) if p in applied][-1]
> +        return q.qseries(repo, start=topmost, length=1, status='A',
>                           summary=opts.get('summary'))
>      else:
>          ui.write("No patches applied\n")

I've applied the attached (simpler) patch instead.
-------------- next part --------------
# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1176414353 25200
# Node ID 7ae02bce8de27d0b3f8c3148bf443fa81426467d
# Parent  23068518deca2ceeee218c70633f7afb002fa75f
mq: fix qtop when some patches beneath are guarded

diff -r 23068518deca -r 7ae02bce8de2 hgext/mq.py
--- a/hgext/mq.py	Thu Apr 12 22:41:50 2007 +0200
+++ b/hgext/mq.py	Thu Apr 12 14:45:53 2007 -0700
@@ -1547,7 +1547,7 @@ def top(ui, repo, **opts):
 def top(ui, repo, **opts):
     """print the name of the current patch"""
     q = repo.mq
-    t = len(q.applied)
+    t = q.series_end()
     if t:
         return q.qseries(repo, start=t-1, length=1, status='A',
                          summary=opts.get('summary'))


More information about the Mercurial-devel mailing list