changeset 6332:950e72fc7cf3

convert: allow missing tools not to stop source type detection
author Patrick Mezard <pmezard@gmail.com>
date Thu, 20 Mar 2008 23:32:43 +0100
parents 627665e37bdd
children f477afeb3a0f
files hgext/convert/common.py hgext/convert/convcmd.py hgext/convert/monotone.py
diffstat 3 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/common.py	Thu Mar 20 22:58:53 2008 +0100
+++ b/hgext/convert/common.py	Thu Mar 20 23:32:43 2008 +0100
@@ -18,10 +18,13 @@
     s = base64.decodestring(s)
     return pickle.loads(s)
 
-def checktool(exe, name=None):
+class MissingTool(Exception): pass
+
+def checktool(exe, name=None, abort=True):
     name = name or exe
     if not util.find_exe(exe):
-        raise util.Abort('cannot find required "%s" tool' % name)
+        exc = abort and util.Abort or MissingTool
+        raise exc(_('cannot find required "%s" tool') % name)
 
 class NoRepo(Exception): pass
 
--- a/hgext/convert/convcmd.py	Thu Mar 20 22:58:53 2008 +0100
+++ b/hgext/convert/convcmd.py	Thu Mar 20 23:32:43 2008 +0100
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
 
-from common import NoRepo, SKIPREV, mapfile
+from common import NoRepo, MissingTool, SKIPREV, mapfile
 from cvs import convert_cvs
 from darcs import darcs_source
 from git import convert_git
@@ -48,7 +48,7 @@
         try:
             if not type or name == type:
                 return source(ui, path, rev)
-        except NoRepo, inst:
+        except (NoRepo, MissingTool), inst:
             exceptions.append(inst)
     if not ui.quiet:
         for inst in exceptions:
--- a/hgext/convert/monotone.py	Thu Mar 20 22:58:53 2008 +0100
+++ b/hgext/convert/monotone.py	Thu Mar 20 23:32:43 2008 +0100
@@ -2,7 +2,8 @@
 
 import os, re, time
 from mercurial import util
-from common import NoRepo, commit, converter_source, checktool, commandline
+from common import NoRepo, MissingTool, commit, converter_source, checktool
+from common import commandline
 from mercurial.i18n import _
 
 class monotone_source(converter_source, commandline):
@@ -41,7 +42,7 @@
         if not os.path.exists(path):
             raise norepo
 
-        checktool('mtn')
+        checktool('mtn', abort=False)
 
         # test if there are any revisions
         self.rev = None