Patchwork D9515: command: automatically create alias for command using '-' in names

login
register
mail settings
Submitter phabricator
Date Dec. 4, 2020, 9:26 a.m.
Message ID <differential-rev-PHID-DREV-html7zjcc6njmrzl66ki-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47798/
State Superseded
Headers show

Comments

phabricator - Dec. 4, 2020, 9:26 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9515

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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):