##// END OF EJS Templates
replace util.sort with sorted built-in...
Matt Mackall -
r8209:a1a5a57e default
parent child Browse files
Show More
@@ -169,7 +169,7 b' class bugzilla_2_16(object):'
169 def filter_real_bug_ids(self, ids):
169 def filter_real_bug_ids(self, ids):
170 '''filter not-existing bug ids from list.'''
170 '''filter not-existing bug ids from list.'''
171 self.run('select bug_id from bugs where bug_id in %s' % buglist(ids))
171 self.run('select bug_id from bugs where bug_id in %s' % buglist(ids))
172 return util.sort([c[0] for c in self.cursor.fetchall()])
172 return sorted([c[0] for c in self.cursor.fetchall()])
173
173
174 def filter_unknown_bug_ids(self, node, ids):
174 def filter_unknown_bug_ids(self, node, ids):
175 '''filter bug ids from list that already refer to this changeset.'''
175 '''filter bug ids from list that already refer to this changeset.'''
@@ -182,7 +182,7 b' class bugzilla_2_16(object):'
182 self.ui.status(_('bug %d already knows about changeset %s\n') %
182 self.ui.status(_('bug %d already knows about changeset %s\n') %
183 (id, short(node)))
183 (id, short(node)))
184 unknown.discard(id)
184 unknown.discard(id)
185 return util.sort(unknown)
185 return sorted(unknown)
186
186
187 def notify(self, ids, committer):
187 def notify(self, ids, committer):
188 '''tell bugzilla to send mail.'''
188 '''tell bugzilla to send mail.'''
@@ -347,7 +347,7 b' class convert_cvs(converter_source):'
347 def getchanges(self, rev):
347 def getchanges(self, rev):
348 self._parse()
348 self._parse()
349 self.modecache = {}
349 self.modecache = {}
350 return util.sort(self.files[rev].items()), {}
350 return sorted(self.files[rev].iteritems()), {}
351
351
352 def getcommit(self, rev):
352 def getcommit(self, rev):
353 self._parse()
353 self._parse()
@@ -359,4 +359,4 b' class convert_cvs(converter_source):'
359
359
360 def getchangedfiles(self, rev, i):
360 def getchangedfiles(self, rev, i):
361 self._parse()
361 self._parse()
362 return util.sort(self.files[rev].keys())
362 return sorted(self.files[rev])
@@ -383,7 +383,7 b' def createlog(ui, directory=None, root="'
383 if store:
383 if store:
384 # clean up the results and save in the log.
384 # clean up the results and save in the log.
385 store = False
385 store = False
386 e.tags = util.sort([scache(x) for x in tags.get(e.revision, [])])
386 e.tags = sorted([scache(x) for x in tags.get(e.revision, [])])
387 e.comment = scache('\n'.join(e.comment))
387 e.comment = scache('\n'.join(e.comment))
388
388
389 revn = len(e.revision)
389 revn = len(e.revision)
@@ -576,7 +576,7 b' def createchangeset(ui, log, fuzz=60, me'
576 for tag in e.tags:
576 for tag in e.tags:
577 tags[tag] = True
577 tags[tag] = True
578 # remember tags only if this is the latest changeset to have it
578 # remember tags only if this is the latest changeset to have it
579 c.tags = util.sort([tag for tag in tags if globaltags[tag] is c])
579 c.tags = sorted([tag for tag in tags if globaltags[tag] is c])
580
580
581 # Find parent changesets, handle {{mergetobranch BRANCHNAME}}
581 # Find parent changesets, handle {{mergetobranch BRANCHNAME}}
582 # by inserting dummy changesets with two parents, and handle
582 # by inserting dummy changesets with two parents, and handle
@@ -111,7 +111,7 b' class darcs_source(converter_source, com'
111 else:
111 else:
112 changes.append((elt.text.strip(), rev))
112 changes.append((elt.text.strip(), rev))
113 self.lastrev = rev
113 self.lastrev = rev
114 return util.sort(changes), copies
114 return sorted(changes), copies
115
115
116 def getfile(self, name, rev):
116 def getfile(self, name, rev):
117 if rev != self.lastrev:
117 if rev != self.lastrev:
@@ -168,7 +168,7 b' class gnuarch_source(converter_source, c'
168 copies.update(cps)
168 copies.update(cps)
169
169
170 self.lastrev = rev
170 self.lastrev = rev
171 return util.sort(set(changes)), copies
171 return sorted(set(changes)), copies
172
172
173 def getcommit(self, rev):
173 def getcommit(self, rev):
174 changes = self.changes[rev]
174 changes = self.changes[rev]
@@ -163,11 +163,11 b' class mercurial_sink(converter_sink):'
163 tagparent = nullid
163 tagparent = nullid
164
164
165 try:
165 try:
166 oldlines = util.sort(parentctx['.hgtags'].data().splitlines(1))
166 oldlines = sorted(parentctx['.hgtags'].data().splitlines(1))
167 except:
167 except:
168 oldlines = []
168 oldlines = []
169
169
170 newlines = util.sort([("%s %s\n" % (tags[tag], tag)) for tag in tags])
170 newlines = sorted([("%s %s\n" % (tags[tag], tag)) for tag in tags])
171 if newlines == oldlines:
171 if newlines == oldlines:
172 return None
172 return None
173 data = "".join(newlines)
173 data = "".join(newlines)
@@ -251,7 +251,7 b' class mercurial_source(converter_source)'
251 ctx = self.changectx(rev)
251 ctx = self.changectx(rev)
252 parents = self.parents(ctx)
252 parents = self.parents(ctx)
253 if not parents:
253 if not parents:
254 files = util.sort(ctx.manifest().keys())
254 files = sorted(ctx.manifest())
255 if self.ignoreerrors:
255 if self.ignoreerrors:
256 # calling getcopies() is a simple way to detect missing
256 # calling getcopies() is a simple way to detect missing
257 # revlogs and populate self.ignored
257 # revlogs and populate self.ignored
@@ -266,7 +266,7 b' class mercurial_source(converter_source)'
266 copies = self.getcopies(ctx, m + a)
266 copies = self.getcopies(ctx, m + a)
267 changes = [(name, rev) for name in m + a + r
267 changes = [(name, rev) for name in m + a + r
268 if name not in self.ignored]
268 if name not in self.ignored]
269 return util.sort(changes), copies
269 return sorted(changes), copies
270
270
271 def getcopies(self, ctx, files):
271 def getcopies(self, ctx, files):
272 copies = {}
272 copies = {}
@@ -176,4 +176,4 b' class p4_source(converter_source):'
176 return self.tags
176 return self.tags
177
177
178 def getchangedfiles(self, rev, i):
178 def getchangedfiles(self, rev, i):
179 return util.sort([x[0] for x in self.files[rev]])
179 return sorted([x[0] for x in self.files[rev]])
@@ -712,7 +712,7 b' class svn_source(converter_source):'
712 # This will fail if a directory was copied
712 # This will fail if a directory was copied
713 # from another branch and then some of its files
713 # from another branch and then some of its files
714 # were deleted in the same transaction.
714 # were deleted in the same transaction.
715 children = util.sort(self._find_children(path, revnum))
715 children = sorted(self._find_children(path, revnum))
716 for child in children:
716 for child in children:
717 # Can we move a child directory and its
717 # Can we move a child directory and its
718 # parent in the same commit? (probably can). Could
718 # parent in the same commit? (probably can). Could
@@ -779,7 +779,7 b' class svn_source(converter_source):'
779 parents = []
779 parents = []
780 # check whether this revision is the start of a branch or part
780 # check whether this revision is the start of a branch or part
781 # of a branch renaming
781 # of a branch renaming
782 orig_paths = util.sort(orig_paths.items())
782 orig_paths = sorted(orig_paths.iteritems())
783 root_paths = [(p,e) for p,e in orig_paths if self.module.startswith(p)]
783 root_paths = [(p,e) for p,e in orig_paths if self.module.startswith(p)]
784 if root_paths:
784 if root_paths:
785 path, ent = root_paths[-1]
785 path, ent = root_paths[-1]
@@ -1108,7 +1108,7 b' class svn_sink(converter_sink, commandli'
1108 return dirs
1108 return dirs
1109
1109
1110 def add_dirs(self, files):
1110 def add_dirs(self, files):
1111 add_dirs = [d for d in util.sort(self.dirs_of(files))
1111 add_dirs = [d for d in sorted(self.dirs_of(files))
1112 if not os.path.exists(self.wjoin(d, '.svn', 'entries'))]
1112 if not os.path.exists(self.wjoin(d, '.svn', 'entries'))]
1113 if add_dirs:
1113 if add_dirs:
1114 self.xargs(add_dirs, 'add', non_recursive=True, quiet=True)
1114 self.xargs(add_dirs, 'add', non_recursive=True, quiet=True)
@@ -1120,10 +1120,8 b' class svn_sink(converter_sink, commandli'
1120 return files
1120 return files
1121
1121
1122 def tidy_dirs(self, names):
1122 def tidy_dirs(self, names):
1123 dirs = util.sort(self.dirs_of(names))
1124 dirs.reverse()
1125 deleted = []
1123 deleted = []
1126 for d in dirs:
1124 for d in sorted(self.dirs_of(names), reverse=True):
1127 wd = self.wjoin(d)
1125 wd = self.wjoin(d)
1128 if os.listdir(wd) == '.svn':
1126 if os.listdir(wd) == '.svn':
1129 self.run0('delete', d)
1127 self.run0('delete', d)
@@ -539,7 +539,7 b' class Watcher(object):'
539 self.ui.note(_('%s processing %d deferred events as %d\n') %
539 self.ui.note(_('%s processing %d deferred events as %d\n') %
540 (self.event_time(), self.deferred,
540 (self.event_time(), self.deferred,
541 len(self.eventq)))
541 len(self.eventq)))
542 for wpath, evts in util.sort(self.eventq.items()):
542 for wpath, evts in sorted(self.eventq.iteritems()):
543 for evt in evts:
543 for evt in evts:
544 self.deferred_event(wpath, evt)
544 self.deferred_event(wpath, evt)
545 self.eventq.clear()
545 self.eventq.clear()
@@ -377,7 +377,7 b' def files(ui, repo, *pats, **opts):'
377 kwt = kwtools['templater']
377 kwt = kwtools['templater']
378 status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts)
378 status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts)
379 modified, added, removed, deleted, unknown, ignored, clean = status
379 modified, added, removed, deleted, unknown, ignored, clean = status
380 files = util.sort(modified + added + clean + unknown)
380 files = sorted(modified + added + clean + unknown)
381 wctx = repo[None]
381 wctx = repo[None]
382 kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
382 kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
383 cwd = pats and repo.getcwd() or ''
383 cwd = pats and repo.getcwd() or ''
@@ -204,7 +204,7 b' class queue:'
204 bad = self.check_guard(guard)
204 bad = self.check_guard(guard)
205 if bad:
205 if bad:
206 raise util.Abort(bad)
206 raise util.Abort(bad)
207 guards = util.sort(set(guards))
207 guards = sorted(set(guards))
208 self.ui.debug(_('active guards: %s\n') % ' '.join(guards))
208 self.ui.debug(_('active guards: %s\n') % ' '.join(guards))
209 self.active_guards = guards
209 self.active_guards = guards
210 self.guards_dirty = True
210 self.guards_dirty = True
@@ -600,18 +600,16 b' class queue:'
600 return (err, n)
600 return (err, n)
601
601
602 def _clean_series(self, patches):
602 def _clean_series(self, patches):
603 indices = util.sort([self.find_series(p) for p in patches])
603 for i in sorted([self.find_series(p) for p in patches], reverse=True):
604 for i in indices[-1::-1]:
605 del self.full_series[i]
604 del self.full_series[i]
606 self.parse_series()
605 self.parse_series()
607 self.series_dirty = 1
606 self.series_dirty = 1
608
607
609 def finish(self, repo, revs):
608 def finish(self, repo, revs):
610 revs.sort()
611 firstrev = repo[self.applied[0].rev].rev()
609 firstrev = repo[self.applied[0].rev].rev()
612 appliedbase = 0
610 appliedbase = 0
613 patches = []
611 patches = []
614 for rev in util.sort(revs):
612 for rev in sorted(revs):
615 if rev < firstrev:
613 if rev < firstrev:
616 raise util.Abort(_('revision %d is not managed') % rev)
614 raise util.Abort(_('revision %d is not managed') % rev)
617 base = bin(self.applied[appliedbase].rev)
615 base = bin(self.applied[appliedbase].rev)
@@ -1367,7 +1365,7 b' class queue:'
1367 self.guards_path)
1365 self.guards_path)
1368 and not fl.startswith('.')):
1366 and not fl.startswith('.')):
1369 msng_list.append(fl)
1367 msng_list.append(fl)
1370 for x in util.sort(msng_list):
1368 for x in sorted(msng_list):
1371 pfx = self.ui.verbose and ('D ') or ''
1369 pfx = self.ui.verbose and ('D ') or ''
1372 self.ui.write("%s%s\n" % (pfx, displayname(x)))
1370 self.ui.write("%s%s\n" % (pfx, displayname(x)))
1373
1371
@@ -88,11 +88,11 b' def purge(ui, repo, *dirs, **opts):'
88 match.dir = directories.append
88 match.dir = directories.append
89 status = repo.status(match=match, ignored=opts['all'], unknown=True)
89 status = repo.status(match=match, ignored=opts['all'], unknown=True)
90
90
91 for f in util.sort(status[4] + status[5]):
91 for f in sorted(status[4] + status[5]):
92 ui.note(_('Removing file %s\n') % f)
92 ui.note(_('Removing file %s\n') % f)
93 remove(removefile, f)
93 remove(removefile, f)
94
94
95 for f in util.sort(directories)[::-1]:
95 for f in sorted(directories, reverse=True):
96 if match(f) and not os.listdir(repo.wjoin(f)):
96 if match(f) and not os.listdir(repo.wjoin(f)):
97 ui.note(_('Removing directory %s\n') % f)
97 ui.note(_('Removing directory %s\n') % f)
98 remove(os.rmdir, f)
98 remove(os.rmdir, f)
@@ -109,7 +109,7 b' def rebase(ui, repo, **opts):'
109 targetancestors = list(repo.changelog.ancestors(target))
109 targetancestors = list(repo.changelog.ancestors(target))
110 targetancestors.append(target)
110 targetancestors.append(target)
111
111
112 for rev in util.sort(state):
112 for rev in sorted(state):
113 if state[rev] == -1:
113 if state[rev] == -1:
114 storestatus(repo, originalwd, target, state, collapsef, keepf,
114 storestatus(repo, originalwd, target, state, collapsef, keepf,
115 keepbranchesf, external)
115 keepbranchesf, external)
@@ -89,7 +89,7 b' class transplanter:'
89
89
90 def apply(self, repo, source, revmap, merges, opts={}):
90 def apply(self, repo, source, revmap, merges, opts={}):
91 '''apply the revisions in revmap one by one in revision order'''
91 '''apply the revisions in revmap one by one in revision order'''
92 revs = util.sort(revmap)
92 revs = sorted(revmap)
93 p1, p2 = repo.dirstate.parents()
93 p1, p2 = repo.dirstate.parents()
94 pulls = []
94 pulls = []
95 diffopts = patch.diffopts(self.ui, opts)
95 diffopts = patch.diffopts(self.ui, opts)
@@ -315,7 +315,7 b' class transplanter:'
315 if not os.path.isdir(self.path):
315 if not os.path.isdir(self.path):
316 os.mkdir(self.path)
316 os.mkdir(self.path)
317 series = self.opener('series', 'w')
317 series = self.opener('series', 'w')
318 for rev in util.sort(revmap):
318 for rev in sorted(revmap):
319 series.write(revlog.hex(revmap[rev]) + '\n')
319 series.write(revlog.hex(revmap[rev]) + '\n')
320 if merges:
320 if merges:
321 series.write('# Merges\n')
321 series.write('# Merges\n')
@@ -155,7 +155,7 b' class changelog(revlog.revlog):'
155
155
156 def encode_extra(self, d):
156 def encode_extra(self, d):
157 # keys must be sorted to produce a deterministic changelog entry
157 # keys must be sorted to produce a deterministic changelog entry
158 items = [_string_escape('%s:%s' % (k, d[k])) for k in util.sort(d)]
158 items = [_string_escape('%s:%s' % (k, d[k])) for k in sorted(d)]
159 return "\0".join(items)
159 return "\0".join(items)
160
160
161 def read(self, node):
161 def read(self, node):
@@ -216,6 +216,6 b' class changelog(revlog.revlog):'
216 if extra:
216 if extra:
217 extra = self.encode_extra(extra)
217 extra = self.encode_extra(extra)
218 parseddate = "%s %s" % (parseddate, extra)
218 parseddate = "%s %s" % (parseddate, extra)
219 l = [hex(manifest), user, parseddate] + util.sort(files) + ["", desc]
219 l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc]
220 text = "\n".join(l)
220 text = "\n".join(l)
221 return self.addrevision(text, transaction, len(self), p1, p2)
221 return self.addrevision(text, transaction, len(self), p1, p2)
@@ -665,7 +665,7 b' class changeset_printer(object):'
665 self.ui.write(_("copies: %s\n") % ' '.join(copies))
665 self.ui.write(_("copies: %s\n") % ' '.join(copies))
666
666
667 if extra and self.ui.debugflag:
667 if extra and self.ui.debugflag:
668 for key, value in util.sort(extra.items()):
668 for key, value in sorted(extra.items()):
669 self.ui.write(_("extra: %s=%s\n")
669 self.ui.write(_("extra: %s=%s\n")
670 % (key, value.encode('string_escape')))
670 % (key, value.encode('string_escape')))
671
671
@@ -816,7 +816,7 b' class changeset_templater(changeset_prin'
816 return showlist('tag', ctx.tags(), **args)
816 return showlist('tag', ctx.tags(), **args)
817
817
818 def showextras(**args):
818 def showextras(**args):
819 for key, value in util.sort(ctx.extra().items()):
819 for key, value in sorted(ctx.extra().items()):
820 args = args.copy()
820 args = args.copy()
821 args.update(dict(key=key, value=value))
821 args.update(dict(key=key, value=value))
822 yield self.t('extra', **args)
822 yield self.t('extra', **args)
@@ -1163,7 +1163,7 b' def walkchangerevs(ui, repo, pats, chang'
1163 for i, window in increasing_windows(0, len(revs)):
1163 for i, window in increasing_windows(0, len(revs)):
1164 yield 'window', revs[0] < revs[-1], revs[-1]
1164 yield 'window', revs[0] < revs[-1], revs[-1]
1165 nrevs = [rev for rev in revs[i:i+window] if want(rev)]
1165 nrevs = [rev for rev in revs[i:i+window] if want(rev)]
1166 for rev in util.sort(list(nrevs)):
1166 for rev in sorted(nrevs):
1167 fns = fncache.get(rev)
1167 fns = fncache.get(rev)
1168 if not fns:
1168 if not fns:
1169 def fns_generator():
1169 def fns_generator():
@@ -1191,7 +1191,7 b' def commit(ui, repo, commitfunc, pats, o'
1191 m = match(repo, pats, opts)
1191 m = match(repo, pats, opts)
1192 if pats:
1192 if pats:
1193 modified, added, removed = repo.status(match=m)[:3]
1193 modified, added, removed = repo.status(match=m)[:3]
1194 files = util.sort(modified + added + removed)
1194 files = sorted(modified + added + removed)
1195
1195
1196 def is_dir(f):
1196 def is_dir(f):
1197 name = f + '/'
1197 name = f + '/'
@@ -446,7 +446,7 b' def branches(ui, repo, active=False):'
446 hexfunc = ui.debugflag and hex or short
446 hexfunc = ui.debugflag and hex or short
447 activebranches = [encoding.tolocal(repo[n].branch())
447 activebranches = [encoding.tolocal(repo[n].branch())
448 for n in repo.heads(closed=False)]
448 for n in repo.heads(closed=False)]
449 branches = util.sort([(tag in activebranches, repo.changelog.rev(node), tag)
449 branches = sorted([(tag in activebranches, repo.changelog.rev(node), tag)
450 for tag, node in repo.branchtags().items()])
450 for tag, node in repo.branchtags().items()])
451 branches.reverse()
451 branches.reverse()
452
452
@@ -704,7 +704,7 b' def debugancestor(ui, repo, *args):'
704 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
704 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
705
705
706 def debugcommands(ui, cmd='', *args):
706 def debugcommands(ui, cmd='', *args):
707 for cmd, vals in util.sort(table.iteritems()):
707 for cmd, vals in sorted(table.iteritems()):
708 cmd = cmd.split('|')[0].strip('^')
708 cmd = cmd.split('|')[0].strip('^')
709 opts = ', '.join([i[1] for i in vals[1]])
709 opts = ', '.join([i[1] for i in vals[1]])
710 ui.write('%s: %s\n' % (cmd, opts))
710 ui.write('%s: %s\n' % (cmd, opts))
@@ -729,7 +729,7 b" def debugcomplete(ui, cmd='', **opts):"
729 cmdlist = cmdutil.findpossible(cmd, table)
729 cmdlist = cmdutil.findpossible(cmd, table)
730 if ui.verbose:
730 if ui.verbose:
731 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
731 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
732 ui.write("%s\n" % "\n".join(util.sort(cmdlist)))
732 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
733
733
734 def debugfsinfo(ui, path = "."):
734 def debugfsinfo(ui, path = "."):
735 file('.debugfsinfo', 'w').write('')
735 file('.debugfsinfo', 'w').write('')
@@ -827,7 +827,7 b' def debugstate(ui, repo, nodates=None):'
827 """show the contents of the current dirstate"""
827 """show the contents of the current dirstate"""
828 timestr = ""
828 timestr = ""
829 showdate = not nodates
829 showdate = not nodates
830 for file_, ent in util.sort(repo.dirstate._map.iteritems()):
830 for file_, ent in sorted(repo.dirstate._map.iteritems()):
831 if showdate:
831 if showdate:
832 if ent[3] == -1:
832 if ent[3] == -1:
833 # Pad or slice to locale representation
833 # Pad or slice to locale representation
@@ -1258,7 +1258,7 b' def grep(ui, repo, pattern, *pats, **opt'
1258 except error.LookupError:
1258 except error.LookupError:
1259 pass
1259 pass
1260 elif st == 'iter':
1260 elif st == 'iter':
1261 for fn, m in util.sort(matches[rev].items()):
1261 for fn, m in sorted(matches[rev].items()):
1262 copy = copies.get(rev, {}).get(fn)
1262 copy = copies.get(rev, {}).get(fn)
1263 if fn in skip:
1263 if fn in skip:
1264 if copy:
1264 if copy:
@@ -1276,7 +1276,7 b' def grep(ui, repo, pattern, *pats, **opt'
1276 fstate[copy] = m
1276 fstate[copy] = m
1277 prev[fn] = rev
1277 prev[fn] = rev
1278
1278
1279 for fn, state in util.sort(fstate.items()):
1279 for fn, state in sorted(fstate.items()):
1280 if fn in skip:
1280 if fn in skip:
1281 continue
1281 continue
1282 if fn not in copies.get(prev[fn], {}):
1282 if fn not in copies.get(prev[fn], {}):
@@ -1424,7 +1424,7 b' def help_(ui, name=None, with_version=Fa'
1424 return
1424 return
1425
1425
1426 ui.status(header)
1426 ui.status(header)
1427 fns = util.sort(h)
1427 fns = sorted(h)
1428 m = max(map(len, fns))
1428 m = max(map(len, fns))
1429 for f in fns:
1429 for f in fns:
1430 if ui.verbose:
1430 if ui.verbose:
@@ -2327,7 +2327,7 b' def remove(ui, repo, *pats, **opts):'
2327 warn(modified, _('is modified'))
2327 warn(modified, _('is modified'))
2328 warn(added, _('has been marked for add'))
2328 warn(added, _('has been marked for add'))
2329
2329
2330 for f in util.sort(remove + forget):
2330 for f in sorted(remove + forget):
2331 if ui.verbose or not m.exact(f):
2331 if ui.verbose or not m.exact(f):
2332 ui.status(_('removing %s\n') % m.rel(f))
2332 ui.status(_('removing %s\n') % m.rel(f))
2333
2333
@@ -2532,7 +2532,7 b' def revert(ui, repo, *pats, **opts):'
2532 (deleted, revert, remove, False, False),
2532 (deleted, revert, remove, False, False),
2533 )
2533 )
2534
2534
2535 for abs, (rel, exact) in util.sort(names.items()):
2535 for abs, (rel, exact) in sorted(names.items()):
2536 mfentry = mf.get(abs)
2536 mfentry = mf.get(abs)
2537 target = repo.wjoin(abs)
2537 target = repo.wjoin(abs)
2538 def handle(xlist, dobackup):
2538 def handle(xlist, dobackup):
@@ -79,7 +79,7 b' class changectx(object):'
79 return self.filectx(key)
79 return self.filectx(key)
80
80
81 def __iter__(self):
81 def __iter__(self):
82 for f in util.sort(self._manifest):
82 for f in sorted(self._manifest):
83 yield f
83 yield f
84
84
85 def changeset(self): return self._changeset
85 def changeset(self): return self._changeset
@@ -166,7 +166,7 b' class changectx(object):'
166 break
166 break
167 if match(fn):
167 if match(fn):
168 yield fn
168 yield fn
169 for fn in util.sort(fdict):
169 for fn in sorted(fdict):
170 if match.bad(fn, 'No such file in rev ' + str(self)) and match(fn):
170 if match.bad(fn, 'No such file in rev ' + str(self)) and match(fn):
171 yield fn
171 yield fn
172
172
@@ -412,7 +412,7 b' class filectx(object):'
412 visit.extend(fn)
412 visit.extend(fn)
413
413
414 hist = {}
414 hist = {}
415 for r, f in util.sort(visit):
415 for r, f in sorted(visit):
416 curr = decorate(f.data(), f)
416 curr = decorate(f.data(), f)
417 for p in parents(f):
417 for p in parents(f):
418 if p != nullid:
418 if p != nullid:
@@ -557,7 +557,7 b' class workingctx(changectx):'
557 def date(self): return self._date
557 def date(self): return self._date
558 def description(self): return self._text
558 def description(self): return self._text
559 def files(self):
559 def files(self):
560 return util.sort(self._status[0] + self._status[1] + self._status[2])
560 return sorted(self._status[0] + self._status[1] + self._status[2])
561
561
562 def modified(self): return self._status[0]
562 def modified(self): return self._status[0]
563 def added(self): return self._status[1]
563 def added(self): return self._status[1]
@@ -606,7 +606,7 b' class workingctx(changectx):'
606 return self._parents[0].ancestor(c2) # punt on two parents for now
606 return self._parents[0].ancestor(c2) # punt on two parents for now
607
607
608 def walk(self, match):
608 def walk(self, match):
609 return util.sort(self._repo.dirstate.walk(match, True, False).keys())
609 return sorted(self._repo.dirstate.walk(match, True, False))
610
610
611 class workingfilectx(filectx):
611 class workingfilectx(filectx):
612 """A workingfilectx object makes access to data related to a particular
612 """A workingfilectx object makes access to data related to a particular
@@ -727,7 +727,7 b' class memctx(object):'
727 parents = [(p or nullid) for p in parents]
727 parents = [(p or nullid) for p in parents]
728 p1, p2 = parents
728 p1, p2 = parents
729 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
729 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
730 files = util.sort(set(files))
730 files = sorted(set(files))
731 self._status = [files, [], [], [], []]
731 self._status = [files, [], [], [], []]
732 self._filectxfn = filectxfn
732 self._filectxfn = filectxfn
733
733
@@ -10,7 +10,7 b' import util, heapq'
10
10
11 def _nonoverlap(d1, d2, d3):
11 def _nonoverlap(d1, d2, d3):
12 "Return list of elements in d1 not in d2 or d3"
12 "Return list of elements in d1 not in d2 or d3"
13 return util.sort([d for d in d1 if d not in d3 and d not in d2])
13 return sorted([d for d in d1 if d not in d3 and d not in d2])
14
14
15 def _dirname(f):
15 def _dirname(f):
16 s = f.rfind("/")
16 s = f.rfind("/")
@@ -46,7 +46,7 b' def _findoldnames(fctx, limit):'
46 visit += [(p, depth - 1) for p in fc.parents()]
46 visit += [(p, depth - 1) for p in fc.parents()]
47
47
48 # return old names sorted by depth
48 # return old names sorted by depth
49 return [o[1] for o in util.sort(old.values())]
49 return [o[1] for o in sorted(old.values())]
50
50
51 def _findlimit(repo, a, b):
51 def _findlimit(repo, a, b):
52 "find the earliest revision that's an ancestor of a or b but not both"
52 "find the earliest revision that's an ancestor of a or b but not both"
@@ -177,7 +177,7 b' class dirstate(object):'
177 return key in self._map
177 return key in self._map
178
178
179 def __iter__(self):
179 def __iter__(self):
180 for x in util.sort(self._map):
180 for x in sorted(self._map):
181 yield x
181 yield x
182
182
183 def parents(self):
183 def parents(self):
@@ -460,7 +460,7 b' class dirstate(object):'
460 results = {'.hg': None}
460 results = {'.hg': None}
461
461
462 # step 1: find all explicit files
462 # step 1: find all explicit files
463 for ff in util.sort(files):
463 for ff in sorted(files):
464 nf = normalize(normpath(ff))
464 nf = normalize(normpath(ff))
465 if nf in results:
465 if nf in results:
466 continue
466 continue
@@ -526,7 +526,7 b' class dirstate(object):'
526 results[nf] = None
526 results[nf] = None
527
527
528 # step 3: report unseen items in the dmap hash
528 # step 3: report unseen items in the dmap hash
529 visit = util.sort([f for f in dmap if f not in results and match(f)])
529 visit = sorted([f for f in dmap if f not in results and match(f)])
530 for nf, st in zip(visit, util.statfiles([join(i) for i in visit])):
530 for nf, st in zip(visit, util.statfiles([join(i) for i in visit])):
531 if not st is None and not getkind(st.st_mode) in (regkind, lnkkind):
531 if not st is None and not getkind(st.st_mode) in (regkind, lnkkind):
532 st = None
532 st = None
@@ -66,7 +66,7 b' def _picktool(repo, ui, path, binary, sy'
66 if t not in tools:
66 if t not in tools:
67 tools[t] = int(_toolstr(ui, t, "priority", "0"))
67 tools[t] = int(_toolstr(ui, t, "priority", "0"))
68 names = tools.keys()
68 names = tools.keys()
69 tools = util.sort([(-p,t) for t,p in tools.items()])
69 tools = sorted([(-p,t) for t,p in tools.items()])
70 uimerge = ui.config("ui", "merge")
70 uimerge = ui.config("ui", "merge")
71 if uimerge:
71 if uimerge:
72 if uimerge not in names:
72 if uimerge not in names:
@@ -38,7 +38,7 b' class hgwebdir(object):'
38 self.repos = cleannames(conf)
38 self.repos = cleannames(conf)
39 self.repos_sorted = ('', False)
39 self.repos_sorted = ('', False)
40 elif isinstance(conf, dict):
40 elif isinstance(conf, dict):
41 self.repos = util.sort(cleannames(conf.items()))
41 self.repos = sorted(cleannames(conf.items()))
42 else:
42 else:
43 if isinstance(conf, config.config):
43 if isinstance(conf, config.config):
44 cp = conf
44 cp = conf
@@ -293,7 +293,7 b' def manifest(web, req, tmpl):'
293 raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
293 raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
294
294
295 def filelist(**map):
295 def filelist(**map):
296 for f in util.sort(files):
296 for f in sorted(files):
297 full = files[f]
297 full = files[f]
298
298
299 fctx = ctx.filectx(full)
299 fctx = ctx.filectx(full)
@@ -305,7 +305,7 b' def manifest(web, req, tmpl):'
305 "permissions": mf.flags(full)}
305 "permissions": mf.flags(full)}
306
306
307 def dirlist(**map):
307 def dirlist(**map):
308 for d in util.sort(dirs):
308 for d in sorted(dirs):
309
309
310 emptydirs = []
310 emptydirs = []
311 h = dirs[d]
311 h = dirs[d]
@@ -384,7 +384,7 b' def summary(web, req, tmpl):'
384
384
385 b = web.repo.branchtags()
385 b = web.repo.branchtags()
386 l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.iteritems()]
386 l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.iteritems()]
387 for r,n,t in util.sort(l):
387 for r,n,t in sorted(l):
388 yield {'parity': parity.next(),
388 yield {'parity': parity.next(),
389 'branch': t,
389 'branch': t,
390 'node': hex(n),
390 'node': hex(n),
@@ -104,7 +104,7 b' def hook(ui, repo, name, throw=False, **'
104 os.dup2(sys.__stderr__.fileno(), sys.__stdout__.fileno())
104 os.dup2(sys.__stderr__.fileno(), sys.__stdout__.fileno())
105
105
106 try:
106 try:
107 for hname, cmd in util.sort(ui.configitems('hooks')):
107 for hname, cmd in ui.configitems('hooks'):
108 if hname.split('.')[0] != name or not cmd:
108 if hname.split('.')[0] != name or not cmd:
109 continue
109 continue
110 if callable(cmd):
110 if callable(cmd):
@@ -357,7 +357,7 b' class localrepository(repo.repository):'
357 except:
357 except:
358 r = -2 # sort to the beginning of the list if unknown
358 r = -2 # sort to the beginning of the list if unknown
359 l.append((r, t, n))
359 l.append((r, t, n))
360 return [(t, n) for r, t, n in util.sort(l)]
360 return [(t, n) for r, t, n in sorted(l)]
361
361
362 def nodetags(self, node):
362 def nodetags(self, node):
363 '''return the tags associated with a node'''
363 '''return the tags associated with a node'''
@@ -861,7 +861,7 b' class localrepository(repo.repository):'
861 tr = None
861 tr = None
862 valid = 0 # don't save the dirstate if this isn't set
862 valid = 0 # don't save the dirstate if this isn't set
863 try:
863 try:
864 commit = util.sort(wctx.modified() + wctx.added())
864 commit = sorted(wctx.modified() + wctx.added())
865 remove = wctx.removed()
865 remove = wctx.removed()
866 extra = wctx.extra().copy()
866 extra = wctx.extra().copy()
867 branchname = extra['branch']
867 branchname = extra['branch']
@@ -919,7 +919,7 b' class localrepository(repo.repository):'
919 remove.append(f)
919 remove.append(f)
920
920
921 updated, added = [], []
921 updated, added = [], []
922 for f in util.sort(changed):
922 for f in sorted(changed):
923 if f in m1 or f in m2:
923 if f in m1 or f in m2:
924 updated.append(f)
924 updated.append(f)
925 else:
925 else:
@@ -927,7 +927,7 b' class localrepository(repo.repository):'
927
927
928 # update manifest
928 # update manifest
929 m1.update(new)
929 m1.update(new)
930 removed = [f for f in util.sort(remove) if f in m1 or f in m2]
930 removed = [f for f in sorted(remove) if f in m1 or f in m2]
931 removed1 = []
931 removed1 = []
932
932
933 for f in removed:
933 for f in removed:
@@ -1220,7 +1220,7 b' class localrepository(repo.repository):'
1220 return ('close' not in extras)
1220 return ('close' not in extras)
1221 # sort the output in rev descending order
1221 # sort the output in rev descending order
1222 heads = [(-self.changelog.rev(h), h) for h in heads if display(h)]
1222 heads = [(-self.changelog.rev(h), h) for h in heads if display(h)]
1223 return [n for (r, n) in util.sort(heads)]
1223 return [n for (r, n) in sorted(heads)]
1224
1224
1225 def branchheads(self, branch=None, start=None, closed=True):
1225 def branchheads(self, branch=None, start=None, closed=True):
1226 if branch is None:
1226 if branch is None:
@@ -1879,7 +1879,7 b' class localrepository(repo.repository):'
1879 msng_filenode_set.setdefault(fname, {})
1879 msng_filenode_set.setdefault(fname, {})
1880 changedfiles[fname] = 1
1880 changedfiles[fname] = 1
1881 # Go through all our files in order sorted by name.
1881 # Go through all our files in order sorted by name.
1882 for fname in util.sort(changedfiles):
1882 for fname in sorted(changedfiles):
1883 filerevlog = self.file(fname)
1883 filerevlog = self.file(fname)
1884 if not len(filerevlog):
1884 if not len(filerevlog):
1885 raise util.Abort(_("empty or missing revlog for %s") % fname)
1885 raise util.Abort(_("empty or missing revlog for %s") % fname)
@@ -1969,7 +1969,7 b' class localrepository(repo.repository):'
1969 for chnk in mnfst.group(nodeiter, lookuprevlink_func(mnfst)):
1969 for chnk in mnfst.group(nodeiter, lookuprevlink_func(mnfst)):
1970 yield chnk
1970 yield chnk
1971
1971
1972 for fname in util.sort(changedfiles):
1972 for fname in sorted(changedfiles):
1973 filerevlog = self.file(fname)
1973 filerevlog = self.file(fname)
1974 if not len(filerevlog):
1974 if not len(filerevlog):
1975 raise util.Abort(_("empty or missing revlog for %s") % fname)
1975 raise util.Abort(_("empty or missing revlog for %s") % fname)
@@ -130,7 +130,7 b' class manifest(revlog.revlog):'
130 # if we're using the listcache, make sure it is valid and
130 # if we're using the listcache, make sure it is valid and
131 # parented by the same node we're diffing against
131 # parented by the same node we're diffing against
132 if not (changed and self.listcache and p1 and self.mapcache[0] == p1):
132 if not (changed and self.listcache and p1 and self.mapcache[0] == p1):
133 files = util.sort(map)
133 files = sorted(map)
134 checkforbidden(files)
134 checkforbidden(files)
135
135
136 # if this is changed to support newlines in filenames,
136 # if this is changed to support newlines in filenames,
@@ -1053,7 +1053,7 b' def updatedir(ui, repo, patches, similar'
1053 repo.copy(src, dst)
1053 repo.copy(src, dst)
1054 removes = removes.keys()
1054 removes = removes.keys()
1055 if (not similarity) and removes:
1055 if (not similarity) and removes:
1056 repo.remove(util.sort(removes), True)
1056 repo.remove(sorted(removes), True)
1057 for f in patches:
1057 for f in patches:
1058 gp = patches[f]
1058 gp = patches[f]
1059 if gp and gp.mode:
1059 if gp and gp.mode:
@@ -1068,7 +1068,7 b' def updatedir(ui, repo, patches, similar'
1068 cmdutil.addremove(repo, cfiles, similarity=similarity)
1068 cmdutil.addremove(repo, cfiles, similarity=similarity)
1069 files = patches.keys()
1069 files = patches.keys()
1070 files.extend([r for r in removes if r not in files])
1070 files.extend([r for r in removes if r not in files])
1071 return util.sort(files)
1071 return sorted(files)
1072
1072
1073 def externalpatch(patcher, args, patchname, ui, strip, cwd, files):
1073 def externalpatch(patcher, args, patchname, ui, strip, cwd, files):
1074 """use <patcher> to apply <patchname> to the working directory.
1074 """use <patcher> to apply <patchname> to the working directory.
@@ -1242,7 +1242,7 b' def diff(repo, node1=None, node2=None, m'
1242 gone = {}
1242 gone = {}
1243 gitmode = {'l': '120000', 'x': '100755', '': '100644'}
1243 gitmode = {'l': '120000', 'x': '100755', '': '100644'}
1244
1244
1245 for f in util.sort(modified + added + removed):
1245 for f in sorted(modified + added + removed):
1246 to = None
1246 to = None
1247 tn = None
1247 tn = None
1248 dodiff = True
1248 dodiff = True
@@ -172,7 +172,7 b' class basicstore:'
172 l.append((n, n, st.st_size))
172 l.append((n, n, st.st_size))
173 elif kind == stat.S_IFDIR and recurse:
173 elif kind == stat.S_IFDIR and recurse:
174 visit.append(fp)
174 visit.append(fp)
175 return util.sort(l)
175 return sorted(l)
176
176
177 def datafiles(self):
177 def datafiles(self):
178 return self._walk('data', True)
178 return self._walk('data', True)
@@ -211,12 +211,6 b' def binary(s):'
211 """return true if a string is binary data"""
211 """return true if a string is binary data"""
212 return bool(s and '\0' in s)
212 return bool(s and '\0' in s)
213
213
214 def sort(l):
215 if not isinstance(l, list):
216 l = list(l)
217 l.sort()
218 return l
219
220 def increasingchunks(source, min=1024, max=65536):
214 def increasingchunks(source, min=1024, max=65536):
221 '''return no less than min bytes per chunk while data remains,
215 '''return no less than min bytes per chunk while data remains,
222 doubling min after each chunk until it reaches max'''
216 doubling min after each chunk until it reaches max'''
@@ -143,17 +143,17 b' def _verify(repo):'
143 ui.status(_("crosschecking files in changesets and manifests\n"))
143 ui.status(_("crosschecking files in changesets and manifests\n"))
144
144
145 if havemf:
145 if havemf:
146 for c, m in util.sort([(c, m) for m in mflinkrevs for c in mflinkrevs[m]]):
146 for c,m in sorted([(c, m) for m in mflinkrevs for c in mflinkrevs[m]]):
147 err(c, _("changeset refers to unknown manifest %s") % short(m))
147 err(c, _("changeset refers to unknown manifest %s") % short(m))
148 del mflinkrevs
148 del mflinkrevs
149
149
150 for f in util.sort(filelinkrevs):
150 for f in sorted(filelinkrevs):
151 if f not in filenodes:
151 if f not in filenodes:
152 lr = filelinkrevs[f][0]
152 lr = filelinkrevs[f][0]
153 err(lr, _("in changeset but not in manifest"), f)
153 err(lr, _("in changeset but not in manifest"), f)
154
154
155 if havecl:
155 if havecl:
156 for f in util.sort(filenodes):
156 for f in sorted(filenodes):
157 if f not in filelinkrevs:
157 if f not in filelinkrevs:
158 try:
158 try:
159 fl = repo.file(f)
159 fl = repo.file(f)
@@ -171,7 +171,7 b' def _verify(repo):'
171 elif size > 0:
171 elif size > 0:
172 storefiles[f] = True
172 storefiles[f] = True
173
173
174 files = util.sort(set(filenodes) | set(filelinkrevs))
174 files = sorted(set(filenodes) | set(filelinkrevs))
175 for f in files:
175 for f in files:
176 lr = filelinkrevs[f][0]
176 lr = filelinkrevs[f][0]
177 try:
177 try:
@@ -227,7 +227,7 b' def _verify(repo):'
227 # cross-check
227 # cross-check
228 if f in filenodes:
228 if f in filenodes:
229 fns = [(mf.linkrev(l), n) for n,l in filenodes[f].iteritems()]
229 fns = [(mf.linkrev(l), n) for n,l in filenodes[f].iteritems()]
230 for lr, node in util.sort(fns):
230 for lr, node in sorted(fns):
231 err(lr, _("%s in manifests not found") % short(node), f)
231 err(lr, _("%s in manifests not found") % short(node), f)
232
232
233 for f in storefiles:
233 for f in storefiles:
@@ -60,6 +60,7 b' 4:8ea2ef7ad3e8'
60 precommit hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198
60 precommit hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198
61 pretxncommit hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=true
61 pretxncommit hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=true
62 5:fad284daf8c0
62 5:fad284daf8c0
63 5:fad284daf8c0
63 pretxncommit.forbid hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=true
64 pretxncommit.forbid hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=true
64 transaction abort!
65 transaction abort!
65 rollback completed
66 rollback completed
General Comments 0
You need to be logged in to leave comments. Login now