Patchwork [2,of,2] dispatch: fix typo suggestion for disabled extension

login
register
mail settings
Submitter via Mercurial-devel
Date July 7, 2017, 7:26 a.m.
Message ID <f968eaa9c1e45e19a904.1499412376@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/22088/
State Accepted
Headers show

Comments

via Mercurial-devel - July 7, 2017, 7:26 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1499411633 25200
#      Fri Jul 07 00:13:53 2017 -0700
# Node ID f968eaa9c1e45e19a90423d875d1538ebb30d884
# Parent  46c6014cd9765a04b61fe03b907f9eceaabba0dd
dispatch: fix typo suggestion for disabled extension

If the matching command lives in an in-tree extension (which is all we
scan for), and the user has disabled that extension with
"extensions.<name>=!", we were not finding it, because the path in
_disabledextensions was the empty string. If the user had set
"extensions.<name>=!<valid path>" it would work, so it seems like just
a mistake that it didn't work.
Yuya Nishihara - July 7, 2017, 1:10 p.m.
On Fri, 07 Jul 2017 00:26:16 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1499411633 25200
> #      Fri Jul 07 00:13:53 2017 -0700
> # Node ID f968eaa9c1e45e19a90423d875d1538ebb30d884
> # Parent  46c6014cd9765a04b61fe03b907f9eceaabba0dd
> dispatch: fix typo suggestion for disabled extension

Queued, thanks.

Patch

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -494,7 +494,11 @@ 
         if name in exts or name in _order or name == '__init__':
             continue
         exts[name] = path
-    exts.update(_disabledextensions)
+    for name, path in _disabledextensions.iteritems():
+        # If no path was provided for a disabled extension (e.g. "color=!"),
+        # don't replace the path we already found by the scan above.
+        if path:
+            exts[name] = path
     return exts
 
 def _moduledoc(file):
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -680,7 +680,11 @@ 
 Disabled extension gets suggested
   $ hg --config extensions.rebase=! rebase
   hg: unknown command 'rebase'
-  (did you mean one of rename, resolve?)
+  'rebase' is provided by the following extension:
+  
+      rebase        command to move sets of revisions to a different ancestor
+  
+  (use 'hg help extensions' for information on enabling extensions)
   [255]
 
 Make sure that we don't run afoul of the help system thinking that