command: automatically create alias for command using '-' in names
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 20 Nov 2020 08:02:25 +0100
changeset 46241 012e25abc603
parent 46240 a42502e9ae6d
child 46242 cb12658bf0e1
command: automatically create alias for command using '-' in names As discussed during the "5.6 Sprint" ignoring dash in command name open the way to using them more. We can now move existing command to more readable (dash using) names without breaking any compatibility. Differential Revision: https://phab.mercurial-scm.org/D9515
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Mon Dec 28 01:05:09 2020 +0100
+++ b/mercurial/cmdutil.py	Fri Nov 20 08:02:25 2020 +0100
@@ -359,7 +359,17 @@
 
 
 def parsealiases(cmd):
-    return cmd.split(b"|")
+    base_aliases = cmd.split(b"|")
+    all_aliases = set(base_aliases)
+    extra_aliases = []
+    for alias in base_aliases:
+        if b'-' in alias:
+            folded_alias = alias.replace(b'-', b'')
+            if folded_alias not in all_aliases:
+                all_aliases.add(folded_alias)
+                extra_aliases.append(folded_alias)
+    base_aliases.extend(extra_aliases)
+    return base_aliases
 
 
 def setupwrapcolorwrite(ui):