changeset 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 32a2a1e244f1
children 344751cd8cb8
files hgext/bugzilla.py hgext/convert/cvs.py hgext/convert/cvsps.py hgext/convert/darcs.py hgext/convert/gnuarch.py hgext/convert/hg.py hgext/convert/p4.py hgext/convert/subversion.py hgext/inotify/server.py hgext/keyword.py hgext/mq.py hgext/purge.py hgext/rebase.py hgext/transplant.py mercurial/changelog.py mercurial/cmdutil.py mercurial/commands.py mercurial/context.py mercurial/copies.py mercurial/dirstate.py mercurial/filemerge.py mercurial/hgweb/hgwebdir_mod.py mercurial/hgweb/webcommands.py mercurial/hook.py mercurial/localrepo.py mercurial/manifest.py mercurial/patch.py mercurial/store.py mercurial/util.py mercurial/verify.py tests/test-hook.out
diffstat 31 files changed, 78 insertions(+), 87 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/bugzilla.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/bugzilla.py	Sun Apr 26 16:50:44 2009 -0500
@@ -169,7 +169,7 @@
     def filter_real_bug_ids(self, ids):
         '''filter not-existing bug ids from list.'''
         self.run('select bug_id from bugs where bug_id in %s' % buglist(ids))
-        return util.sort([c[0] for c in self.cursor.fetchall()])
+        return sorted([c[0] for c in self.cursor.fetchall()])
 
     def filter_unknown_bug_ids(self, node, ids):
         '''filter bug ids from list that already refer to this changeset.'''
@@ -182,7 +182,7 @@
             self.ui.status(_('bug %d already knows about changeset %s\n') %
                            (id, short(node)))
             unknown.discard(id)
-        return util.sort(unknown)
+        return sorted(unknown)
 
     def notify(self, ids, committer):
         '''tell bugzilla to send mail.'''
--- a/hgext/convert/cvs.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/convert/cvs.py	Sun Apr 26 16:50:44 2009 -0500
@@ -347,7 +347,7 @@
     def getchanges(self, rev):
         self._parse()
         self.modecache = {}
-        return util.sort(self.files[rev].items()), {}
+        return sorted(self.files[rev].iteritems()), {}
 
     def getcommit(self, rev):
         self._parse()
@@ -359,4 +359,4 @@
 
     def getchangedfiles(self, rev, i):
         self._parse()
-        return util.sort(self.files[rev].keys())
+        return sorted(self.files[rev])
--- a/hgext/convert/cvsps.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/convert/cvsps.py	Sun Apr 26 16:50:44 2009 -0500
@@ -383,7 +383,7 @@
         if store:
             # clean up the results and save in the log.
             store = False
-            e.tags = util.sort([scache(x) for x in tags.get(e.revision, [])])
+            e.tags = sorted([scache(x) for x in tags.get(e.revision, [])])
             e.comment = scache('\n'.join(e.comment))
 
             revn = len(e.revision)
@@ -576,7 +576,7 @@
             for tag in e.tags:
                 tags[tag] = True
         # remember tags only if this is the latest changeset to have it
-        c.tags = util.sort([tag for tag in tags if globaltags[tag] is c])
+        c.tags = sorted([tag for tag in tags if globaltags[tag] is c])
 
     # Find parent changesets, handle {{mergetobranch BRANCHNAME}}
     # by inserting dummy changesets with two parents, and handle
--- a/hgext/convert/darcs.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/convert/darcs.py	Sun Apr 26 16:50:44 2009 -0500
@@ -111,7 +111,7 @@
             else:
                 changes.append((elt.text.strip(), rev))
         self.lastrev = rev
-        return util.sort(changes), copies
+        return sorted(changes), copies
 
     def getfile(self, name, rev):
         if rev != self.lastrev:
--- a/hgext/convert/gnuarch.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/convert/gnuarch.py	Sun Apr 26 16:50:44 2009 -0500
@@ -168,7 +168,7 @@
             copies.update(cps)
 
         self.lastrev = rev
