diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py --- a/hgext/bugzilla.py +++ b/hgext/bugzilla.py @@ -169,7 +169,7 @@ class bugzilla_2_16(object): 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 @@ class bugzilla_2_16(object): 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.''' diff --git a/hgext/convert/cvs.py b/hgext/convert/cvs.py --- a/hgext/convert/cvs.py +++ b/hgext/convert/cvs.py @@ -347,7 +347,7 @@ class convert_cvs(converter_source): 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 @@ class convert_cvs(converter_source): def getchangedfiles(self, rev, i): self._parse() - return util.sort(self.files[rev].keys()) + return sorted(self.files[rev]) diff --git a/hgext/convert/cvsps.py b/hgext/convert/cvsps.py --- a/hgext/convert/cvsps.py +++ b/hgext/convert/cvsps.py @@ -383,7 +383,7 @@ def createlog(ui, directory=None, root=" 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 @@ def createchangeset(ui, log, fuzz=60, me 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 diff --git a/hgext/convert/darcs.py b/hgext/convert/darcs.py --- a/hgext/convert/darcs.py +++ b/hgext/convert/darcs.py @@ -111,7 +111,7 @@ class darcs_source(converter_source, com 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: diff --git a/hgext/convert/gnuarch.py b/hgext/convert/gnuarch.py --- a/hgext/convert/gnuarch.py +++ b/hgext/convert/gnuarch.py @@ -168,7 +168,7 @@ class gnuarch_source(converter_source, c 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] diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py --- a/hgext/convert/hg.py +++ b/hgext/convert/hg.py @@ -163,11 +163,11 @@ class mercurial_sink(converter_sink): 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 @@ class mercurial_source(converter_source) 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 @@ class mercurial_source(converter_source) 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 = {} diff --git a/hgext/convert/p4.py b/hgext/convert/p4.py --- a/hgext/convert/p4.py +++ b/hgext/convert/p4.py @@ -176,4 +176,4 @@ class p4_source(converter_source): 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]]) diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -712,7 +712,7 @@ class svn_source(converter_source): # 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 @@ class svn_source(converter_source): 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 @@ class svn_sink(converter_sink, commandli 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 @@ class svn_sink(converter_sink, commandli 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) diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py --- a/hgext/inotify/server.py +++ b/hgext/inotify/server.py @@ -539,7 +539,7 @@ class Watcher(object): 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() diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -377,7 +377,7 @@ def files(ui, repo, *pats, **opts): 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 '' diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -204,7 +204,7 @@ class queue: 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 @@ class queue: 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 @@ class queue: 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))) diff --git a/hgext/purge.py b/hgext/purge.py --- a/hgext/purge.py +++ b/hgext/purge.py @@ -88,11 +88,11 @@ def purge(ui, repo, *dirs, **opts): 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) diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -109,7 +109,7 @@ def rebase(ui, repo, **opts): 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) diff --git a/hgext/transplant.py b/hgext/transplant.py --- a/hgext/transplant.py +++ b/hgext/transplant.py @@ -89,7 +89,7 @@ class transplanter: 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 @@ class transplanter: 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') diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -155,7 +155,7 @@ class changelog(revlog.revlog): 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 @@ class changelog(revlog.revlog): 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) diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -665,7 +665,7 @@ class changeset_printer(object): 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 @@ class changeset_templater(changeset_prin 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 @@ def walkchangerevs(ui, repo, pats, chang 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 @@ def commit(ui, repo, commitfunc, pats, o 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 + '/' diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -446,7 +446,7 @@ def branches(ui, repo, active=False): 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 @@ def debugancestor(ui, repo, *args): 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 @@ def debugcomplete(ui, cmd='', **opts): 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 @@ def debugstate(ui, repo, nodates=None): """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 @@ def grep(ui, repo, pattern, *pats, **opt 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 @@ def grep(ui, repo, pattern, *pats, **opt 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 @@ def help_(ui, name=None, with_version=Fa 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 @@ def remove(ui, repo, *pats, **opts): 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 @@ def revert(ui, repo, *pats, **opts): (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): diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -79,7 +79,7 @@ class changectx(object): 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 @@ class changectx(object): 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 @@ class filectx(object): 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 @@ class workingctx(changectx): 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 @@ class workingctx(changectx): 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 @@ class memctx(object): 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 diff --git a/mercurial/copies.py b/mercurial/copies.py --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -10,7 +10,7 @@ import util, heapq 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 @@ def _findoldnames(fctx, limit): 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" diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -177,7 +177,7 @@ class dirstate(object): 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 @@ class dirstate(object): 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 @@ class dirstate(object): 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 diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -66,7 +66,7 @@ def _picktool(repo, ui, path, binary, sy 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: diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -38,7 +38,7 @@ class hgwebdir(object): 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 diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -293,7 +293,7 @@ def manifest(web, req, tmpl): 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 @@ def manifest(web, req, tmpl): "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 @@ def summary(web, req, tmpl): 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), diff --git a/mercurial/hook.py b/mercurial/hook.py --- a/mercurial/hook.py +++ b/mercurial/hook.py @@ -104,7 +104,7 @@ def hook(ui, repo, name, throw=False, ** 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): diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -357,7 +357,7 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): # 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 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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) diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -130,7 +130,7 @@ class manifest(revlog.revlog): # 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, diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1053,7 +1053,7 @@ def updatedir(ui, repo, patches, similar 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 @@ def updatedir(ui, repo, patches, similar 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 to apply to the working directory. @@ -1242,7 +1242,7 @@ def diff(repo, node1=None, node2=None, m 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 diff --git a/mercurial/store.py b/mercurial/store.py --- a/mercurial/store.py +++ b/mercurial/store.py @@ -172,7 +172,7 @@ class basicstore: 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) diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -211,12 +211,6 @@ def binary(s): """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''' diff --git a/mercurial/verify.py b/mercurial/verify.py --- a/mercurial/verify.py +++ b/mercurial/verify.py @@ -143,17 +143,17 @@ def _verify(repo): 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 @@ def _verify(repo): 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 @@ def _verify(repo): # 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: diff --git a/tests/test-hook.out b/tests/test-hook.out --- a/tests/test-hook.out +++ b/tests/test-hook.out @@ -60,6 +60,7 @@ 4:8ea2ef7ad3e8 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