[PATCH 2 of 2] mq: qtop was broken when holes appear within the patch sequence
Brendan Cully
brendan at kublai.com
Sun May 6 20:32:59 UTC 2007
On Sunday, 06 May 2007 at 19:24, Patrick Mézard wrote:
> Brendan Cully a écrit :
>> 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.
>
> It still breaks when the series ends with guarded patches. A test case and
> fix are attached. What happens is q.series_end() returns the end of the full
> series because there are no more pushable patches, then q.qseries() start
> iterating on the last guarded patch and ignores it.
ok, your patches look fine to me.
> # HG changeset patch
> # User Patrick Mezard <pmezard at gmail.com>
> # Date 1178471967 -7200
> # Node ID 36e458cc0b904d4e6b24106fccdc1069b179c203
> # Parent 71a41efd1f580aa93b603d672dd72d998a55f5fc
> mq: fix qtop failure when the series ends with guarded patches.
>
> diff -r 71a41efd1f58 -r 36e458cc0b90 hgext/mq.py
> --- a/hgext/mq.py Sun May 06 18:19:25 2007 +0200
> +++ b/hgext/mq.py Sun May 06 19:19:27 2007 +0200
> @@ -1303,6 +1303,10 @@ class queue:
> return 0
>
> def series_end(self, all_patches=False):
> + """If all_patches is False, return the index of the next pushable patch
> + in the series, or the series length. If all_patches is True, return the
> + index of the first patch past the last applied one.
> + """
> end = 0
> def next(start):
> if all_patches:
> @@ -1589,7 +1593,7 @@ def top(ui, repo, **opts):
> def top(ui, repo, **opts):
> """print the name of the current patch"""
> q = repo.mq
> - t = q.series_end()
> + t = len(q.applied) > 0 and q.series_end(True) or 0
> if t:
> return q.qseries(repo, start=t-1, length=1, status='A',
> summary=opts.get('summary'))
it might be more pythonic to write 'q.applied and...' instead of
'len(q.applied) > 0 and...'
More information about the Mercurial-devel
mailing list