-        return util.sort(set(changes)), copies
+        return sorted(set(changes)), copies
 
     def getcommit(self, rev):
         changes = self.changes[rev]
--- a/hgext/convert/hg.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/convert/hg.py	Sun Apr 26 16:50:44 2009 -0500
@@ -163,11 +163,11 @@
             tagparent = nullid
 
         try:
-            oldlines = util.sort(parentctx['.hgtags'].data().splitlines(1))
+            oldlines = sorted(parentctx['.hgtags'].data().splitlines(1))
         except:
             oldlines = []
 
-        newlines = util.sort([("%s %s\n" % (tags[tag], tag)) for tag in tags])
+        newlines = sorted([("%s %s\n" % (tags[tag], tag)) for tag in tags])
         if newlines == oldlines:
             return None
         data = "".join(newlines)
@@ -251,7 +251,7 @@
         ctx = self.changectx(rev)
         parents = self.parents(ctx)
         if not parents:
-            files = util.sort(ctx.manifest().keys())
+            files = sorted(ctx.manifest())
             if self.ignoreerrors:
                 # calling getcopies() is a simple way to detect missing
                 # revlogs and populate self.ignored
@@ -266,7 +266,7 @@
         copies = self.getcopies(ctx, m + a)
         changes = [(name, rev) for name in m + a + r
                    if name not in self.ignored]
-        return util.sort(changes), copies
+        return sorted(changes), copies
 
     def getcopies(self, ctx, files):
         copies = {}
--- a/hgext/convert/p4.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/convert/p4.py	Sun Apr 26 16:50:44 2009 -0500
@@ -176,4 +176,4 @@
         return self.tags
 
     def getchangedfiles(self, rev, i):
-        return util.sort([x[0] for x in self.files[rev]])
+        return sorted([x[0] for x in self.files[rev]])
--- a/hgext/convert/subversion.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/convert/subversion.py	Sun Apr 26 16:50:44 2009 -0500
@@ -712,7 +712,7 @@
                 # This will fail if a directory was copied
                 # from another branch and then some of its files
                 # were deleted in the same transaction.
-                children = util.sort(self._find_children(path, revnum))
+                children = sorted(self._find_children(path, revnum))
                 for child in children:
                     # Can we move a child directory and its
                     # parent in the same commit? (probably can). Could
@@ -779,7 +779,7 @@
             parents = []
             # check whether this revision is the start of a branch or part
             # of a branch renaming
-            orig_paths = util.sort(orig_paths.items())
+            orig_paths = sorted(orig_paths.iteritems())
             root_paths = [(p,e) for p,e in orig_paths if self.module.startswith(p)]
             if root_paths:
                 path, ent = root_paths[-1]
@@ -1108,7 +1108,7 @@
         return dirs
 
     def add_dirs(self, files):
-        add_dirs = [d for d in util.sort(self.dirs_of(files))
+        add_dirs = [d for d in sorted(self.dirs_of(files))
                     if not os.path.exists(self.wjoin(d, '.svn', 'entries'))]
         if add_dirs:
             self.xargs(add_dirs, 'add', non_recursive=True, quiet=True)
@@ -1120,10 +1120,8 @@
         return files
 
     def tidy_dirs(self, names):
-        dirs = util.sort(self.dirs_of(names))
-        dirs.reverse()
         deleted = []
-        for d in dirs:
+        for d in sorted(self.dirs_of(names), reverse=True):
             wd = self.wjoin(d)
             if os.listdir(wd) == '.svn':
                 self.run0('delete', d)
--- a/hgext/inotify/server.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/inotify/server.py	Sun Apr 26 16:50:44 2009 -0500
@@ -539,7 +539,7 @@
                 self.ui.note(_('%s processing %d deferred events as %d\n') %
                              (self.event_time(), self.deferred,
                               len(self.eventq)))
-            for wpath, evts in util.sort(self.eventq.items()):
+            for wpath, evts in sorted(self.eventq.iteritems()):
                 for evt in evts:
                     self.deferred_event(wpath, evt)
             self.eventq.clear()
--- a/hgext/keyword.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/keyword.py	Sun Apr 26 16:50:44 2009 -0500
@@ -377,7 +377,7 @@
     kwt = kwtools['templater']
     status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts)
     modified, added, removed, deleted, unknown, ignored, clean = status
