Show More
@@ -1284,24 +1284,33 b' def keyword(repo, subset, x):' | |||
|
1284 | 1284 | return subset.filter(matches) |
|
1285 | 1285 | |
|
1286 | 1286 | def limit(repo, subset, x): |
|
1287 |
"""``limit(set |
|
|
1288 | First n members of set, defaulting to 1. | |
|
1287 | """``limit(set[, n[, offset]])`` | |
|
1288 | First n members of set, defaulting to 1, starting from offset. | |
|
1289 | 1289 | """ |
|
1290 | args = getargsdict(x, 'limit', 'set n') | |
|
1290 | args = getargsdict(x, 'limit', 'set n offset') | |
|
1291 | 1291 | if 'set' not in args: |
|
1292 | 1292 | # i18n: "limit" is a keyword |
|
1293 |
raise error.ParseError(_("limit requires one |
|
|
1293 | raise error.ParseError(_("limit requires one to three arguments")) | |
|
1294 | 1294 | try: |
|
1295 | lim = 1 | |
|
1295 | lim, ofs = 1, 0 | |
|
1296 | 1296 | if 'n' in args: |
|
1297 | 1297 | # i18n: "limit" is a keyword |
|
1298 | 1298 | lim = int(getstring(args['n'], _("limit requires a number"))) |
|
1299 | if 'offset' in args: | |
|
1300 | # i18n: "limit" is a keyword | |
|
1301 | ofs = int(getstring(args['offset'], _("limit requires a number"))) | |
|
1302 | if ofs < 0: | |
|
1303 | raise error.ParseError(_("negative offset")) | |
|
1299 | 1304 | except (TypeError, ValueError): |
|
1300 | 1305 | # i18n: "limit" is a keyword |
|
1301 | 1306 | raise error.ParseError(_("limit expects a number")) |
|
1302 | 1307 | os = getset(repo, fullreposet(repo), args['set']) |
|
1303 | 1308 | result = [] |
|
1304 | 1309 | it = iter(os) |
|
1310 | for x in xrange(ofs): | |
|
1311 | y = next(it, None) | |
|
1312 | if y is None: | |
|
1313 | break | |
|
1305 | 1314 | for x in xrange(lim): |
|
1306 | 1315 | y = next(it, None) |
|
1307 | 1316 | if y is None: |
@@ -566,6 +566,16 b' test ancestors' | |||
|
566 | 566 | $ log 'keyword("test a")' |
|
567 | 567 | $ log 'limit(head(), 1)' |
|
568 | 568 | 0 |
|
569 | $ log 'limit(author("re:bob|test"), 3, 5)' | |
|
570 | 5 | |
|
571 | 6 | |
|
572 | 7 | |
|
573 | $ log 'limit(author("re:bob|test"), offset=6)' | |
|
574 | 6 | |
|
575 | $ log 'limit(author("re:bob|test"), offset=10)' | |
|
576 | $ log 'limit(all(), 1, -1)' | |
|
577 | hg: parse error: negative offset | |
|
578 | [255] | |
|
569 | 579 | $ log 'matching(6)' |
|
570 | 580 | 6 |
|
571 | 581 | $ log 'matching(6:7, "phase parents user date branch summary files description substate")' |
General Comments 0
You need to be logged in to leave comments.
Login now