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

Kevin Bullock kbullock+mercurial at ringworld.org
Fri Oct 21 11:20:28 CDT 2011


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.]

# HG changeset patch
# User Kevin Bullock <kbullock at ringworld.org>
# Date 1319213443 18000
# Branch stable
# Node ID c91cd7c4311ed5fa6c5d6366fc3cb570a4c4221d
# Parent  3eb1a90ea40941ad7a920daad665e27ffdb6f291
import: abort usefully if no patch name given

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3352,7 +3352,7 @@ def identify(ui, repo, source=None, rev=
     _('use any branch information in patch (implied by --exact)'))] +
    commitopts + commitopts2 + similarityopts,
    _('[OPTION]... PATCH...'))
-def import_(ui, repo, patch1, *patches, **opts):
+def import_(ui, repo, patch1=None, *patches, **opts):
    """import an ordered set of patches

    Import a list of patches and commit them individually (unless
@@ -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')



More information about the Mercurial-devel mailing list