Mercurial > hg
changeset 9962:a7178eccf2dc
convert: better error on invalid repository type
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 30 Nov 2009 22:23:04 +0100 |
parents | 0aa1a632262b |
children | a68fb6f4ae4b |
files | hgext/convert/convcmd.py tests/test-convert tests/test-convert.out |
diffstat | 3 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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:
--- 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
--- 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