histedit: max(x, key=y) and min(x, key=y) are not available in python 2.4
authorThomas Arendsen Hein <thomas@intevation.de>
Tue, 16 Oct 2012 16:04:28 +0200
changeset 17769 8672e615d81c
parent 17768 9837cafc25b1
child 17770 6c81b8ebf66e
histedit: max(x, key=y) and min(x, key=y) are not available in python 2.4 Use sorted(x, key=y)[-1] or sorted(x, key=y)[0] instead.
hgext/histedit.py
--- a/hgext/histedit.py	Sat Oct 13 15:10:39 2012 -0500
+++ b/hgext/histedit.py	Tue Oct 16 16:04:28 2012 +0200
@@ -701,14 +701,14 @@
 
     # computed topmost element (necessary for bookmark)
     if new:
-        newtopmost = max(new, key=repo.changelog.rev)
+        newtopmost = sorted(new, key=repo.changelog.rev)[-1]
     elif not final:
         # Nothing rewritten at all. we won't need `newtopmost`
         # It is the same as `oldtopmost` and `processreplacement` know it
         newtopmost = None
     else:
         # every body died. The newtopmost is the parent of the root.
-        newtopmost = repo[min(final, key=repo.changelog.rev)].p1().node()
+        newtopmost = repo[sorted(final, key=repo.changelog.rev)[0]].p1().node()
 
     return final, tmpnodes, new, newtopmost