-    files = util.sort(modified + added + clean + unknown)
+    files = sorted(modified + added + clean + unknown)
     wctx = repo[None]
     kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
     cwd = pats and repo.getcwd() or ''
--- a/hgext/mq.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/mq.py	Sun Apr 26 16:50:44 2009 -0500
@@ -204,7 +204,7 @@
             bad = self.check_guard(guard)
             if bad:
                 raise util.Abort(bad)
-        guards = util.sort(set(guards))
+        guards = sorted(set(guards))
         self.ui.debug(_('active guards: %s\n') % ' '.join(guards))
         self.active_guards = guards
         self.guards_dirty = True
@@ -600,18 +600,16 @@
         return (err, n)
 
     def _clean_series(self, patches):
-        indices = util.sort([self.find_series(p) for p in patches])
-        for i in indices[-1::-1]:
+        for i in sorted([self.find_series(p) for p in patches], reverse=True):
             del self.full_series[i]
         self.parse_series()
         self.series_dirty = 1
 
     def finish(self, repo, revs):
-        revs.sort()
         firstrev = repo[self.applied[0].rev].rev()
         appliedbase = 0
         patches = []
-        for rev in util.sort(revs):
+        for rev in sorted(revs):
             if rev < firstrev:
                 raise util.Abort(_('revision %d is not managed') % rev)
             base = bin(self.applied[appliedbase].rev)
@@ -1367,7 +1365,7 @@
                                    self.guards_path)
                         and not fl.startswith('.')):
                         msng_list.append(fl)
-            for x in util.sort(msng_list):
+            for x in sorted(msng_list):
                 pfx = self.ui.verbose and ('D ') or ''
                 self.ui.write("%s%s\n" % (pfx, displayname(x)))
 
--- a/hgext/purge.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/purge.py	Sun Apr 26 16:50:44 2009 -0500
@@ -88,11 +88,11 @@
     match.dir = directories.append
     status = repo.status(match=match, ignored=opts['all'], unknown=True)
 
-    for f in util.sort(status[4] + status[5]):
+    for f in sorted(status[4] + status[5]):
         ui.note(_('Removing file %s\n') % f)
         remove(removefile, f)
 
-    for f in util.sort(directories)[::-1]:
+    for f in sorted(directories, reverse=True):
         if match(f) and not os.listdir(repo.wjoin(f)):
             ui.note(_('Removing directory %s\n') % f)
             remove(os.rmdir, f)
--- a/hgext/rebase.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/rebase.py	Sun Apr 26 16:50:44 2009 -0500
@@ -109,7 +109,7 @@
         targetancestors = list(repo.changelog.ancestors(target))
         targetancestors.append(target)
 
-        for rev in util.sort(state):
+        for rev in sorted(state):
             if state[rev] == -1:
                 storestatus(repo, originalwd, target, state, collapsef, keepf,
                                                     keepbranchesf, external)
--- a/hgext/transplant.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/hgext/transplant.py	Sun Apr 26 16:50:44 2009 -0500
@@ -89,7 +89,7 @@
 
     def apply(self, repo, source, revmap, merges, opts={}):
         '''apply the revisions in revmap one by one in revision order'''
-        revs = util.sort(revmap)
+        revs = sorted(revmap)
         p1, p2 = repo.dirstate.parents()
         pulls = []
         diffopts = patch.diffopts(self.ui, opts)
@@ -315,7 +315,7 @@
         if not os.path.isdir(self.path):
             os.mkdir(self.path)
         series = self.opener('series', 'w')
