Patchwork [evolve-ext] inhibit: don't abort when directaccess is not enabled

login
register
mail settings
Submitter Laurent Charignon
Date July 30, 2015, 12:14 a.m.
Message ID <9d28cbc46f39cd446797.1438215278@lcharignon-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/10073/
State Accepted
Headers show

Comments

Laurent Charignon - July 30, 2015, 12:14 a.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1438188950 25200
#      Wed Jul 29 09:55:50 2015 -0700
# Node ID 9d28cbc46f39cd44679767c3e055f48b05e25152
# Parent  89a1103bf139cf9a700a61a872c7004d1765fc52
inhibit: don't abort when directaccess is not enabled

When directaccess is not enabled, we should just print a warning and not set up
inhibit. We don't need to abort in that case. Example: if the user is running
hg showconfig, we don't want to crash as the command is unrelated to inhibit.
Pierre-Yves David - July 30, 2015, 2:22 a.m.
On 07/29/2015 05:14 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1438188950 25200
> #      Wed Jul 29 09:55:50 2015 -0700
> # Node ID 9d28cbc46f39cd44679767c3e055f48b05e25152
> # Parent  89a1103bf139cf9a700a61a872c7004d1765fc52
> inhibit: don't abort when directaccess is not enabled

pushed to main, thanks!

Patch

diff --git a/hgext/inhibit.py b/hgext/inhibit.py
--- a/hgext/inhibit.py
+++ b/hgext/inhibit.py
@@ -196,8 +196,11 @@  def extsetup(ui):
     try:
         extensions.find('directaccess')
     except KeyError:
-        errormsg = _('Cannot use inhibit without the direct access extension')
-        raise error.Abort(errormsg)
+        errormsg = _('cannot use inhibit without the direct access extension\n')
+        hint = _("(please enable it or inhibit won\'t work)\n")
+        ui.warn(errormsg)
+        ui.warn(hint)
+        return
 
     # Wrapping this to inhibit obsolete revs resulting from a transaction
     extensions.wrapfunction(localrepo.localrepository,
diff --git a/tests/test-inhibit.t b/tests/test-inhibit.t
--- a/tests/test-inhibit.t
+++ b/tests/test-inhibit.t
@@ -725,9 +725,10 @@  Inhibit should not work without directac
   > directaccess=!
   > testextension=!
   > EOF
-  $ hg up 15
-  abort: Cannot use inhibit without the direct access extension
-  [255]
+  $ hg up .
+  cannot use inhibit without the direct access extension
+  (please enable it or inhibit won't work)
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo "directaccess=$(echo $(dirname $TESTDIR))/hgext/directaccess.py" >> $HGRCPATH
   $ cd ..