changeset 77:772d75b1a030

Fallback to normal Mercurial API if `mercurial_extension_utils` isn't found.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 20 Aug 2017 16:24:22 -0700
parents 03cc0603800e
children 02b85549369b
files mercurial_all_paths.py
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial_all_paths.py	Sat Jul 22 15:48:58 2017 -0700
+++ b/mercurial_all_paths.py	Sun Aug 20 16:24:22 2017 -0700
@@ -7,6 +7,8 @@
 
 '''execute commands on multiple paths'''
 
+import os
+import sys
 import mercurial.util
 import mercurial.commands
 import mercurial.cmdutil
@@ -31,10 +33,7 @@
         try:
             import mercurial_extension_utils
         except ImportError:
-            raise mercurial.util.Abort(_("""Can not import mercurial_extension_utils.
-Please install this module in Python path.
-See Installation chapter in https://bitbucket.org/Mekk/mercurial-dynamic_username/ for details
-(and for info about TortoiseHG on Windows, or other bundled Python)."""))
+            return None
 
     if not hasattr(mercurial_extension_utils, 'command'):
         raise mercurial.util.Abort(_("""Your mercurial_extension_utils is outdated.
@@ -43,6 +42,10 @@
     return mercurial_extension_utils
 
 meu = import_meu()
+if meu:
+    command_decorator = meu.command
+else:
+    command_decorator = mercurial.cmdutil.command
 
 
 # pylint:disable=invalid-name,broad-except,line-too-long
@@ -151,7 +154,7 @@
 
 
 cmdtable = {}
-command = meu.command(cmdtable)
+command = command_decorator(cmdtable)
 
 
 @command("pushall",