-        for rev in util.sort(revmap):
+        for rev in sorted(revmap):
             series.write(revlog.hex(revmap[rev]) + '\n')
         if merges:
             series.write('# Merges\n')
--- a/mercurial/changelog.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/changelog.py	Sun Apr 26 16:50:44 2009 -0500
@@ -155,7 +155,7 @@
 
     def encode_extra(self, d):
         # keys must be sorted to produce a deterministic changelog entry
-        items = [_string_escape('%s:%s' % (k, d[k])) for k in util.sort(d)]
+        items = [_string_escape('%s:%s' % (k, d[k])) for k in sorted(d)]
         return "\0".join(items)
 
     def read(self, node):
@@ -216,6 +216,6 @@
         if extra:
             extra = self.encode_extra(extra)
             parseddate = "%s %s" % (parseddate, extra)
-        l = [hex(manifest), user, parseddate] + util.sort(files) + ["", desc]
+        l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc]
         text = "\n".join(l)
         return self.addrevision(text, transaction, len(self), p1, p2)
--- a/mercurial/cmdutil.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/cmdutil.py	Sun Apr 26 16:50:44 2009 -0500
@@ -665,7 +665,7 @@
             self.ui.write(_("copies:      %s\n") % ' '.join(copies))
 
         if extra and self.ui.debugflag:
-            for key, value in util.sort(extra.items()):
+            for key, value in sorted(extra.items()):
                 self.ui.write(_("extra:       %s=%s\n")
                               % (key, value.encode('string_escape')))
 
@@ -816,7 +816,7 @@
             return showlist('tag', ctx.tags(), **args)
 
         def showextras(**args):
-            for key, value in util.sort(ctx.extra().items()):
+            for key, value in sorted(ctx.extra().items()):
                 args = args.copy()
                 args.update(dict(key=key, value=value))
                 yield self.t('extra', **args)
@@ -1163,7 +1163,7 @@
         for i, window in increasing_windows(0, len(revs)):
             yield 'window', revs[0] < revs[-1], revs[-1]
             nrevs = [rev for rev in revs[i:i+window] if want(rev)]
-            for rev in util.sort(list(nrevs)):
+            for rev in sorted(nrevs):
                 fns = fncache.get(rev)
                 if not fns:
                     def fns_generator():
@@ -1191,7 +1191,7 @@
     m = match(repo, pats, opts)
     if pats:
         modified, added, removed = repo.status(match=m)[:3]
-        files = util.sort(modified + added + removed)
+        files = sorted(modified + added + removed)
 
         def is_dir(f):
             name = f + '/'
--- 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):
--- a/mercurial/context.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/context.py	Sun Apr 26 16:50:44 2009 -0500
@@ -79,7 +79,7 @@
         return self.filectx(key)
 
     def __iter__(self):
-        for f in util.sort(self._manifest):
+        for f in sorted(self._manifest):
             yield f
 
     def changeset(self): return self._changeset
@@ -166,7 +166,7 @@
                     break
             if match(fn):
                 yield fn
-        for fn in util.sort(fdict):
+        for fn in sorted(fdict):
             if match.bad(fn, 'No such file in rev ' + str(self)) and match(fn):
                 yield fn
 
@@ -412,7 +412,7 @@
             visit.extend(fn)
 
         hist = {}
-        for r, f in util.sort(visit):
+        for r, f in sorted(visit):
             curr = decorate(f.data(), f)
             for p in parents(f):
                 if p != nullid:
@@ -557,7 +557,7 @@
     def date(self): return self._date
     def description(self): return self._text
     def files(self):
-        return util.sort(self._status[0] + self._status[1] + self._status[2])
+        return sorted(self._status[0] + self._status[1] + self._status[2])
 
     def modified(self): return self._status[0]
     def added(self): return self._status[1]
@@ -606,7 +606,7 @@
         return self._parents[0].ancestor(c2) # punt on two parents for now
 
     def walk(self, match):
