churn: py2.3 compatibility fix
authorAlexander Solovyov <piranha@piranha.org.ua>
Fri, 10 Oct 2008 15:53:49 +0300
changeset 7076 c29d3f4ed967
parent 7075 6db6f6db026a
child 7077 ccbd39cad3c3
churn: py2.3 compatibility fix - generator expressions appeared in py2.4 - sort doesn't have any arguments except sorting function
hgext/churn.py
--- a/hgext/churn.py	Fri Oct 10 13:20:40 2008 +0200
+++ b/hgext/churn.py	Fri Oct 10 15:53:49 2008 +0300
@@ -153,11 +153,11 @@
     if not rate:
         return
 
-    keyfn = (not opts.get('sort')) and (lambda (k,v): (v,k)) or None
-    rate.sort(key=keyfn, reverse=not opts.get('sort'))
+    sortfn = ((not opts.get('sort')) and (lambda a, b: cmp(b[1], a[1])) or None)
+    rate.sort(sortfn)
 
-    maxcount = float(max(v for k, v in rate))
-    maxname = max(len(k) for k, v in rate)
+    maxcount = float(max([v for k, v in rate]))
+    maxname = max([len(k) for k, v in rate])
 
     ttywidth = get_tty_width()
     ui.debug(_("assuming %i character terminal\n") % ttywidth)