Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 8209:a1a5a57efe90
replace util.sort with sorted built-in
This is marginally faster for small and moderately-sized lists
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 26 Apr 2009 16:50:44 -0500 |
parents | d2899a856f9f |
children | 344751cd8cb8 |
comparison
equal
deleted
inserted
replaced
8208:32a2a1e244f1 | 8209:a1a5a57efe90 |
---|---|
663 if copies and self.ui.verbose: | 663 if copies and self.ui.verbose: |
664 copies = ['%s (%s)' % c for c in copies] | 664 copies = ['%s (%s)' % c for c in copies] |
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 |
672 description = changes[4].strip() | 672 description = changes[4].strip() |
673 if description: | 673 if description: |
814 | 814 |
815 def showtags(**args): | 815 def showtags(**args): |
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) |
823 | 823 |
824 def showcopies(**args): | 824 def showcopies(**args): |
1161 return rev in wanted | 1161 return rev in wanted |
1162 | 1162 |
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(): |
1170 for f in change(rev)[3]: | 1170 for f in change(rev)[3]: |
1171 if m(f): | 1171 if m(f): |
1189 addremove(repo, pats, opts) | 1189 addremove(repo, pats, opts) |
1190 | 1190 |
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 + '/' |
1198 i = bisect.bisect(files, name) | 1198 i = bisect.bisect(files, name) |
1199 return i < len(files) and files[i].startswith(name) | 1199 return i < len(files) and files[i].startswith(name) |