-        return util.sort(self._repo.dirstate.walk(match, True, False).keys())
+        return sorted(self._repo.dirstate.walk(match, True, False))
 
 class workingfilectx(filectx):
     """A workingfilectx object makes access to data related to a particular
@@ -727,7 +727,7 @@
         parents = [(p or nullid) for p in parents]
         p1, p2 = parents
         self._parents = [changectx(self._repo, p) for p in (p1, p2)]
-        files = util.sort(set(files))
+        files = sorted(set(files))
         self._status = [files, [], [], [], []]
         self._filectxfn = filectxfn
 
--- a/mercurial/copies.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/copies.py	Sun Apr 26 16:50:44 2009 -0500
@@ -10,7 +10,7 @@
 
 def _nonoverlap(d1, d2, d3):
     "Return list of elements in d1 not in d2 or d3"
-    return util.sort([d for d in d1 if d not in d3 and d not in d2])
+    return sorted([d for d in d1 if d not in d3 and d not in d2])
 
 def _dirname(f):
     s = f.rfind("/")
@@ -46,7 +46,7 @@
         visit += [(p, depth - 1) for p in fc.parents()]
 
     # return old names sorted by depth
-    return [o[1] for o in util.sort(old.values())]
+    return [o[1] for o in sorted(old.values())]
 
 def _findlimit(repo, a, b):
     "find the earliest revision that's an ancestor of a or b but not both"
--- a/mercurial/dirstate.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/dirstate.py	Sun Apr 26 16:50:44 2009 -0500
@@ -177,7 +177,7 @@
         return key in self._map
 
     def __iter__(self):
-        for x in util.sort(self._map):
+        for x in sorted(self._map):
             yield x
 
     def parents(self):
@@ -460,7 +460,7 @@
         results = {'.hg': None}
 
         # step 1: find all explicit files
-        for ff in util.sort(files):
+        for ff in sorted(files):
             nf = normalize(normpath(ff))
             if nf in results:
                 continue
@@ -526,7 +526,7 @@
                         results[nf] = None
 
         # step 3: report unseen items in the dmap hash
-        visit = util.sort([f for f in dmap if f not in results and match(f)])
+        visit = sorted([f for f in dmap if f not in results and match(f)])
         for nf, st in zip(visit, util.statfiles([join(i) for i in visit])):
             if not st is None and not getkind(st.st_mode) in (regkind, lnkkind):
                 st = None
--- a/mercurial/filemerge.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/filemerge.py	Sun Apr 26 16:50:44 2009 -0500
@@ -66,7 +66,7 @@
         if t not in tools:
             tools[t] = int(_toolstr(ui, t, "priority", "0"))
     names = tools.keys()
-    tools = util.sort([(-p,t) for t,p in tools.items()])
+    tools = sorted([(-p,t) for t,p in tools.items()])
     uimerge = ui.config("ui", "merge")
     if uimerge:
         if uimerge not in names:
--- a/mercurial/hgweb/hgwebdir_mod.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/hgweb/hgwebdir_mod.py	Sun Apr 26 16:50:44 2009 -0500
@@ -38,7 +38,7 @@
             self.repos = cleannames(conf)
             self.repos_sorted = ('', False)
         elif isinstance(conf, dict):
-            self.repos = util.sort(cleannames(conf.items()))
+            self.repos = sorted(cleannames(conf.items()))
         else:
             if isinstance(conf, config.config):
                 cp = conf
--- a/mercurial/hgweb/webcommands.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/hgweb/webcommands.py	Sun Apr 26 16:50:44 2009 -0500
@@ -293,7 +293,7 @@
         raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
 
     def filelist(**map):
-        for f in util.sort(files):
+        for f in sorted(files):
             full = files[f]
 
             fctx = ctx.filectx(full)
@@ -305,7 +305,7 @@
                    "permissions": mf.flags(full)}
 
     def dirlist(**map):
-        for d in util.sort(dirs):
+        for d in sorted(dirs):
 
             emptydirs = []
             h = dirs[d]
@@ -384,7 +384,7 @@
 
         b = web.repo.branchtags()
         l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.iteritems()]
-        for r,n,t in util.sort(l):
+        for r,n,t in sorted(l):
             yield {'parity': parity.next(),
                    'branch': t,
                    'node': hex(n),
--- a/mercurial/hook.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/hook.py	Sun Apr 26 16:50:44 2009 -0500
@@ -104,7 +104,7 @@
         os.dup2(sys.__stderr__.fileno(), sys.__stdout__.fileno())
 
     try:
-        for hname, cmd in util.sort(ui.configitems('hooks')):
+        for hname, cmd in ui.configitems('hooks'):
             if hname.split('.')[0] != name or not cmd:
                 continue
             if callable(cmd):
--- a/mercurial/localrepo.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/localrepo.py	Sun Apr 26 16:50:44 2009 -0500
@@ -357,7 +357,7 @@
             except:
                 r = -2 # sort to the beginning of the list if unknown
             l.append((r, t, n))
-        return [(t, n) for r, t, n in util.sort(l)]
+        return [(t, n) for r, t, n in sorted(l)]
 
     def nodetags(self, node):
         '''return the tags associated with a node'''
@@ -861,7 +861,7 @@
         tr = None
         valid = 0 # don't save the dirstate if this isn't set
         try:
-            commit = util.sort(wctx.modified() + wctx.added())
+            commit = sorted(wctx.modified() + wctx.added())
             remove = wctx.removed()
             extra = wctx.extra().copy()
             branchname = extra['branch']
@@ -919,7 +919,7 @@
                         remove.append(f)
 
             updated, added = [], []
-            for f in util.sort(changed):
+            for f in sorted(changed):
                 if f in m1 or f in m2:
                     updated.append(f)
                 else:
@@ -927,7 +927,7 @@
 
             # update manifest
             m1.update(new)
-            removed = [f for f in util.sort(remove) if f in m1 or f in m2]
+            removed = [f for f in sorted(remove) if f in m1 or f in m2]
             removed1 = []
 
             for f in removed:
@@ -1220,7 +1220,7 @@
             return ('close' not in extras)
         # sort the output in rev descending order
         heads = [(-self.changelog.rev(h), h) for h in heads if display(h)]
-        return [n for (r, n) in util.sort(heads)]
+        return [n for (r, n) in sorted(heads)]
 
     def branchheads(self, branch=None, start=None, closed=True):
         if branch is None:
@@ -1879,7 +1879,7 @@
                     msng_filenode_set.setdefault(fname, {})
                     changedfiles[fname] = 1
             # Go through all our files in order sorted by name.
-            for fname in util.sort(changedfiles):
+            for fname in sorted(changedfiles):
                 filerevlog = self.file(fname)
                 if not len(filerevlog):
                     raise util.Abort(_("empty or missing revlog for %s") % fname)
@@ -1969,7 +1969,7 @@
             for chnk in mnfst.group(nodeiter, lookuprevlink_func(mnfst)):
                 yield chnk
 
-            for fname in util.sort(changedfiles):
+            for fname in sorted(changedfiles):
                 filerevlog = self.file(fname)
                 if not len(filerevlog):
                     raise util.Abort(_("empty or missing revlog for %s") % fname)
--- a/mercurial/manifest.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/manifest.py	Sun Apr 26 16:50:44 2009 -0500
@@ -130,7 +130,7 @@
         # if we're using the listcache, make sure it is valid and
         # parented by the same node we're diffing against
         if not (changed and self.listcache and p1 and self.mapcache[0] == p1):
-            files = util.sort(map)
+            files = sorted(map)
             checkforbidden(files)
 
             # if this is changed to support newlines in filenames,
--- a/mercurial/patch.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/patch.py	Sun Apr 26 16:50:44 2009 -0500
@@ -1053,7 +1053,7 @@
         repo.copy(src, dst)
     removes = removes.keys()
     if (not similarity) and removes:
-        repo.remove(util.sort(removes), True)
+        repo.remove(sorted(removes), True)
     for f in patches:
         gp = patches[f]
         if gp and gp.mode:
@@ -1068,7 +1068,7 @@
     cmdutil.addremove(repo, cfiles, similarity=similarity)
     files = patches.keys()
     files.extend([r for r in removes if r not in files])
-    return util.sort(files)
+    return sorted(files)
 
 def externalpatch(patcher, args, patchname, ui, strip, cwd, files):
     """use <patcher> to apply <patchname> to the working directory.
