[PATCH evolve-ext] directaccess: don't crash when evolve is not loaded

Laurent Charignon lcharignon at fb.com
Fri May 22 17:38:57 UTC 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1432316296 25200
#      Fri May 22 10:38:16 2015 -0700
# Node ID f3291b8bf1f7b32c3ffeb1d356484a833e2846f0
# Parent  ff93c2fbe1aac1dfd78f7c000dac2a6a0181452f
directaccess: don't crash when evolve is not loaded

Before this patch, when evolve was not loaded direct access was crashing. This
patch catches the error and prevents the crash.

diff --git a/hgext/directaccess.py b/hgext/directaccess.py
--- a/hgext/directaccess.py
+++ b/hgext/directaccess.py
@@ -47,11 +47,11 @@
     branchmap.subsettable['visible-directaccess-warn'] = 'visible'
 
     for warn, ext, cmd in directaccesslevel:
-        cmdtable = extensions.find(ext).cmdtable if ext else commands.table
-        wrapper = wrapwithwarning if warn else wrapwithoutwarning
         try:
+            cmdtable = extensions.find(ext).cmdtable if ext else commands.table
+            wrapper = wrapwithwarning if warn else wrapwithoutwarning
             extensions.wrapcommand(cmdtable, cmd, wrapper)
-        except error.UnknownCommand:
+        except (error.UnknownCommand, KeyError):
             pass
 
 def wrapwithoutwarning(orig, ui, repo, *args, **kwargs):


More information about the Mercurial-devel mailing list