comparison mercurial/revset.py @ 25145:3553163bb736

revset: use 'next()' to detect end of iteration in 'last' The 'next()' built-in can return a default value, allow to get rid of the confusing try/except code flow.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sun, 17 May 2015 18:00:38 -0700
parents 81a395447b34
children f542a2c89b60
comparison
equal deleted inserted replaced
25144:81a395447b34 25145:3553163bb736
1170 os = getset(repo, fullreposet(repo), l[0]) 1170 os = getset(repo, fullreposet(repo), l[0])
1171 os.reverse() 1171 os.reverse()
1172 result = [] 1172 result = []
1173 it = iter(os) 1173 it = iter(os)
1174 for x in xrange(lim): 1174 for x in xrange(lim):
1175 try: 1175 y = next(it, None)
1176 y = it.next() 1176 if y is None:
1177 if y in ss:
1178 result.append(y)
1179 except (StopIteration):
1180 break 1177 break
1178 elif y in ss:
1179 result.append(y)
1181 return baseset(result) 1180 return baseset(result)
1182 1181
1183 def maxrev(repo, subset, x): 1182 def maxrev(repo, subset, x):
1184 """``max(set)`` 1183 """``max(set)``
1185 Changeset with highest revision number in set. 1184 Changeset with highest revision number in set.