@@ -1242,7 +1242,7 @@
     gone = {}
     gitmode = {'l': '120000', 'x': '100755', '': '100644'}
 
-    for f in util.sort(modified + added + removed):
+    for f in sorted(modified + added + removed):
         to = None
         tn = None
         dodiff = True
--- a/mercurial/store.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/store.py	Sun Apr 26 16:50:44 2009 -0500
@@ -172,7 +172,7 @@
                         l.append((n, n, st.st_size))
                     elif kind == stat.S_IFDIR and recurse:
                         visit.append(fp)
-        return util.sort(l)
+        return sorted(l)
 
     def datafiles(self):
         return self._walk('data', True)
--- a/mercurial/util.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/util.py	Sun Apr 26 16:50:44 2009 -0500
@@ -211,12 +211,6 @@
     """return true if a string is binary data"""
     return bool(s and '\0' in s)
 
-def sort(l):
-    if not isinstance(l, list):
-        l = list(l)
-    l.sort()
-    return l
-
 def increasingchunks(source, min=1024, max=65536):
     '''return no less than min bytes per chunk while data remains,
     doubling min after each chunk until it reaches max'''
--- a/mercurial/verify.py	Sun Apr 26 16:50:44 2009 -0500
+++ b/mercurial/verify.py	Sun Apr 26 16:50:44 2009 -0500
@@ -143,17 +143,17 @@
     ui.status(_("crosschecking files in changesets and manifests\n"))
 
     if havemf:
