diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py --- a/hgext/convert/convcmd.py +++ b/hgext/convert/convcmd.py @@ -48,6 +48,8 @@ sink_converters = [ 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 @@ def convertsource(ui, path, type, rev): 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 --git a/tests/test-convert b/tests/test-convert --- a/tests/test-convert +++ b/tests/test-convert @@ -50,3 +50,10 @@ mkdir emptydir # 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 --git a/tests/test-convert.out b/tests/test-convert.out --- a/tests/test-convert.out +++ b/tests/test-convert.out @@ -259,3 +259,8 @@ emptydir does not look like a GNU Arch r 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