Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revset.py @ 32838:4710cc4dac99
smartset: extract method to slice abstractsmartset
Sub classes can provide optimized implementations.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 24 Mar 2015 00:14:53 +0900 |
parents | 348b491c0934 |
children | 8e02829bec61 |
line wrap: on
line diff
--- a/mercurial/revset.py Sun May 24 11:07:14 2015 +0900 +++ b/mercurial/revset.py Tue Mar 24 00:14:53 2015 +0900 @@ -1169,18 +1169,7 @@ if ofs < 0: raise error.ParseError(_("negative offset")) os = getset(repo, fullreposet(repo), args['set']) - result = [] - it = iter(os) - for x in xrange(ofs): - y = next(it, None) - if y is None: - break - for x in xrange(lim): - y = next(it, None) - if y is None: - break - result.append(y) - ls = baseset(result, datarepr=('<limit n=%d, offset=%d, %r>', lim, ofs, os)) + ls = os.slice(ofs, ofs + lim) if order == followorder and lim > 1: return subset & ls return ls & subset @@ -1199,14 +1188,7 @@ raise error.ParseError(_("negative number to select")) os = getset(repo, fullreposet(repo), l[0]) os.reverse() - result = [] - it = iter(os) - for x in xrange(lim): - y = next(it, None) - if y is None: - break - result.append(y) - ls = baseset(result, datarepr=('<last n=%d, %r>', lim, os)) + ls = os.slice(0, lim) if order == followorder and lim > 1: return subset & ls ls.reverse()