# HG changeset patch # User Matt Mackall # Date 1238866093 18000 # Node ID db3a68fd9387d10308148bbf1a18c89bf50ce96d # Parent 425a30ddfff6c8ada8cd7c63806cced92544b2ee convert: attempt to check repo type before checking for tool diff -r 425a30ddfff6 -r db3a68fd9387 hgext/convert/bzr.py --- a/hgext/convert/bzr.py Sat Apr 04 19:43:00 2009 +0200 +++ b/hgext/convert/bzr.py Sat Apr 04 12:28:13 2009 -0500 @@ -27,15 +27,15 @@ def __init__(self, ui, path, rev=None): super(bzr_source, self).__init__(ui, path, rev=rev) + if not os.path.exists(os.path.join(path, '.bzr')): + raise NoRepo('%s does not look like a Bazaar repo' % path) + try: # access bzrlib stuff branch except NameError: raise NoRepo('Bazaar modules could not be loaded') - if not os.path.exists(os.path.join(path, '.bzr')): - raise NoRepo('%s does not look like a Bazaar repo' % path) - path = os.path.abspath(path) self.branch = branch.Branch.open(path) self.sourcerepo = self.branch.repository diff -r 425a30ddfff6 -r db3a68fd9387 hgext/convert/darcs.py --- a/hgext/convert/darcs.py Sat Apr 04 19:43:00 2009 +0200 +++ b/hgext/convert/darcs.py Sat Apr 04 12:28:13 2009 -0500 @@ -24,6 +24,9 @@ # check for _darcs, ElementTree, _darcs/inventory so that we can # easily skip test-convert-darcs if ElementTree is not around + if not os.path.exists(os.path.join(path, '_darcs', 'inventories')): + raise NoRepo("%s does not look like a darcs repo" % path) + if not os.path.exists(os.path.join(path, '_darcs')): raise NoRepo("%s does not look like a darcs repo" % path) @@ -32,9 +35,6 @@ if ElementTree is None: raise util.Abort(_("Python ElementTree module is not available")) - if not os.path.exists(os.path.join(path, '_darcs', 'inventories')): - raise NoRepo("%s does not look like a darcs repo" % path) - self.path = os.path.realpath(path) self.lastrev = None diff -r 425a30ddfff6 -r db3a68fd9387 hgext/convert/monotone.py --- a/hgext/convert/monotone.py Sat Apr 04 19:43:00 2009 +0200 +++ b/hgext/convert/monotone.py Sat Apr 04 12:28:13 2009 -0500 @@ -14,6 +14,10 @@ self.ui = ui self.path = path + norepo = NoRepo (_("%s does not look like a monotone repo") % path) + if not os.path.exists(os.path.join(path, '_MTN')): + raise norepo + # regular expressions for parsing monotone output space = r'\s*' name = r'\s+"((?:\\"|[^"])*)"\s*' @@ -39,10 +43,6 @@ self.files = None self.dirs = None - norepo = NoRepo (_("%s does not look like a monotone repo") % path) - if not os.path.exists(path): - raise norepo - checktool('mtn', abort=False) # test if there are any revisions diff -r 425a30ddfff6 -r db3a68fd9387 hgext/convert/p4.py --- a/hgext/convert/p4.py Sat Apr 04 19:43:00 2009 +0200 +++ b/hgext/convert/p4.py Sat Apr 04 12:28:13 2009 -0500 @@ -10,7 +10,7 @@ from mercurial import util from mercurial.i18n import _ -from common import commit, converter_source, checktool +from common import commit, converter_source, checktool, NoRepo import marshal def loaditer(f): @@ -28,6 +28,9 @@ def __init__(self, ui, path, rev=None): super(p4_source, self).__init__(ui, path, rev=rev) + if not path.startswith('//'): + raise NoRepo('%s does not look like a P4 repo' % path) + checktool('p4', abort=False) self.p4changes = {} diff -r 425a30ddfff6 -r db3a68fd9387 hgext/convert/subversion.py --- a/hgext/convert/subversion.py Sat Apr 04 19:43:00 2009 +0200 +++ b/hgext/convert/subversion.py Sat Apr 04 12:28:13 2009 -0500 @@ -152,6 +152,12 @@ def __init__(self, ui, url, rev=None): super(svn_source, self).__init__(ui, url, rev=rev) + if not (url.startswith('svn://') or url.startswith('svn+ssh://') or + (os.path.exists(url) and + os.path.exists(os.path.join(url, '.svn'))) or + (url.startswith('file://'))): + raise NoRepo("%s does not look like a Subversion repo" % url) + try: SubversionException except NameError: diff -r 425a30ddfff6 -r db3a68fd9387 tests/test-convert.out --- a/tests/test-convert.out Sat Apr 04 19:43:00 2009 +0200 +++ b/tests/test-convert.out Sat Apr 04 12:28:13 2009 -0500 @@ -231,11 +231,11 @@ initializing destination emptydir-hg repository emptydir does not look like a CVS checkout emptydir does not look like a Git repo -.../emptydir does not look like a Subversion repo +emptydir does not look like a Subversion repo emptydir is not a local Mercurial repo emptydir does not look like a darcs repo -cannot find required "mtn" tool +emptydir does not look like a monotone repo emptydir does not look like a GNU Arch repo emptydir does not look like a Bazaar repo -cannot find required "p4" tool +emptydir does not look like a P4 repo abort: emptydir: missing or unsupported repository