diff mercurial/commands.py @ 8209:a1a5a57efe90

replace util.sort with sorted built-in This is marginally faster for small and moderately-sized lists
author Matt Mackall <mpm@selenic.com>
date Sun, 26 Apr 2009 16:50:44 -0500
parents 9b8ac5fb7760
children 344751cd8cb8
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/commands.py	Sun Apr 26 16:50:44 2009 -0500
@@ -446,7 +446,7 @@
     hexfunc = ui.debugflag and hex or short
     activebranches = [encoding.tolocal(repo[n].branch())
                             for n in repo.heads(closed=False)]
-    branches = util.sort([(tag in activebranches, repo.changelog.rev(node), tag)
+    branches = sorted([(tag in activebranches, repo.changelog.rev(node), tag)
                           for tag, node in repo.branchtags().items()])
     branches.reverse()
 
@@ -704,7 +704,7 @@
     ui.write("%d:%s\n" % (r.rev(a), hex(a)))
 
 def debugcommands(ui, cmd='', *args):
-    for cmd, vals in util.sort(table.iteritems()):
+    for cmd, vals in sorted(table.iteritems()):
         cmd = cmd.split('|')[0].strip('^')
         opts = ', '.join([i[1] for i in vals[1]])
         ui.write('%s: %s\n' % (cmd, opts))
@@ -729,7 +729,7 @@
     cmdlist = cmdutil.findpossible(cmd, table)
     if ui.verbose:
         cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
-    ui.write("%s\n" % "\n".join(util.sort(cmdlist)))
+    ui.write("%s\n" % "\n".join(sorted(cmdlist)))
 
 def debugfsinfo(ui, path = "."):
     file('.debugfsinfo', 'w').write('')
@@ -827,7 +827,7 @@
     """show the contents of the current dirstate"""
     timestr = ""
     showdate = not nodates
-    for file_, ent in util.sort(repo.dirstate._map.iteritems()):
+    for file_, ent in sorted(repo.dirstate._map.iteritems()):
         if showdate:
             if ent[3] == -1:
                 # Pad or slice to locale representation
@@ -1258,7 +1258,7 @@
                 except error.LookupError:
                     pass
         elif st == 'iter':
-            for fn, m in util.sort(matches[rev].items()):
+            for fn, m in sorted(matches[rev].items()):
                 copy = copies.get(rev, {}).get(fn)
                 if fn in skip:
                     if copy:
@@ -1276,7 +1276,7 @@
                     fstate[copy] = m
                 prev[fn] = rev
 
-    for fn, state in util.sort(fstate.items()):
+    for fn, state in sorted(fstate.items()):
         if fn in skip:
             continue
         if fn not in copies.get(prev[fn], {}):
@@ -1424,7 +1424,7 @@
             return
 
         ui.status(header)
-        fns = util.sort(h)
+        fns = sorted(h)
         m = max(map(len, fns))
         for f in fns:
             if ui.verbose:
@@ -2327,7 +2327,7 @@
         warn(modified, _('is modified'))
         warn(added, _('has been marked for add'))
 
-    for f in util.sort(remove + forget):
+    for f in sorted(remove + forget):
         if ui.verbose or not m.exact(f):
             ui.status(_('removing %s\n') % m.rel(f))
 
@@ -2532,7 +2532,7 @@
             (deleted, revert, remove, False, False),
             )
 
-        for abs, (rel, exact) in util.sort(names.items()):
+        for abs, (rel, exact) in sorted(names.items()):
             mfentry = mf.get(abs)
             target = repo.wjoin(abs)
             def handle(xlist, dobackup):