[PATCH stable]mq: fix traceback when qpush inexistant-patch with no patch applied

Dirkjan Ochtman dirkjan at ochtman.nl
Tue Oct 6 06:59:07 CDT 2009


2009/10/6 Benoît Allard <benoit at aeteurope.nl>:
> # HG changeset patch
> # User Benoit Allard <benoit at aeteurope.nl>
> # Date 1254530194 -7200
> # Node ID 577a230a7e354523047be21657777d3bc46ff95d
> # Parent  53a95a74481248a92ea4faf10c302d1e948b7968
> mq: fix traceback for qpush inexistant-patch with no patch applied
>
> diff -r 53a95a744812 -r 577a230a7e35 hgext/mq.py
> --- a/hgext/mq.py       Sun Oct 04 23:16:54 2009 +0200
> +++ b/hgext/mq.py       Sat Oct 03 02:36:34 2009 +0200
> @@ -997,12 +997,13 @@
>                  self.ui.warn(_('done\n'))
>                  raise
>
> -            top = self.applied[-1].name
> -            if ret[0] and ret[0] > 1:
> -                msg = _("errors during apply, please fix and refresh %s\n")
> -                self.ui.write(msg % top)
> -            else:
> -                self.ui.write(_("now at: %s\n") % top)
> +            if len(self.applied) > 0:
> +                top = self.applied[-1].name
> +               if ret[0] and ret[0] > 1:
> +                    msg = _("errors during apply, please fix and
> refresh %s\n")
> +                    self.ui.write(msg % top)
> +                else:
> +                    self.ui.write(_("now at: %s\n") % top)
>              return ret[0]

Seems better if you invert the condition and return early, instead of
indenting the extra step.

Cheers,

Dirkjan



More information about the Mercurial-devel mailing list