# HG changeset patch # User Patrick Mezard # Date 1259616184 -3600 # Node ID a7178eccf2dc5ea67498ad96d98b65f4ea4d92a3 # Parent 0aa1a632262be8a29c08a1e159239f7857d43be9 convert: better error on invalid repository type diff -r 0aa1a632262b -r a7178eccf2dc hgext/convert/convcmd.py --- a/hgext/convert/convcmd.py Mon Nov 30 22:23:09 2009 +0100 +++ b/hgext/convert/convcmd.py Mon Nov 30 22:23:04 2009 +0100 @@ -48,6 +48,8 @@ def convertsource(ui, path, type, rev): exceptions = [] + if type and type not in [s[0] for s in source_converters]: + raise util.Abort(_('%s: invalid source repository type') % type) for name, source, sortmode in source_converters: try: if not type or name == type: @@ -60,6 +62,8 @@ raise util.Abort(_('%s: missing or unsupported repository') % path) def convertsink(ui, path, type): + if type and type not in [s[0] for s in sink_converters]: + raise util.Abort(_('%s: invalid destination repository type') % type) for name, sink in sink_converters: try: if not type or name == type: diff -r 0aa1a632262b -r a7178eccf2dc tests/test-convert --- a/tests/test-convert Mon Nov 30 22:23:09 2009 +0100 +++ b/tests/test-convert Mon Nov 30 22:23:04 2009 +0100 @@ -50,3 +50,10 @@ # override $PATH to ensure p4 not visible; use $PYTHON in case we're # running from a devel copy, not a temp installation PATH=$BINDIR $PYTHON $BINDIR/hg convert emptydir 2>&1 | sed 's,file://.*/emptydir,.../emptydir,g' + +echo % convert with imaginary source type +hg convert --source-type foo a a-foo +echo % convert with imaginary sink type +hg convert --dest-type foo a a-foo + +true diff -r 0aa1a632262b -r a7178eccf2dc tests/test-convert.out --- a/tests/test-convert.out Mon Nov 30 22:23:09 2009 +0100 +++ b/tests/test-convert.out Mon Nov 30 22:23:04 2009 +0100 @@ -259,3 +259,8 @@ emptydir does not look like a Bazaar repo cannot find required "p4" tool abort: emptydir: missing or unsupported repository +% convert with imaginary source type +initializing destination a-foo repository +abort: foo: invalid source repository type +% convert with imaginary sink type +abort: foo: invalid destination repository type