##// END OF EJS Templates
util: add sort helper
Matt Mackall -
r6762:f67d1468 default
parent child Browse files
Show More
@@ -99,9 +99,7 b' class bugzilla_2_16(object):'
99 def filter_real_bug_ids(self, ids):
99 def filter_real_bug_ids(self, ids):
100 '''filter not-existing bug ids from list.'''
100 '''filter not-existing bug ids from list.'''
101 self.run('select bug_id from bugs where bug_id in %s' % buglist(ids))
101 self.run('select bug_id from bugs where bug_id in %s' % buglist(ids))
102 ids = [c[0] for c in self.cursor.fetchall()]
102 return util.sort([c[0] for c in self.cursor.fetchall()])
103 ids.sort()
104 return ids
105
103
106 def filter_unknown_bug_ids(self, node, ids):
104 def filter_unknown_bug_ids(self, node, ids):
107 '''filter bug ids from list that already refer to this changeset.'''
105 '''filter bug ids from list that already refer to this changeset.'''
@@ -114,9 +112,7 b' class bugzilla_2_16(object):'
114 self.ui.status(_('bug %d already knows about changeset %s\n') %
112 self.ui.status(_('bug %d already knows about changeset %s\n') %
115 (id, short(node)))
113 (id, short(node)))
116 unknown.pop(id, None)
114 unknown.pop(id, None)
117 ids = unknown.keys()
115 return util.sort(unknown.keys())
118 ids.sort()
119 return ids
120
116
121 def notify(self, ids):
117 def notify(self, ids):
122 '''tell bugzilla to send mail.'''
118 '''tell bugzilla to send mail.'''
@@ -92,14 +92,12 b' def churn(ui, repo, **opts):'
92 alias, actual = l.split()
92 alias, actual = l.split()
93 amap[alias] = actual
93 amap[alias] = actual
94
94
95 revs = [int(r) for r in cmdutil.revrange(repo, opts['rev'])]
95 revs = util.sort([int(r) for r in cmdutil.revrange(repo, opts['rev'])])
96 revs.sort()
97 stats = countrevs(ui, repo, amap, revs, opts.get('progress'))
96 stats = countrevs(ui, repo, amap, revs, opts.get('progress'))
98 if not stats:
97 if not stats:
99 return
98 return
100
99
101 stats = [(-l, u, l) for u,l in stats.items()]
100 stats = util.sort([(-l, u, l) for u,l in stats.items()])
102 stats.sort()
103 maxchurn = float(max(1, stats[0][2]))
101 maxchurn = float(max(1, stats[0][2]))
104 maxuser = max([len(u) for k, u, l in stats])
102 maxuser = max([len(u) for k, u, l in stats])
105
103
@@ -337,10 +337,7 b' class convert_cvs(converter_source):'
337
337
338 def getchanges(self, rev):
338 def getchanges(self, rev):
339 self.modecache = {}
339 self.modecache = {}
340 files = self.files[rev]
340 return util.sort(self.files[rev].items()), {}
341 cl = files.items()
342 cl.sort()
343 return (cl, {})
344
341
345 def getcommit(self, rev):
342 def getcommit(self, rev):
346 return self.changeset[rev]
343 return self.changeset[rev]
@@ -349,7 +346,4 b' class convert_cvs(converter_source):'
349 return self.tags
346 return self.tags
350
347
351 def getchangedfiles(self, rev, i):
348 def getchangedfiles(self, rev, i):
352 files = self.files[rev].keys()
349 return util.sort(self.files[rev].keys())
353 files.sort()
354 return files
355
@@ -297,8 +297,7 b' def createlog(ui, directory=None, root="'
297 if store:
297 if store:
298 # clean up the results and save in the log.
298 # clean up the results and save in the log.
299 store = False
299 store = False
300 e.tags = [scache(x) for x in tags.get(e.revision, [])]
300 e.tags = util.sort([scache(x) for x in tags.get(e.revision, [])])
301 e.tags.sort()
302 e.comment = scache('\n'.join(e.comment))
301 e.comment = scache('\n'.join(e.comment))
303
302
304 revn = len(e.revision)
303 revn = len(e.revision)
@@ -468,9 +467,7 b' def createchangeset(ui, log, fuzz=60, me'
468 for tag in e.tags:
467 for tag in e.tags:
469 tags[tag] = True
468 tags[tag] = True
470 # remember tags only if this is the latest changeset to have it
469 # remember tags only if this is the latest changeset to have it
471 tagnames = [tag for tag in tags if globaltags[tag] is c]
470 c.tags = util.sort([tag for tag in tags if globaltags[tag] is c])
472 tagnames.sort()
473 c.tags = tagnames
474
471
475 # Find parent changesets, handle {{mergetobranch BRANCHNAME}}
472 # Find parent changesets, handle {{mergetobranch BRANCHNAME}}
476 # by inserting dummy changesets with two parents, and handle
473 # by inserting dummy changesets with two parents, and handle
@@ -110,9 +110,8 b' class darcs_source(converter_source, com'
110 copies[elt.get('from')] = elt.get('to')
110 copies[elt.get('from')] = elt.get('to')
111 else:
111 else:
112 changes.append((elt.text.strip(), rev))
112 changes.append((elt.text.strip(), rev))
113 changes.sort()
114 self.lastrev = rev
113 self.lastrev = rev
115 return changes, copies
114 return util.sort(changes), copies
116
115
117 def getfile(self, name, rev):
116 def getfile(self, name, rev):
118 if rev != self.lastrev:
117 if rev != self.lastrev:
@@ -130,10 +130,8 b' class gnuarch_source(converter_source, c'
130 for c in cps:
130 for c in cps:
131 copies[c] = cps[c]
131 copies[c] = cps[c]
132
132
133 changes.sort()
134 self.lastrev = rev
133 self.lastrev = rev
135
134 return util.sort(changes), copies
136 return changes, copies
137
135
138 def getcommit(self, rev):
136 def getcommit(self, rev):
139 changes = self.changes[rev]
137 changes = self.changes[rev]
@@ -164,14 +164,11 b' class mercurial_sink(converter_sink):'
164 tagparent = nullid
164 tagparent = nullid
165
165
166 try:
166 try:
167 old = parentctx.filectx(".hgtags").data()
167 oldlines = util.sort(parentctx['.hgtags'].data().splitlines(1))
168 oldlines = old.splitlines(1)
169 oldlines.sort()
170 except:
168 except:
171 oldlines = []
169 oldlines = []
172
170
173 newlines = [("%s %s\n" % (tags[tag], tag)) for tag in tags.keys()]
171 newlines = util.sort([("%s %s\n" % (tags[tag], tag)) for tag in tags])
174 newlines.sort()
175
172
176 if newlines == oldlines:
173 if newlines == oldlines:
177 return None
174 return None
@@ -238,8 +235,7 b' class mercurial_source(converter_source)'
238 else:
235 else:
239 m, a, r = self.repo.status(ctx.parents()[0].node(), ctx.node())[:3]
236 m, a, r = self.repo.status(ctx.parents()[0].node(), ctx.node())[:3]
240 changes = [(name, rev) for name in m + a + r]
237 changes = [(name, rev) for name in m + a + r]
241 changes.sort()
238 return util.sort(changes), self.getcopies(ctx, m + a)
242 return (changes, self.getcopies(ctx, m + a))
243
239
244 def getcopies(self, ctx, files):
240 def getcopies(self, ctx, files):
245 copies = {}
241 copies = {}
@@ -658,8 +658,7 b' class svn_source(converter_source):'
658 # This will fail if a directory was copied
658 # This will fail if a directory was copied
659 # from another branch and then some of its files
659 # from another branch and then some of its files
660 # were deleted in the same transaction.
660 # were deleted in the same transaction.
661 children = self._find_children(path, revnum)
661 children = util.sort(self._find_children(path, revnum))
662 children.sort()
663 for child in children:
662 for child in children:
664 # Can we move a child directory and its
663 # Can we move a child directory and its
665 # parent in the same commit? (probably can). Could
664 # parent in the same commit? (probably can). Could
@@ -732,8 +731,7 b' class svn_source(converter_source):'
732 parents = []
731 parents = []
733 # check whether this revision is the start of a branch or part
732 # check whether this revision is the start of a branch or part
734 # of a branch renaming
733 # of a branch renaming
735 orig_paths = orig_paths.items()
734 orig_paths = util.sort(orig_paths.items())
736 orig_paths.sort()
737 root_paths = [(p,e) for p,e in orig_paths if self.module.startswith(p)]
735 root_paths = [(p,e) for p,e in orig_paths if self.module.startswith(p)]
738 if root_paths:
736 if root_paths:
739 path, ent = root_paths[-1]
737 path, ent = root_paths[-1]
@@ -1045,10 +1043,9 b' class svn_sink(converter_sink, commandli'
1045 return dirs
1043 return dirs
1046
1044
1047 def add_dirs(self, files):
1045 def add_dirs(self, files):
1048 add_dirs = [d for d in self.dirs_of(files)
1046 add_dirs = [d for d in util.sort(self.dirs_of(files))
1049 if not os.path.exists(self.wjoin(d, '.svn', 'entries'))]
1047 if not os.path.exists(self.wjoin(d, '.svn', 'entries'))]
1050 if add_dirs:
1048 if add_dirs:
1051 add_dirs.sort()
1052 self.xargs(add_dirs, 'add', non_recursive=True, quiet=True)
1049 self.xargs(add_dirs, 'add', non_recursive=True, quiet=True)
1053 return add_dirs
1050 return add_dirs
1054
1051
@@ -1058,8 +1055,7 b' class svn_sink(converter_sink, commandli'
1058 return files
1055 return files
1059
1056
1060 def tidy_dirs(self, names):
1057 def tidy_dirs(self, names):
1061 dirs = list(self.dirs_of(names))
1058 dirs = util.sort(self.dirs_of(names))
1062 dirs.sort()
1063 dirs.reverse()
1059 dirs.reverse()
1064 deleted = []
1060 deleted = []
1065 for d in dirs:
1061 for d in dirs:
@@ -13,6 +13,7 b' from mercurial.commands import templateo'
13 from mercurial.i18n import _
13 from mercurial.i18n import _
14 from mercurial.node import nullrev
14 from mercurial.node import nullrev
15 from mercurial.util import Abort, canonpath
15 from mercurial.util import Abort, canonpath
16 from mercurial import util
16
17
17 def revision_grapher(repo, start_rev, stop_rev):
18 def revision_grapher(repo, start_rev, stop_rev):
18 """incremental revision grapher
19 """incremental revision grapher
@@ -53,8 +54,7 b' def revision_grapher(repo, start_rev, st'
53 for parent in parents:
54 for parent in parents:
54 if parent not in next_revs:
55 if parent not in next_revs:
55 parents_to_add.append(parent)
56 parents_to_add.append(parent)
56 parents_to_add.sort()
57 next_revs[rev_index:rev_index + 1] = util.sort(parents_to_add)
57 next_revs[rev_index:rev_index + 1] = parents_to_add
58
58
59 edges = []
59 edges = []
60 for parent in parents:
60 for parent in parents:
@@ -105,8 +105,7 b' def filelog_grapher(repo, path, start_re'
105 for parent in parents:
105 for parent in parents:
106 if parent not in next_revs:
106 if parent not in next_revs:
107 parents_to_add.append(parent)
107 parents_to_add.append(parent)
108 parents_to_add.sort()
108 next_revs[rev_index:rev_index + 1] = util.sort(parents_to_add)
109 next_revs[rev_index:rev_index + 1] = parents_to_add
110
109
111 edges = []
110 edges = []
112 for parent in parents:
111 for parent in parents:
@@ -534,9 +534,7 b' class Watcher(object):'
534 self.ui.note('%s processing %d deferred events as %d\n' %
534 self.ui.note('%s processing %d deferred events as %d\n' %
535 (self.event_time(), self.deferred,
535 (self.event_time(), self.deferred,
536 len(self.eventq)))
536 len(self.eventq)))
537 eventq = self.eventq.items()
537 for wpath, evts in util.sort(self.eventq.items()):
538 eventq.sort()
539 for wpath, evts in eventq:
540 for evt in evts:
538 for evt in evts:
541 self.deferred_event(wpath, evt)
539 self.deferred_event(wpath, evt)
542 self.eventq.clear()
540 self.eventq.clear()
@@ -183,7 +183,6 b' class kwtemplater(object):'
183 candidates = [f for f in files if self.iskwfile(f, ctx.flags)]
183 candidates = [f for f in files if self.iskwfile(f, ctx.flags)]
184 if candidates:
184 if candidates:
185 self.restrict = True # do not expand when reading
185 self.restrict = True # do not expand when reading
186 candidates.sort()
187 action = expand and 'expanding' or 'shrinking'
186 action = expand and 'expanding' or 'shrinking'
188 for f in candidates:
187 for f in candidates:
189 fp = self.repo.file(f)
188 fp = self.repo.file(f)
@@ -382,8 +381,7 b' def files(ui, repo, *pats, **opts):'
382 kwt = kwtools['templater']
381 kwt = kwtools['templater']
383 status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts)
382 status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts)
384 modified, added, removed, deleted, unknown, ignored, clean = status
383 modified, added, removed, deleted, unknown, ignored, clean = status
385 files = modified + added + clean + unknown
384 files = util.sort(modified + added + clean + unknown)
386 files.sort()
387 wctx = repo[None]
385 wctx = repo[None]
388 kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
386 kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
389 cwd = pats and repo.getcwd() or ''
387 cwd = pats and repo.getcwd() or ''
@@ -143,8 +143,7 b' class queue:'
143 bad = self.check_guard(guard)
143 bad = self.check_guard(guard)
144 if bad:
144 if bad:
145 raise util.Abort(bad)
145 raise util.Abort(bad)
146 guards = dict.fromkeys(guards).keys()
146 guards = util.sort(util.unique(guards))
147 guards.sort()
148 self.ui.debug('active guards: %s\n' % ' '.join(guards))
147 self.ui.debug('active guards: %s\n' % ' '.join(guards))
149 self.active_guards = guards
148 self.active_guards = guards
150 self.guards_dirty = True
149 self.guards_dirty = True
@@ -536,8 +535,7 b' class queue:'
536 return (err, n)
535 return (err, n)
537
536
538 def _clean_series(self, patches):
537 def _clean_series(self, patches):
539 indices = [self.find_series(p) for p in patches]
538 indices = util.sort([self.find_series(p) for p in patches])
540 indices.sort()
541 for i in indices[-1::-1]:
539 for i in indices[-1::-1]:
542 del self.full_series[i]
540 del self.full_series[i]
543 self.parse_series()
541 self.parse_series()
@@ -545,10 +543,10 b' class queue:'
545
543
546 def finish(self, repo, revs):
544 def finish(self, repo, revs):
547 revs.sort()
545 revs.sort()
548 firstrev = repo.changelog.rev(revlog.bin(self.applied[0].rev))
546 firstrev = repo[self.applied[0].rev].rev()
549 appliedbase = 0
547 appliedbase = 0
550 patches = []
548 patches = []
551 for rev in revs:
549 for rev in util.sort(revs):
552 if rev < firstrev:
550 if rev < firstrev:
553 raise util.Abort(_('revision %d is not managed') % rev)
551 raise util.Abort(_('revision %d is not managed') % rev)
554 base = revlog.bin(self.applied[appliedbase].rev)
552 base = revlog.bin(self.applied[appliedbase].rev)
@@ -1261,8 +1259,7 b' class queue:'
1261 self.guards_path)
1259 self.guards_path)
1262 and not fl.startswith('.')):
1260 and not fl.startswith('.')):
1263 msng_list.append(fl)
1261 msng_list.append(fl)
1264 msng_list.sort()
1262 for x in util.sort(msng_list):
1265 for x in msng_list:
1266 pfx = self.ui.verbose and ('D ') or ''
1263 pfx = self.ui.verbose and ('D ') or ''
1267 self.ui.write("%s%s\n" % (pfx, displayname(x)))
1264 self.ui.write("%s%s\n" % (pfx, displayname(x)))
1268
1265
@@ -156,9 +156,7 b' class notifier(object):'
156 if fnmatch.fnmatch(self.repo.root, pat):
156 if fnmatch.fnmatch(self.repo.root, pat):
157 for user in users.split(','):
157 for user in users.split(','):
158 subs[self.fixmail(user)] = 1
158 subs[self.fixmail(user)] = 1
159 subs = subs.keys()
159 return util.sort(subs)
160 subs.sort()
161 return subs
162
160
163 def url(self, path=None):
161 def url(self, path=None):
164 return self.ui.config('web', 'baseurl') + (path or self.root)
162 return self.ui.config('web', 'baseurl') + (path or self.root)
@@ -77,15 +77,12 b' def purge(ui, repo, *dirs, **opts):'
77 match = cmdutil.match(repo, dirs, opts)
77 match = cmdutil.match(repo, dirs, opts)
78 match.dir = directories.append
78 match.dir = directories.append
79 status = repo.status(match=match, ignored=opts['all'], unknown=True)
79 status = repo.status(match=match, ignored=opts['all'], unknown=True)
80 files = status[4] + status[5]
81 files.sort()
82 directories.sort()
83
80
84 for f in files:
81 for f in util.sort(status[4] + status[5]):
85 ui.note(_('Removing file %s\n') % f)
82 ui.note(_('Removing file %s\n') % f)
86 remove(os.remove, f)
83 remove(os.remove, f)
87
84
88 for f in directories[::-1]:
85 for f in util.sort(directories)[::-1]:
89 if match(f) and not os.listdir(repo.wjoin(f)):
86 if match(f) and not os.listdir(repo.wjoin(f)):
90 ui.note(_('Removing directory %s\n') % f)
87 ui.note(_('Removing directory %s\n') % f)
91 remove(os.rmdir, f)
88 remove(os.rmdir, f)
@@ -88,9 +88,7 b' class transplanter:'
88
88
89 def apply(self, repo, source, revmap, merges, opts={}):
89 def apply(self, repo, source, revmap, merges, opts={}):
90 '''apply the revisions in revmap one by one in revision order'''
90 '''apply the revisions in revmap one by one in revision order'''
91 revs = revmap.keys()
91 revs = util.sort(revmap)
92 revs.sort()
93
94 p1, p2 = repo.dirstate.parents()
92 p1, p2 = repo.dirstate.parents()
95 pulls = []
93 pulls = []
96 diffopts = patch.diffopts(self.ui, opts)
94 diffopts = patch.diffopts(self.ui, opts)
@@ -310,9 +308,7 b' class transplanter:'
310 if not os.path.isdir(self.path):
308 if not os.path.isdir(self.path):
311 os.mkdir(self.path)
309 os.mkdir(self.path)
312 series = self.opener('series', 'w')
310 series = self.opener('series', 'w')
313 revs = revmap.keys()
311 for rev in util.sort(revmap):
314 revs.sort()
315 for rev in revs:
316 series.write(revlog.hex(revmap[rev]) + '\n')
312 series.write(revlog.hex(revmap[rev]) + '\n')
317 if merges:
313 if merges:
318 series.write('# Merges\n')
314 series.write('# Merges\n')
@@ -572,10 +568,6 b' def transplant(ui, repo, *revs, **opts):'
572 for r in merges:
568 for r in merges:
573 revmap[source.changelog.rev(r)] = r
569 revmap[source.changelog.rev(r)] = r
574
570
575 revs = revmap.keys()
576 revs.sort()
577 pulls = []
578
579 tp.apply(repo, source, revmap, merges, opts)
571 tp.apply(repo, source, revmap, merges, opts)
580 finally:
572 finally:
581 if bundle:
573 if bundle:
@@ -130,9 +130,7 b' class changelog(revlog):'
130
130
131 def encode_extra(self, d):
131 def encode_extra(self, d):
132 # keys must be sorted to produce a deterministic changelog entry
132 # keys must be sorted to produce a deterministic changelog entry
133 keys = d.keys()
133 items = [_string_escape('%s:%s' % (k, d[k])) for k in util.sort(d)]
134 keys.sort()
135 items = [_string_escape('%s:%s' % (k, d[k])) for k in keys]
136 return "\0".join(items)
134 return "\0".join(items)
137
135
138 def read(self, node):
136 def read(self, node):
@@ -175,7 +173,7 b' class changelog(revlog):'
175 files = l[3:]
173 files = l[3:]
176 return (manifest, user, (time, timezone), files, desc, extra)
174 return (manifest, user, (time, timezone), files, desc, extra)
177
175
178 def add(self, manifest, list, desc, transaction, p1=None, p2=None,
176 def add(self, manifest, files, desc, transaction, p1=None, p2=None,
179 user=None, date=None, extra={}):
177 user=None, date=None, extra={}):
180
178
181 user, desc = util.fromlocal(user), util.fromlocal(desc)
179 user, desc = util.fromlocal(user), util.fromlocal(desc)
@@ -189,7 +187,6 b' class changelog(revlog):'
189 if extra:
187 if extra:
190 extra = self.encode_extra(extra)
188 extra = self.encode_extra(extra)
191 parseddate = "%s %s" % (parseddate, extra)
189 parseddate = "%s %s" % (parseddate, extra)
192 list.sort()
190 l = [hex(manifest), user, parseddate] + util.sort(files) + ["", desc]
193 l = [hex(manifest), user, parseddate] + list + ["", desc]
194 text = "\n".join(l)
191 text = "\n".join(l)
195 return self.addrevision(text, transaction, len(self), p1, p2)
192 return self.addrevision(text, transaction, len(self), p1, p2)
@@ -653,9 +653,7 b' class changeset_printer(object):'
653 self.ui.write(_("copies: %s\n") % ' '.join(copies))
653 self.ui.write(_("copies: %s\n") % ' '.join(copies))
654
654
655 if extra and self.ui.debugflag:
655 if extra and self.ui.debugflag:
656 extraitems = extra.items()
656 for key, value in util.sort(extra.items()):
657 extraitems.sort()
658 for key, value in extraitems:
659 self.ui.write(_("extra: %s=%s\n")
657 self.ui.write(_("extra: %s=%s\n")
660 % (key, value.encode('string_escape')))
658 % (key, value.encode('string_escape')))
661
659
@@ -799,9 +797,7 b' class changeset_templater(changeset_prin'
799 return showlist('tag', self.repo.nodetags(changenode), **args)
797 return showlist('tag', self.repo.nodetags(changenode), **args)
800
798
801 def showextras(**args):
799 def showextras(**args):
802 extras = changes[5].items()
800 for key, value in util.sort(changes[5].items()):
803 extras.sort()
804 for key, value in extras:
805 args = args.copy()
801 args = args.copy()
806 args.update(dict(key=key, value=value))
802 args.update(dict(key=key, value=value))
807 yield self.t('extra', **args)
803 yield self.t('extra', **args)
@@ -1129,9 +1125,7 b' def walkchangerevs(ui, repo, pats, chang'
1129 for i, window in increasing_windows(0, len(revs)):
1125 for i, window in increasing_windows(0, len(revs)):
1130 yield 'window', revs[0] < revs[-1], revs[-1]
1126 yield 'window', revs[0] < revs[-1], revs[-1]
1131 nrevs = [rev for rev in revs[i:i+window] if want(rev)]
1127 nrevs = [rev for rev in revs[i:i+window] if want(rev)]
1132 srevs = list(nrevs)
1128 for rev in util.sort(list(nrevs)):
1133 srevs.sort()
1134 for rev in srevs:
1135 fns = fncache.get(rev)
1129 fns = fncache.get(rev)
1136 if not fns:
1130 if not fns:
1137 def fns_generator():
1131 def fns_generator():
@@ -1159,7 +1153,7 b' def commit(ui, repo, commitfunc, pats, o'
1159 m = match(repo, pats, opts)
1153 m = match(repo, pats, opts)
1160 if pats:
1154 if pats:
1161 modified, added, removed = repo.status(match=m)[:3]
1155 modified, added, removed = repo.status(match=m)[:3]
1162 files = modified + added + removed
1156 files = util.sort(modified + added + removed)
1163 slist = None
1157 slist = None
1164 for f in m.files():
1158 for f in m.files():
1165 if f == '.':
1159 if f == '.':
@@ -1173,11 +1167,8 b' def commit(ui, repo, commitfunc, pats, o'
1173 raise util.Abort(_("file %s not found!") % rel)
1167 raise util.Abort(_("file %s not found!") % rel)
1174 if stat.S_ISDIR(mode):
1168 if stat.S_ISDIR(mode):
1175 name = f + '/'
1169 name = f + '/'
1176 if slist is None:
1170 i = bisect.bisect(files, name)
1177 slist = list(files)
1171 if i >= len(files) or not files[i].startswith(name):
1178 slist.sort()
1179 i = bisect.bisect(slist, name)
1180 if i >= len(slist) or not slist[i].startswith(name):
1181 raise util.Abort(_("no match under directory %s!")
1172 raise util.Abort(_("no match under directory %s!")
1182 % rel)
1173 % rel)
1183 elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)):
1174 elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)):
@@ -380,9 +380,8 b' def branches(ui, repo, active=False):'
380 hexfunc = ui.debugflag and hex or short
380 hexfunc = ui.debugflag and hex or short
381 activebranches = [util.tolocal(repo[n].branch())
381 activebranches = [util.tolocal(repo[n].branch())
382 for n in repo.heads()]
382 for n in repo.heads()]
383 branches = [(tag in activebranches, repo.changelog.rev(node), tag)
383 branches = util.sort([(tag in activebranches, repo.changelog.rev(node), tag)
384 for tag, node in repo.branchtags().items()]
384 for tag, node in repo.branchtags().items()])
385 branches.sort()
386 branches.reverse()
385 branches.reverse()
387
386
388 for isactive, node, tag in branches:
387 for isactive, node, tag in branches:
@@ -635,9 +634,7 b" def debugcomplete(ui, cmd='', **opts):"
635 ui.write("%s\n" % "\n".join(options))
634 ui.write("%s\n" % "\n".join(options))
636 return
635 return
637
636
638 clist = cmdutil.findpossible(ui, cmd, table).keys()
637 ui.write("%s\n" % "\n".join(util.sort(cmdutil.findpossible(ui, cmd, table))))
639 clist.sort()
640 ui.write("%s\n" % "\n".join(clist))
641
638
642 def debugfsinfo(ui, path = "."):
639 def debugfsinfo(ui, path = "."):
643 file('.debugfsinfo', 'w').write('')
640 file('.debugfsinfo', 'w').write('')
@@ -727,11 +724,9 b' def debugsetparents(ui, repo, rev1, rev2'
727
724
728 def debugstate(ui, repo, nodates=None):
725 def debugstate(ui, repo, nodates=None):
729 """show the contents of the current dirstate"""
726 """show the contents of the current dirstate"""
730 k = repo.dirstate._map.items()
731 k.sort()
732 timestr = ""
727 timestr = ""
733 showdate = not nodates
728 showdate = not nodates
734 for file_, ent in k:
729 for file_, ent in util.sort(repo.dirstate._map.items()):
735 if showdate:
730 if showdate:
736 if ent[3] == -1:
731 if ent[3] == -1:
737 # Pad or slice to locale representation
732 # Pad or slice to locale representation
@@ -1142,9 +1137,7 b' def grep(ui, repo, pattern, *pats, **opt'
1142 except revlog.LookupError:
1137 except revlog.LookupError:
1143 pass
1138 pass
1144 elif st == 'iter':
1139 elif st == 'iter':
1145 states = matches[rev].items()
1140 for fn, m in util.sort(matches[rev].items()):
1146 states.sort()
1147 for fn, m in states:
1148 copy = copies.get(rev, {}).get(fn)
1141 copy = copies.get(rev, {}).get(fn)
1149 if fn in skip:
1142 if fn in skip:
1150 if copy:
1143 if copy:
@@ -1162,9 +1155,7 b' def grep(ui, repo, pattern, *pats, **opt'
1162 fstate[copy] = m
1155 fstate[copy] = m
1163 prev[fn] = rev
1156 prev[fn] = rev
1164
1157
1165 fstate = fstate.items()
1158 for fn, state in util.sort(fstate.items()):
1166 fstate.sort()
1167 for fn, state in fstate:
1168 if fn in skip:
1159 if fn in skip:
1169 continue
1160 continue
1170 if fn not in copies.get(prev[fn], {}):
1161 if fn not in copies.get(prev[fn], {}):
@@ -1304,8 +1295,7 b' def help_(ui, name=None, with_version=Fa'
1304 return
1295 return
1305
1296
1306 ui.status(header)
1297 ui.status(header)
1307 fns = h.keys()
1298 fns = util.sort(h)
1308 fns.sort()
1309 m = max(map(len, fns))
1299 m = max(map(len, fns))
1310 for f in fns:
1300 for f in fns:
1311 if ui.verbose:
1301 if ui.verbose:
@@ -2215,9 +2205,7 b' def remove(ui, repo, *pats, **opts):'
2215 warn(modified, _('is modified'))
2205 warn(modified, _('is modified'))
2216 warn(added, _('has been marked for add'))
2206 warn(added, _('has been marked for add'))
2217
2207
2218 files = remove + forget
2208 for f in util.sort(remove + forget):
2219 files.sort()
2220 for f in files:
2221 if ui.verbose or not m.exact(f):
2209 if ui.verbose or not m.exact(f):
2222 ui.status(_('removing %s\n') % m.rel(f))
2210 ui.status(_('removing %s\n') % m.rel(f))
2223
2211
@@ -2401,10 +2389,7 b' def revert(ui, repo, *pats, **opts):'
2401 (deleted, revert, remove, False, False),
2389 (deleted, revert, remove, False, False),
2402 )
2390 )
2403
2391
2404 entries = names.items()
2392 for abs, (rel, exact) in util.sort(names.items()):
2405 entries.sort()
2406
2407 for abs, (rel, exact) in entries:
2408 mfentry = mf.get(abs)
2393 mfentry = mf.get(abs)
2409 target = repo.wjoin(abs)
2394 target = repo.wjoin(abs)
2410 def handle(xlist, dobackup):
2395 def handle(xlist, dobackup):
@@ -71,9 +71,7 b' class changectx(object):'
71 return self.filectx(key)
71 return self.filectx(key)
72
72
73 def __iter__(self):
73 def __iter__(self):
74 a = self._manifest.keys()
74 for f in util.sort(self._manifest):
75 a.sort()
76 for f in a:
77 yield f
75 yield f
78
76
79 def changeset(self): return self._changeset
77 def changeset(self): return self._changeset
@@ -134,10 +132,7 b' class changectx(object):'
134 def filectxs(self):
132 def filectxs(self):
135 """generate a file context for each file in this changeset's
133 """generate a file context for each file in this changeset's
136 manifest"""
134 manifest"""
137 mf = self.manifest()
135 for f in util.sort(mf):
138 m = mf.keys()
139 m.sort()
140 for f in m:
141 yield self.filectx(f, fileid=mf[f])
136 yield self.filectx(f, fileid=mf[f])
142
137
143 def ancestor(self, c2):
138 def ancestor(self, c2):
@@ -383,12 +378,11 b' class filectx(object):'
383 # sort by revision (per file) which is a topological order
378 # sort by revision (per file) which is a topological order
384 visit = []
379 visit = []
385 for f in files:
380 for f in files:
386 fn = [(n.rev(), n) for n in needed.keys() if n._path == f]
381 fn = [(n.rev(), n) for n in needed if n._path == f]
387 visit.extend(fn)
382 visit.extend(fn)
388 visit.sort()
383
389 hist = {}
384 hist = {}
390
385 for r, f in util.sort(visit):
391 for r, f in visit:
392 curr = decorate(f.data(), f)
386 curr = decorate(f.data(), f)
393 for p in parents(f):
387 for p in parents(f):
394 if p != nullid:
388 if p != nullid:
@@ -530,9 +524,7 b' class workingctx(changectx):'
530 def date(self): return self._date
524 def date(self): return self._date
531 def description(self): return self._text
525 def description(self): return self._text
532 def files(self):
526 def files(self):
533 f = self.modified() + self.added() + self.removed()
527 return util.sort(self._status[0] + self._status[1] + self._status[2])
534 f.sort()
535 return f
536
528
537 def modified(self): return self._status[0]
529 def modified(self): return self._status[0]
538 def added(self): return self._status[1]
530 def added(self): return self._status[1]
@@ -688,8 +680,7 b' class memctx(object):'
688 parents = [(p or nullid) for p in parents]
680 parents = [(p or nullid) for p in parents]
689 p1, p2 = parents
681 p1, p2 = parents
690 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
682 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
691 files = list(files)
683 files = util.sort(list(files))
692 files.sort()
693 self._status = [files, [], [], [], []]
684 self._status = [files, [], [], [], []]
694 self._filectxfn = filectxfn
685 self._filectxfn = filectxfn
695
686
@@ -11,9 +11,7 b' import util, heapq'
11
11
12 def _nonoverlap(d1, d2, d3):
12 def _nonoverlap(d1, d2, d3):
13 "Return list of elements in d1 not in d2 or d3"
13 "Return list of elements in d1 not in d2 or d3"
14 l = [d for d in d1 if d not in d3 and d not in d2]
14 return util.sort([d for d in d1 if d not in d3 and d not in d2])
15 l.sort()
16 return l
17
15
18 def _dirname(f):
16 def _dirname(f):
19 s = f.rfind("/")
17 s = f.rfind("/")
@@ -49,9 +47,7 b' def _findoldnames(fctx, limit):'
49 visit += [(p, depth - 1) for p in fc.parents()]
47 visit += [(p, depth - 1) for p in fc.parents()]
50
48
51 # return old names sorted by depth
49 # return old names sorted by depth
52 old = old.values()
50 return [o[1] for o in util.sort(old.values())]
53 old.sort()
54 return [o[1] for o in old]
55
51
56 def _findlimit(repo, a, b):
52 def _findlimit(repo, a, b):
57 "find the earliest revision that's an ancestor of a or b but not both"
53 "find the earliest revision that's an ancestor of a or b but not both"
@@ -153,9 +153,7 b' class dirstate(object):'
153 return key in self._map
153 return key in self._map
154
154
155 def __iter__(self):
155 def __iter__(self):
156 a = self._map.keys()
156 for x in util.sort(self._map):
157 a.sort()
158 for x in a:
159 yield x
157 yield x
160
158
161 def parents(self):
159 def parents(self):
@@ -436,8 +434,7 b' class dirstate(object):'
436 if not unknown:
434 if not unknown:
437 return ret
435 return ret
438
436
439 b = self._map.keys()
437 b = util.sort(self._map)
440 b.sort()
441 blen = len(b)
438 blen = len(b)
442
439
443 for x in unknown:
440 for x in unknown:
@@ -578,12 +575,10 b' class dirstate(object):'
578 add((nn, 'f', st))
575 add((nn, 'f', st))
579 elif np in dc:
576 elif np in dc:
580 add((nn, 'm', st))
577 add((nn, 'm', st))
581 found.sort()
578 return util.sort(found)
582 return found
583
579
584 # step one, find all files that match our criteria
580 # step one, find all files that match our criteria
585 files.sort()
581 for ff in util.sort(files):
586 for ff in files:
587 nf = normpath(ff)
582 nf = normpath(ff)
588 nn = self.normalize(nf)
583 nn = self.normalize(nf)
589 f = _join(ff)
584 f = _join(ff)
@@ -617,9 +612,7 b' class dirstate(object):'
617
612
618 # step two run through anything left in the dc hash and yield
613 # step two run through anything left in the dc hash and yield
619 # if we haven't already seen it
614 # if we haven't already seen it
620 ks = dc.keys()
615 for k in util.sort(dc):
621 ks.sort()
622 for k in ks:
623 if k in known:
616 if k in known:
624 continue
617 continue
625 known[k] = 1
618 known[k] = 1
@@ -63,8 +63,7 b' def _picktool(repo, ui, path, binary, sy'
63 if t not in tools:
63 if t not in tools:
64 tools[t] = int(_toolstr(ui, t, "priority", "0"))
64 tools[t] = int(_toolstr(ui, t, "priority", "0"))
65 names = tools.keys()
65 names = tools.keys()
66 tools = [(-p,t) for t,p in tools.items()]
66 tools = util.sort([(-p,t) for t,p in tools.items()])
67 tools.sort()
68 uimerge = ui.config("ui", "merge")
67 uimerge = ui.config("ui", "merge")
69 if uimerge:
68 if uimerge:
70 if uimerge not in names:
69 if uimerge not in names:
@@ -60,7 +60,6 b' def bisect(changelog, state):'
60 children[prev] = [rev]
60 children[prev] = [rev]
61 visit.append(prev)
61 visit.append(prev)
62
62
63 candidates.sort()
64 # have we narrowed it down to one entry?
63 # have we narrowed it down to one entry?
65 tot = len(candidates)
64 tot = len(candidates)
66 if tot == 1:
65 if tot == 1:
@@ -71,7 +70,7 b' def bisect(changelog, state):'
71 best_rev = None
70 best_rev = None
72 best_len = -1
71 best_len = -1
73 poison = {}
72 poison = {}
74 for rev in candidates:
73 for rev in util.sort(candidates):
75 if rev in poison:
74 if rev in poison:
76 for c in children.get(rev, []):
75 for c in children.get(rev, []):
77 poison[c] = True # poison children
76 poison[c] = True # poison children
@@ -19,8 +19,8 b' from request import wsgirequest'
19 class hgwebdir(object):
19 class hgwebdir(object):
20 def __init__(self, config, parentui=None):
20 def __init__(self, config, parentui=None):
21 def cleannames(items):
21 def cleannames(items):
22 return [(util.pconvert(name).strip('/'), path)
22 return util.sort([(util.pconvert(name).strip('/'), path)
23 for name, path in items]
23 for name, path in items])
24
24
25 self.parentui = parentui or ui.ui(report_untrusted=False,
25 self.parentui = parentui or ui.ui(report_untrusted=False,
26 interactive = False)
26 interactive = False)
@@ -34,7 +34,6 b' class hgwebdir(object):'
34 self.repos_sorted = ('', False)
34 self.repos_sorted = ('', False)
35 elif isinstance(config, dict):
35 elif isinstance(config, dict):
36 self.repos = cleannames(config.items())
36 self.repos = cleannames(config.items())
37 self.repos.sort()
38 else:
37 else:
39 if isinstance(config, util.configparser):
38 if isinstance(config, util.configparser):
40 cp = config
39 cp = config
@@ -13,7 +13,7 b' from mercurial.util import binary, dates'
13 from mercurial.repo import RepoError
13 from mercurial.repo import RepoError
14 from common import paritygen, staticfile, get_contact, ErrorResponse
14 from common import paritygen, staticfile, get_contact, ErrorResponse
15 from common import HTTP_OK, HTTP_NOT_FOUND
15 from common import HTTP_OK, HTTP_NOT_FOUND
16 from mercurial import graphmod
16 from mercurial import graphmod, util
17
17
18 # __all__ is populated with the allowed commands. Be sure to add to it if
18 # __all__ is populated with the allowed commands. Be sure to add to it if
19 # you're adding a new command, or the new command won't work.
19 # you're adding a new command, or the new command won't work.
@@ -288,9 +288,7 b' def manifest(web, req, tmpl):'
288 raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
288 raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
289
289
290 def filelist(**map):
290 def filelist(**map):
291 fl = files.keys()
291 for f in util.sort(files):
292 fl.sort()
293 for f in fl:
294 full, fnode = files[f]
292 full, fnode = files[f]
295 if not fnode:
293 if not fnode:
296 continue
294 continue
@@ -304,9 +302,7 b' def manifest(web, req, tmpl):'
304 "permissions": mf.flags(full)}
302 "permissions": mf.flags(full)}
305
303
306 def dirlist(**map):
304 def dirlist(**map):
307 fl = files.keys()
305 for f in util.sort(files):
308 fl.sort()
309 for f in fl:
310 full, fnode = files[f]
306 full, fnode = files[f]
311 if fnode:
307 if fnode:
312 continue
308 continue
@@ -378,9 +374,7 b' def summary(web, req, tmpl):'
378
374
379 b = web.repo.branchtags()
375 b = web.repo.branchtags()
380 l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.items()]
376 l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.items()]
381 l.sort()
377 for r,n,t in util.sort(l):
382
383 for r,n,t in l:
384 yield {'parity': parity.next(),
378 yield {'parity': parity.next(),
385 'branch': t,
379 'branch': t,
386 'node': hex(n),
380 'node': hex(n),
@@ -96,10 +96,9 b' def hook(ui, repo, name, throw=False, **'
96 oldstdout = os.dup(sys.__stdout__.fileno())
96 oldstdout = os.dup(sys.__stdout__.fileno())
97 os.dup2(sys.__stderr__.fileno(), sys.__stdout__.fileno())
97 os.dup2(sys.__stderr__.fileno(), sys.__stdout__.fileno())
98
98
99 hooks = [(hname, cmd) for hname, cmd in ui.configitems("hooks")
99 for hname, cmd in util.sort(ui.configitems('hooks')):
100 if hname.split(".", 1)[0] == name and cmd]
100 if hname.split('.')[0] != name or not cmd:
101 hooks.sort()
101 continue
102 for hname, cmd in hooks:
103 if callable(cmd):
102 if callable(cmd):
104 r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r
103 r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r
105 elif cmd.startswith('python:'):
104 elif cmd.startswith('python:'):
@@ -366,8 +366,7 b' class localrepository(repo.repository):'
366 except:
366 except:
367 r = -2 # sort to the beginning of the list if unknown
367 r = -2 # sort to the beginning of the list if unknown
368 l.append((r, t, n))
368 l.append((r, t, n))
369 l.sort()
369 return [(t, n) for r, t, n in util.sort(l)]
370 return [(t, n) for r, t, n in l]
371
370
372 def nodetags(self, node):
371 def nodetags(self, node):
373 '''return the tags associated with a node'''
372 '''return the tags associated with a node'''
@@ -811,7 +810,7 b' class localrepository(repo.repository):'
811 tr = None
810 tr = None
812 valid = 0 # don't save the dirstate if this isn't set
811 valid = 0 # don't save the dirstate if this isn't set
813 try:
812 try:
814 commit = wctx.modified() + wctx.added()
813 commit = util.sort(wctx.modified() + wctx.added())
815 remove = wctx.removed()
814 remove = wctx.removed()
816 extra = wctx.extra().copy()
815 extra = wctx.extra().copy()
817 branchname = extra['branch']
816 branchname = extra['branch']
@@ -844,7 +843,6 b' class localrepository(repo.repository):'
844 new = {}
843 new = {}
845 changed = []
844 changed = []
846 linkrev = len(self)
845 linkrev = len(self)
847 commit.sort()
848 for f in commit:
846 for f in commit:
849 self.ui.note(f + "\n")
847 self.ui.note(f + "\n")
850 try:
848 try:
@@ -871,10 +869,9 b' class localrepository(repo.repository):'
871
869
872 # update manifest
870 # update manifest
873 m1.update(new)
871 m1.update(new)
874 remove.sort()
875 removed = []
872 removed = []
876
873
877 for f in remove:
874 for f in util.sort(remove):
878 if f in m1:
875 if f in m1:
879 del m1[f]
876 del m1[f]
880 removed.append(f)
877 removed.append(f)
@@ -950,10 +947,7 b' class localrepository(repo.repository):'
950 # for dirstate.walk, files=['.'] means "walk the whole tree".
947 # for dirstate.walk, files=['.'] means "walk the whole tree".
951 # follow that here, too
948 # follow that here, too
952 fdict.pop('.', None)
949 fdict.pop('.', None)
953 mdict = self.manifest.read(self.changelog.read(node)[0])
950 for fn in self[node]:
954 mfiles = mdict.keys()
955 mfiles.sort()
956 for fn in mfiles:
957 for ffn in fdict:
951 for ffn in fdict:
958 # match if the file is the exact name or a directory
952 # match if the file is the exact name or a directory
959 if ffn == fn or fn.startswith("%s/" % ffn):
953 if ffn == fn or fn.startswith("%s/" % ffn):
@@ -961,9 +955,7 b' class localrepository(repo.repository):'
961 break
955 break
962 if match(fn):
956 if match(fn):
963 yield fn
957 yield fn
964 ffiles = fdict.keys()
958 for fn in util.sort(fdict):
965 ffiles.sort()
966 for fn in ffiles:
967 if match.bad(fn, 'No such file in rev ' + short(node)) \
959 if match.bad(fn, 'No such file in rev ' + short(node)) \
968 and match(fn):
960 and match(fn):
969 yield fn
961 yield fn
@@ -1065,10 +1057,8 b' class localrepository(repo.repository):'
1065
1057
1066 # make sure to sort the files so we talk to the disk in a
1058 # make sure to sort the files so we talk to the disk in a
1067 # reasonable order
1059 # reasonable order
1068 mf2keys = mf2.keys()
1069 mf2keys.sort()
1070 getnode = lambda fn: mf1.get(fn, nullid)
1060 getnode = lambda fn: mf1.get(fn, nullid)
1071 for fn in mf2keys:
1061 for fn in util.sort(mf2):
1072 if fn in mf1:
1062 if fn in mf1:
1073 if (mf1.flags(fn) != mf2.flags(fn) or
1063 if (mf1.flags(fn) != mf2.flags(fn) or
1074 (mf1[fn] != mf2[fn] and
1064 (mf1[fn] != mf2[fn] and
@@ -1190,8 +1180,7 b' class localrepository(repo.repository):'
1190 heads = self.changelog.heads(start)
1180 heads = self.changelog.heads(start)
1191 # sort the output in rev descending order
1181 # sort the output in rev descending order
1192 heads = [(-self.changelog.rev(h), h) for h in heads]
1182 heads = [(-self.changelog.rev(h), h) for h in heads]
1193 heads.sort()
1183 return [n for (r, n) in util.sort(heads)]
1194 return [n for (r, n) in heads]
1195
1184
1196 def branchheads(self, branch=None, start=None):
1185 def branchheads(self, branch=None, start=None):
1197 if branch is None:
1186 if branch is None:
@@ -1843,10 +1832,8 b' class localrepository(repo.repository):'
1843 add_extra_nodes(fname,
1832 add_extra_nodes(fname,
1844 msng_filenode_set.setdefault(fname, {}))
1833 msng_filenode_set.setdefault(fname, {}))
1845 changedfiles[fname] = 1
1834 changedfiles[fname] = 1
1846 changedfiles = changedfiles.keys()
1847 changedfiles.sort()
1848 # Go through all our files in order sorted by name.
1835 # Go through all our files in order sorted by name.
1849 for fname in changedfiles:
1836 for fname in util.sort(changedfiles):
1850 filerevlog = self.file(fname)
1837 filerevlog = self.file(fname)
1851 if not len(filerevlog):
1838 if not len(filerevlog):
1852 raise util.Abort(_("empty or missing revlog for %s") % fname)
1839 raise util.Abort(_("empty or missing revlog for %s") % fname)
@@ -1924,15 +1911,13 b' class localrepository(repo.repository):'
1924 for chnk in cl.group(nodes, identity,
1911 for chnk in cl.group(nodes, identity,
1925 changed_file_collector(changedfiles)):
1912 changed_file_collector(changedfiles)):
1926 yield chnk
1913 yield chnk
1927 changedfiles = changedfiles.keys()
1928 changedfiles.sort()
1929
1914
1930 mnfst = self.manifest
1915 mnfst = self.manifest
1931 nodeiter = gennodelst(mnfst)
1916 nodeiter = gennodelst(mnfst)
1932 for chnk in mnfst.group(nodeiter, lookuprevlink_func(mnfst)):
1917 for chnk in mnfst.group(nodeiter, lookuprevlink_func(mnfst)):
1933 yield chnk
1918 yield chnk
1934
1919
1935 for fname in changedfiles:
1920 for fname in util.sort(changedfiles):
1936 filerevlog = self.file(fname)
1921 filerevlog = self.file(fname)
1937 if not len(filerevlog):
1922 if not len(filerevlog):
1938 raise util.Abort(_("empty or missing revlog for %s") % fname)
1923 raise util.Abort(_("empty or missing revlog for %s") % fname)
@@ -8,7 +8,7 b''
8 from node import bin, hex, nullid
8 from node import bin, hex, nullid
9 from revlog import revlog, RevlogError
9 from revlog import revlog, RevlogError
10 from i18n import _
10 from i18n import _
11 import array, struct, mdiff, parsers
11 import array, struct, mdiff, parsers, util
12
12
13 class manifestdict(dict):
13 class manifestdict(dict):
14 def __init__(self, mapping=None, flags=None):
14 def __init__(self, mapping=None, flags=None):
@@ -126,9 +126,7 b' class manifest(revlog):'
126 # if we're using the listcache, make sure it is valid and
126 # if we're using the listcache, make sure it is valid and
127 # parented by the same node we're diffing against
127 # parented by the same node we're diffing against
128 if not (changed and self.listcache and p1 and self.mapcache[0] == p1):
128 if not (changed and self.listcache and p1 and self.mapcache[0] == p1):
129 files = map.keys()
129 files = util.sort(map)
130 files.sort()
131
132 for f in files:
130 for f in files:
133 checkforbidden(f)
131 checkforbidden(f)
134
132
@@ -262,11 +262,10 b' def applyupdates(repo, action, wctx, mct'
262 "apply the merge action list to the working directory"
262 "apply the merge action list to the working directory"
263
263
264 updated, merged, removed, unresolved = 0, 0, 0, 0
264 updated, merged, removed, unresolved = 0, 0, 0, 0
265 action.sort()
266
267 ms = mergestate(repo)
265 ms = mergestate(repo)
268 ms.reset(wctx.parents()[0].node())
266 ms.reset(wctx.parents()[0].node())
269 moves = []
267 moves = []
268 action.sort()
270
269
271 # prescan for merges
270 # prescan for merges
272 for a in action:
271 for a in action:
@@ -1094,8 +1094,7 b' def updatedir(ui, repo, patches):'
1094 repo.copy(src, dst)
1094 repo.copy(src, dst)
1095 removes = removes.keys()
1095 removes = removes.keys()
1096 if removes:
1096 if removes:
1097 removes.sort()
1097 repo.remove(util.sort(removes), True)
1098 repo.remove(removes, True)
1099 for f in patches:
1098 for f in patches:
1100 ctype, gp = patches[f]
1099 ctype, gp = patches[f]
1101 if gp and gp.mode:
1100 if gp and gp.mode:
@@ -1113,9 +1112,7 b' def updatedir(ui, repo, patches):'
1113 cmdutil.addremove(repo, cfiles)
1112 cmdutil.addremove(repo, cfiles)
1114 files = patches.keys()
1113 files = patches.keys()
1115 files.extend([r for r in removes if r not in files])
1114 files.extend([r for r in removes if r not in files])
1116 files.sort()
1115 return util.sort(files)
1117
1118 return files
1119
1116
1120 def b85diff(to, tn):
1117 def b85diff(to, tn):
1121 '''print base85-encoded binary diff'''
1118 '''print base85-encoded binary diff'''
@@ -1208,13 +1205,10 b' def diff(repo, node1=None, node2=None, m'
1208 for k, v in copy.items():
1205 for k, v in copy.items():
1209 copy[v] = k
1206 copy[v] = k
1210
1207
1211 all = modified + added + removed
1212 all.sort()
1213 gone = {}
1208 gone = {}
1214
1215 gitmode = {'l': '120000', 'x': '100755', '': '100644'}
1209 gitmode = {'l': '120000', 'x': '100755', '': '100644'}
1216
1210
1217 for f in all:
1211 for f in util.sort(modified + added + removed):
1218 to = None
1212 to = None
1219 tn = None
1213 tn = None
1220 dodiff = True
1214 dodiff = True
@@ -34,8 +34,7 b' def walkrepo(root):'
34 for x in walk(os.path.join(root, 'data'), True):
34 for x in walk(os.path.join(root, 'data'), True):
35 yield x
35 yield x
36 # write manifest before changelog
36 # write manifest before changelog
37 meta = list(walk(root, False))
37 meta = util.sort(walk(root, False))
38 meta.sort()
39 meta.reverse()
38 meta.reverse()
40 for x in meta:
39 for x in meta:
41 yield x
40 yield x
@@ -312,15 +312,11 b' class ui(object):'
312 items = self._configitems(section, untrusted=untrusted, abort=True)
312 items = self._configitems(section, untrusted=untrusted, abort=True)
313 if self.debugflag and not untrusted and self.ucdata:
313 if self.debugflag and not untrusted and self.ucdata:
314 uitems = self._configitems(section, untrusted=True, abort=False)
314 uitems = self._configitems(section, untrusted=True, abort=False)
315 keys = uitems.keys()
315 for k in util.sort(uitems):
316 keys.sort()
317 for k in keys:
318 if uitems[k] != items.get(k):
316 if uitems[k] != items.get(k):
319 self.warn(_("Ignoring untrusted configuration option "
317 self.warn(_("Ignoring untrusted configuration option "
320 "%s.%s = %s\n") % (section, k, uitems[k]))
318 "%s.%s = %s\n") % (section, k, uitems[k]))
321 x = items.items()
319 return util.sort(items.items())
322 x.sort()
323 return x
324
320
325 def walkconfig(self, untrusted=False):
321 def walkconfig(self, untrusted=False):
326 cdata = self._get_cdata(untrusted)
322 cdata = self._get_cdata(untrusted)
@@ -252,6 +252,12 b' def unique(g):'
252 """return the uniq elements of iterable g"""
252 """return the uniq elements of iterable g"""
253 return dict.fromkeys(g).keys()
253 return dict.fromkeys(g).keys()
254
254
255 def sort(l):
256 if not isinstance(l, list):
257 l = list(l)
258 l.sort()
259 return l
260
255 class Abort(Exception):
261 class Abort(Exception):
256 """Raised if a command needs to print an error and exit."""
262 """Raised if a command needs to print an error and exit."""
257
263
@@ -7,7 +7,7 b''
7
7
8 from node import nullid, short
8 from node import nullid, short
9 from i18n import _
9 from i18n import _
10 import revlog
10 import revlog, util
11
11
12 def verify(repo):
12 def verify(repo):
13 lock = repo.lock()
13 lock = repo.lock()
@@ -139,38 +139,26 b' def _verify(repo):'
139 ui.status(_("crosschecking files in changesets and manifests\n"))
139 ui.status(_("crosschecking files in changesets and manifests\n"))
140
140
141 if havemf:
141 if havemf:
142 nm = []
142 for c, m in util.sort([(c, m) for m in mflinkrevs for c in mflinkrevs[m]]):
143 for m in mflinkrevs:
144 for c in mflinkrevs[m]:
145 nm.append((c, m))
146 nm.sort()
147 for c, m in nm:
148 err(c, _("changeset refers to unknown manifest %s") % short(m))
143 err(c, _("changeset refers to unknown manifest %s") % short(m))
149 del mflinkrevs, nm
144 del mflinkrevs
150
145
151 fl = filelinkrevs.keys()
146 for f in util.sort(filelinkrevs):
152 fl.sort()
153 for f in fl:
154 if f not in filenodes:
147 if f not in filenodes:
155 lr = filelinkrevs[f][0]
148 lr = filelinkrevs[f][0]
156 err(lr, _("in changeset but not in manifest"), f)
149 err(lr, _("in changeset but not in manifest"), f)
157 del fl
158
150
159 if havecl:
151 if havecl:
160 fl = filenodes.keys()
152 for f in util.sort(filenodes):
161 fl.sort()
162 for f in fl:
163 if f not in filelinkrevs:
153 if f not in filelinkrevs:
164 try:
154 try:
165 lr = min([repo.file(f).linkrev(n) for n in filenodes[f]])
155 lr = min([repo.file(f).linkrev(n) for n in filenodes[f]])
166 except:
156 except:
167 lr = None
157 lr = None
168 err(lr, _("in manifest but not in changeset"), f)
158 err(lr, _("in manifest but not in changeset"), f)
169 del fl
170
159
171 ui.status(_("checking files\n"))
160 ui.status(_("checking files\n"))
172 files = dict.fromkeys(filenodes.keys() + filelinkrevs.keys()).keys()
161 files = util.sort(util.unique(filenodes.keys() + filelinkrevs.keys()))
173 files.sort()
174 for f in files:
162 for f in files:
175 fl = repo.file(f)
163 fl = repo.file(f)
176 checklog(fl, f)
164 checklog(fl, f)
@@ -214,8 +202,7 b' def _verify(repo):'
214 # cross-check
202 # cross-check
215 if f in filenodes:
203 if f in filenodes:
216 fns = [(mf.linkrev(l), n) for n,l in filenodes[f].items()]
204 fns = [(mf.linkrev(l), n) for n,l in filenodes[f].items()]
217 fns.sort()
205 for lr, node in util.sort(fns):
218 for lr, node in fns:
219 err(lr, _("%s in manifests not found") % short(node), f)
206 err(lr, _("%s in manifests not found") % short(node), f)
220
207
221 ui.status(_("%d files, %d changesets, %d total revisions\n") %
208 ui.status(_("%d files, %d changesets, %d total revisions\n") %
General Comments 0
You need to be logged in to leave comments. Login now