Show More
@@ -143,8 +143,8 b' def churn(ui, repo, *pats, **opts):' | |||
|
143 | 143 | if not rate: |
|
144 | 144 | return |
|
145 | 145 | |
|
146 |
sort |
|
|
147 |
rate.sort( |
|
|
146 | sortkey = ((not opts.get('sort')) and (lambda x: -x[1]) or None) | |
|
147 | rate.sort(key=sortkey) | |
|
148 | 148 | |
|
149 | 149 | maxcount = float(max([v for k, v in rate])) |
|
150 | 150 | maxname = max([len(k) for k, v in rate]) |
@@ -12,13 +12,6 b' import cPickle as pickle' | |||
|
12 | 12 | from mercurial import util |
|
13 | 13 | from mercurial.i18n import _ |
|
14 | 14 | |
|
15 | def listsort(list, key): | |
|
16 | "helper to sort by key in Python 2.3" | |
|
17 | try: | |
|
18 | list.sort(key=key) | |
|
19 | except TypeError: | |
|
20 | list.sort(lambda l, r: cmp(key(l), key(r))) | |
|
21 | ||
|
22 | 15 | class logentry(object): |
|
23 | 16 | '''Class logentry has the following attributes: |
|
24 | 17 | .author - author name as CVS knows it |
@@ -419,7 +412,7 b' def createlog(ui, directory=None, root="' | |||
|
419 | 412 | if len(log) % 100 == 0: |
|
420 | 413 | ui.status(util.ellipsis('%d %s' % (len(log), e.file), 80)+'\n') |
|
421 | 414 | |
|
422 |
l |
|
|
415 | log.sort(key=lambda x: (x.rcs, x.revision)) | |
|
423 | 416 | |
|
424 | 417 | # find parent revisions of individual files |
|
425 | 418 | versions = {} |
@@ -435,7 +428,7 b' def createlog(ui, directory=None, root="' | |||
|
435 | 428 | if cache: |
|
436 | 429 | if log: |
|
437 | 430 | # join up the old and new logs |
|
438 |
l |
|
|
431 | log.sort(key=lambda x: x.date) | |
|
439 | 432 | |
|
440 | 433 | if oldlog and oldlog[-1].date >= log[0].date: |
|
441 | 434 | raise logerror('Log cache overlaps with new log entries,' |
@@ -484,7 +477,7 b' def createchangeset(ui, log, fuzz=60, me' | |||
|
484 | 477 | |
|
485 | 478 | # Merge changesets |
|
486 | 479 | |
|
487 |
l |
|
|
480 | log.sort(key=lambda x: (x.comment, x.author, x.branch, x.date)) | |
|
488 | 481 | |
|
489 | 482 | changesets = [] |
|
490 | 483 | files = set() |
@@ -1541,7 +1541,7 b' class queue(object):' | |||
|
1541 | 1541 | raise util.Abort(_('option "-r" not valid when importing ' |
|
1542 | 1542 | 'files')) |
|
1543 | 1543 | rev = cmdutil.revrange(repo, rev) |
|
1544 | rev.sort(lambda x, y: cmp(y, x)) | |
|
1544 | rev.sort(reverse=True) | |
|
1545 | 1545 | if (len(files) > 1 or len(rev) > 1) and patchname: |
|
1546 | 1546 | raise util.Abort(_('option "-n" not valid when importing multiple ' |
|
1547 | 1547 | 'patches')) |
@@ -2334,7 +2334,7 b' def select(ui, repo, *args, **opts):' | |||
|
2334 | 2334 | if ui.verbose: |
|
2335 | 2335 | guards['NONE'] = noguards |
|
2336 | 2336 | guards = guards.items() |
|
2337 |
guards.sort(lambda |
|
|
2337 | guards.sort(key=lambda x: x[0][1:]) | |
|
2338 | 2338 | if guards: |
|
2339 | 2339 | ui.note(_('guards in series file:\n')) |
|
2340 | 2340 | for guard, count in guards: |
@@ -1709,14 +1709,14 b' class localrepository(repo.repository):' | |||
|
1709 | 1709 | |
|
1710 | 1710 | # A function generating function. Sets up an environment for the |
|
1711 | 1711 | # inner function. |
|
1712 |
def |
|
|
1713 |
# |
|
|
1712 | def revkey(revlog): | |
|
1713 | # Key to sort a node by it's revision number in the environment's | |
|
1714 | 1714 | # revision history. Since the revision number both represents the |
|
1715 | 1715 | # most efficient order to read the nodes in, and represents a |
|
1716 | 1716 | # topological sorting of the nodes, this function is often useful. |
|
1717 |
def |
|
|
1718 |
return |
|
|
1719 |
return |
|
|
1717 | def revlog_sort_key(x): | |
|
1718 | return revlog.rev(x) | |
|
1719 | return revlog_sort_key | |
|
1720 | 1720 | |
|
1721 | 1721 | # If we determine that a particular file or manifest node must be a |
|
1722 | 1722 | # node that the recipient of the changegroup will already have, we can |
@@ -1724,7 +1724,7 b' class localrepository(repo.repository):' | |||
|
1724 | 1724 | # prunes them from the set of missing nodes. |
|
1725 | 1725 | def prune_parents(revlog, hasset, msngset): |
|
1726 | 1726 | haslst = list(hasset) |
|
1727 |
haslst.sort( |
|
|
1727 | haslst.sort(key=revkey(revlog)) | |
|
1728 | 1728 | for node in haslst: |
|
1729 | 1729 | parentlst = [p for p in revlog.parents(node) if p != nullid] |
|
1730 | 1730 | while parentlst: |
@@ -1874,7 +1874,7 b' class localrepository(repo.repository):' | |||
|
1874 | 1874 | add_extra_nodes(1, msng_mnfst_set) |
|
1875 | 1875 | msng_mnfst_lst = msng_mnfst_set.keys() |
|
1876 | 1876 | # Sort the manifestnodes by revision number. |
|
1877 |
msng_mnfst_lst.sort( |
|
|
1877 | msng_mnfst_lst.sort(key=revkey(mnfst)) | |
|
1878 | 1878 | # Create a generator for the manifestnodes that calls our lookup |
|
1879 | 1879 | # and data collection functions back. |
|
1880 | 1880 | group = mnfst.group(msng_mnfst_lst, lookup_manifest_link, |
@@ -1912,7 +1912,7 b' class localrepository(repo.repository):' | |||
|
1912 | 1912 | yield changegroup.chunkheader(len(fname)) |
|
1913 | 1913 | yield fname |
|
1914 | 1914 | # Sort the filenodes by their revision # |
|
1915 |
msng_filenode_lst.sort( |
|
|
1915 | msng_filenode_lst.sort(key=revkey(filerevlog)) | |
|
1916 | 1916 | # Create a group generator and only pass in a changenode |
|
1917 | 1917 | # lookup function as we need to collect no information |
|
1918 | 1918 | # from filenodes. |
@@ -26,12 +26,10 b' class Stats(object):' | |||
|
26 | 26 | """XXX docstring""" |
|
27 | 27 | if crit not in profiler_entry.__dict__: |
|
28 | 28 | raise ValueError("Can't sort by %s" % crit) |
|
29 |
self.data.sort(lambda |
|
|
30 | getattr(b, crit))) | |
|
29 | self.data.sort(key=lambda x: getattr(x, crit), reverse=True) | |
|
31 | 30 | for e in self.data: |
|
32 | 31 | if e.calls: |
|
33 |
e.calls.sort(lambda |
|
|
34 | getattr(b, crit))) | |
|
32 | e.calls.sort(key=lambda x: getattr(x, crit), reverse=True) | |
|
35 | 33 | |
|
36 | 34 | def pprint(self, top=None, file=None, limit=None, climit=None): |
|
37 | 35 | """XXX docstring""" |
@@ -325,10 +325,6 b' class patchfile(object):' | |||
|
325 | 325 | # looks through the hash and finds candidate lines. The |
|
326 | 326 | # result is a list of line numbers sorted based on distance |
|
327 | 327 | # from linenum |
|
328 | def sorter(a, b): | |
|
329 | vala = abs(a - linenum) | |
|
330 | valb = abs(b - linenum) | |
|
331 | return cmp(vala, valb) | |
|
332 | 328 | |
|
333 | 329 | try: |
|
334 | 330 | cand = self.hash[l] |
@@ -337,7 +333,7 b' class patchfile(object):' | |||
|
337 | 333 | |
|
338 | 334 | if len(cand) > 1: |
|
339 | 335 | # resort our list of potentials forward then back. |
|
340 |
cand.sort( |
|
|
336 | cand.sort(key=lambda x: abs(x - linenum)) | |
|
341 | 337 | return cand |
|
342 | 338 | |
|
343 | 339 | def hashlines(self): |
General Comments 0
You need to be logged in to leave comments.
Login now