equal
deleted
inserted
replaced
1167 # i18n: "limit" is a keyword |
1167 # i18n: "limit" is a keyword |
1168 ofs = getinteger(args.get('offset'), _("limit expects a number"), default=0) |
1168 ofs = getinteger(args.get('offset'), _("limit expects a number"), default=0) |
1169 if ofs < 0: |
1169 if ofs < 0: |
1170 raise error.ParseError(_("negative offset")) |
1170 raise error.ParseError(_("negative offset")) |
1171 os = getset(repo, fullreposet(repo), args['set']) |
1171 os = getset(repo, fullreposet(repo), args['set']) |
1172 result = [] |
1172 ls = os.slice(ofs, ofs + lim) |
1173 it = iter(os) |
|
1174 for x in xrange(ofs): |
|
1175 y = next(it, None) |
|
1176 if y is None: |
|
1177 break |
|
1178 for x in xrange(lim): |
|
1179 y = next(it, None) |
|
1180 if y is None: |
|
1181 break |
|
1182 result.append(y) |
|
1183 ls = baseset(result, datarepr=('<limit n=%d, offset=%d, %r>', lim, ofs, os)) |
|
1184 if order == followorder and lim > 1: |
1173 if order == followorder and lim > 1: |
1185 return subset & ls |
1174 return subset & ls |
1186 return ls & subset |
1175 return ls & subset |
1187 |
1176 |
1188 @predicate('last(set, [n])', safe=True, takeorder=True) |
1177 @predicate('last(set, [n])', safe=True, takeorder=True) |
1197 lim = getinteger(l[1], _("last expects a number")) |
1186 lim = getinteger(l[1], _("last expects a number")) |
1198 if lim < 0: |
1187 if lim < 0: |
1199 raise error.ParseError(_("negative number to select")) |
1188 raise error.ParseError(_("negative number to select")) |
1200 os = getset(repo, fullreposet(repo), l[0]) |
1189 os = getset(repo, fullreposet(repo), l[0]) |
1201 os.reverse() |
1190 os.reverse() |
1202 result = [] |
1191 ls = os.slice(0, lim) |
1203 it = iter(os) |
|
1204 for x in xrange(lim): |
|
1205 y = next(it, None) |
|
1206 if y is None: |
|
1207 break |
|
1208 result.append(y) |
|
1209 ls = baseset(result, datarepr=('<last n=%d, %r>', lim, os)) |
|
1210 if order == followorder and lim > 1: |
1192 if order == followorder and lim > 1: |
1211 return subset & ls |
1193 return subset & ls |
1212 ls.reverse() |
1194 ls.reverse() |
1213 return ls & subset |
1195 return ls & subset |
1214 |
1196 |