-        for c, m in util.sort([(c, m) for m in mflinkrevs for c in mflinkrevs[m]]):
+        for c,m in sorted([(c, m) for m in mflinkrevs for c in mflinkrevs[m]]):
             err(c, _("changeset refers to unknown manifest %s") % short(m))
         del mflinkrevs
 
-        for f in util.sort(filelinkrevs):
+        for f in sorted(filelinkrevs):
             if f not in filenodes:
                 lr = filelinkrevs[f][0]
                 err(lr, _("in changeset but not in manifest"), f)
 
     if havecl:
-        for f in util.sort(filenodes):
+        for f in sorted(filenodes):
             if f not in filelinkrevs:
                 try:
                     fl = repo.file(f)
@@ -171,7 +171,7 @@
         elif size > 0:
             storefiles[f] = True
 
-    files = util.sort(set(filenodes) | set(filelinkrevs))
+    files = sorted(set(filenodes) | set(filelinkrevs))
     for f in files:
         lr = filelinkrevs[f][0]
         try:
@@ -227,7 +227,7 @@
         # cross-check
         if f in filenodes:
             fns = [(mf.linkrev(l), n) for n,l in filenodes[f].iteritems()]
-            for lr, node in util.sort(fns):
+            for lr, node in sorted(fns):
                 err(lr, _("%s in manifests not found") % short(node), f)
 
     for f in storefiles:
--- a/tests/test-hook.out	Sun Apr 26 16:50:44 2009 -0500
+++ b/tests/test-hook.out	Sun Apr 26 16:50:44 2009 -0500
@@ -60,6 +60,7 @@
 precommit hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 
 pretxncommit hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=true 
 5:fad284daf8c0
+5:fad284daf8c0
 pretxncommit.forbid hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=true 
 transaction abort!
 rollback completed