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

login
register
mail settings
Submitter Laurent Charignon
Date May 22, 2015, 5:38 p.m.
Message ID <f3291b8bf1f7b32c3ffe.1432316337@lcharignon-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/9240/
State Accepted
Headers show

Comments

Laurent Charignon - May 22, 2015, 5:38 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@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.
Pierre-Yves David - May 22, 2015, 8:31 p.m.
On 05/22/2015 12:38 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@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

sure, pushed to main.

note: catching the key Error only on the find call would probably be better.

Patch

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):