Mercurial > hg-stable
diff mercurial/patch.py @ 9032:1fa80c5428b8
compat: use 'key' argument instead of 'cmp' when sorting a list
author | Alejandro Santos <alejolp@alejolp.com> |
---|---|
date | Sun, 05 Jul 2009 11:02:00 +0200 |
parents | 3b76321aa0de |
children | 6d1f9238824e |
line wrap: on
line diff
--- a/mercurial/patch.py Sun Jul 05 11:01:30 2009 +0200 +++ b/mercurial/patch.py Sun Jul 05 11:02:00 2009 +0200 @@ -325,10 +325,6 @@ # looks through the hash and finds candidate lines. The # result is a list of line numbers sorted based on distance # from linenum - def sorter(a, b): - vala = abs(a - linenum) - valb = abs(b - linenum) - return cmp(vala, valb) try: cand = self.hash[l] @@ -337,7 +333,7 @@ if len(cand) > 1: # resort our list of potentials forward then back. - cand.sort(sorter) + cand.sort(key=lambda x: abs(x - linenum)) return cand def hashlines(self):