Patchwork [6,of,8,py3] cmdutil: use sorted(dict) instead of x = dict.keys(); x.sort()

login
register
mail settings
Submitter Augie Fackler
Date May 28, 2017, 8:59 p.m.
Message ID <2faf46402f149abebd3e.1496005142@imladris.local>
Download mbox | patch
Permalink /patch/21003/
State Accepted
Headers show

Comments

Augie Fackler - May 28, 2017, 8:59 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1495994534 14400
#      Sun May 28 14:02:14 2017 -0400
# Node ID 2faf46402f149abebd3e47f854185dc2d83f53b9
# Parent  41aae794b8504450ed27f89422f586625933abee
cmdutil: use sorted(dict) instead of x = dict.keys(); x.sort()

The former both does less work and has the virtue of working on Python 3.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -449,8 +449,7 @@  def findcmd(cmd, table, strict=True):
         return choice[cmd]
 
     if len(choice) > 1:
-        clist = choice.keys()
-        clist.sort()
+        clist = sorted(choice)
         raise error.AmbiguousCommand(cmd, clist)
 
     if choice: