[PATCH STABLE?] import: abort usefully if no patch name given

Matt Mackall mpm at selenic.com
Fri Oct 21 12:32:48 CDT 2011

On Fri, 2011-10-21 at 11:20 -0500, Kevin Bullock wrote:
> Here's a quick fix for what's arguably a bug (hence I've flagged it for stable): `hg import` with no arguments aborts quite unhelpfully, as shown by timeless' paste here: <http://pastebin.mozilla.org/1361350>
> This patch makes it abort with a useful message when, say, you meant to say `hg import -` but forgot the '-'.
> It also quashes the usage text. Not sure if that's consistent with other commands. Bikeshedding and alternate approaches welcome.
> [Hopefully Apple Mail doesn't mangle this.]

It did, by deleting a bunch of leading spaces:

> @@ -3414,6 +3414,9 @@ def import_(ui, repo, patch1, *patches, 
>     Returns 0 on success.
>     """
> +    if not patch1:
> +        raise util.Abort(_('need at least one patch to import'))
> +
>     patches = (patch1,) + patches
>     date = opts.get('date')

Why oh why would a mailer even do that?

Anyway, fixed, queued, and a trivial test added, thanks.

Mathematics is the supreme nostalgia of our time.

More information about the Mercurial-devel mailing list