[PATCH V2] mq: catch attempt to qpush to an earlier patch in the series (issue2587)

Gilles Moris gilles.moris at free.fr
Sat Feb 12 03:51:13 CST 2011


On Saturday 12 February 2011 09:10:57 am Afuna wrote:
> mq: catch attempt to qpush to an earlier patch in the series (issue2587)
>
> We can't assume that all pushable patches early in the series have already
> been applied. If a hg qselect is done while you already have patches
> applied, some patches with guards may now be pushable, even though they
> come earlier in the series.
>
> So instead of checking only applied patches, explicitly check where we are
> in the series against the position of the patch we want to qpush to.
>
> diff --git a/hgext/mq.py b/hgext/mq.py
> --- a/hgext/mq.py
> +++ b/hgext/mq.py
> @@ -1061,15 +1061,17 @@ class queue(object):
>              # go backwards with qpush)
>              if patch:
>                  info = self.isapplied(patch)
> -                if info:
> -                    if info[0] < len(self.applied) - 1:
> -                        raise util.Abort(
> -                            _("cannot push to a previous patch: %s") %
> patch) +                if info and info[0] >= len(self.applied) - 1:
>                      self.ui.warn(
>                          _('qpush: %s is already at the top\n') % patch)
>                      return 0
> +
>                  pushable, reason = self.pushable(patch)
> -                if not pushable:
> +                if pushable:
> +                    if self.series.index(patch) < self.series_end():
> +                        raise util.Abort(
> +                            _("cannot push to a previous patch: %s") %
> patch) +                else:
>                      if reason:
>                          reason = _('guarded by %r') % reason
>                      else:

Seems OK for me now.

Thanks.
Gilles.


More information about the Mercurial-devel mailing list