Show More
@@ -312,6 +312,12 b' def getstring(x, err):' | |||||
312 | return x[1] |
|
312 | return x[1] | |
313 | raise error.ParseError(err) |
|
313 | raise error.ParseError(err) | |
314 |
|
314 | |||
|
315 | def getinteger(x, err): | |||
|
316 | try: | |||
|
317 | return int(getstring(x, err)) | |||
|
318 | except ValueError: | |||
|
319 | raise error.ParseError(err) | |||
|
320 | ||||
315 | def getlist(x): |
|
321 | def getlist(x): | |
316 | if not x: |
|
322 | if not x: | |
317 | return [] |
|
323 | return [] | |
@@ -539,10 +545,7 b' def ancestorspec(repo, subset, x, n, ord' | |||||
539 | Changesets that are the Nth ancestor (first parents only) of a changeset |
|
545 | Changesets that are the Nth ancestor (first parents only) of a changeset | |
540 | in set. |
|
546 | in set. | |
541 | """ |
|
547 | """ | |
542 | try: |
|
548 | n = getinteger(n, _("~ expects a number")) | |
543 | n = int(n[1]) |
|
|||
544 | except (TypeError, ValueError): |
|
|||
545 | raise error.ParseError(_("~ expects a number")) |
|
|||
546 | ps = set() |
|
549 | ps = set() | |
547 | cl = repo.changelog |
|
550 | cl = repo.changelog | |
548 | for r in getset(repo, fullreposet(repo), x): |
|
551 | for r in getset(repo, fullreposet(repo), x): | |
@@ -1098,10 +1101,8 b' def followlines(repo, subset, x):' | |||||
1098 | raise error.ParseError(_("followlines expects exactly one file")) |
|
1101 | raise error.ParseError(_("followlines expects exactly one file")) | |
1099 | fname = files[0] |
|
1102 | fname = files[0] | |
1100 |
|
1103 | |||
1101 | try: |
|
1104 | fromline, toline = [getinteger(a, _("line range bounds must be integers")) | |
1102 |
|
|
1105 | for a in args['lines']] | |
1103 | except ValueError: |
|
|||
1104 | raise error.ParseError(_("line range bounds must be integers")) |
|
|||
1105 | if toline - fromline < 0: |
|
1106 | if toline - fromline < 0: | |
1106 | raise error.ParseError(_("line range must be positive")) |
|
1107 | raise error.ParseError(_("line range must be positive")) | |
1107 | if fromline < 1: |
|
1108 | if fromline < 1: | |
@@ -1273,19 +1274,15 b' def limit(repo, subset, x):' | |||||
1273 | if 'set' not in args: |
|
1274 | if 'set' not in args: | |
1274 | # i18n: "limit" is a keyword |
|
1275 | # i18n: "limit" is a keyword | |
1275 | raise error.ParseError(_("limit requires one to three arguments")) |
|
1276 | raise error.ParseError(_("limit requires one to three arguments")) | |
1276 | try: |
|
|||
1277 |
|
|
1277 | lim, ofs = 1, 0 | |
1278 |
|
|
1278 | if 'n' in args: | |
1279 |
|
|
1279 | # i18n: "limit" is a keyword | |
1280 |
|
|
1280 | lim = getinteger(args['n'], _("limit expects a number")) | |
1281 |
|
|
1281 | if 'offset' in args: | |
1282 |
|
|
1282 | # i18n: "limit" is a keyword | |
1283 |
|
|
1283 | ofs = getinteger(args['offset'], _("limit expects a number")) | |
1284 |
|
|
1284 | if ofs < 0: | |
1285 |
|
|
1285 | raise error.ParseError(_("negative offset")) | |
1286 | except (TypeError, ValueError): |
|
|||
1287 | # i18n: "limit" is a keyword |
|
|||
1288 | raise error.ParseError(_("limit expects a number")) |
|
|||
1289 | os = getset(repo, fullreposet(repo), args['set']) |
|
1286 | os = getset(repo, fullreposet(repo), args['set']) | |
1290 | result = [] |
|
1287 | result = [] | |
1291 | it = iter(os) |
|
1288 | it = iter(os) | |
@@ -1308,14 +1305,10 b' def last(repo, subset, x):' | |||||
1308 | """ |
|
1305 | """ | |
1309 | # i18n: "last" is a keyword |
|
1306 | # i18n: "last" is a keyword | |
1310 | l = getargs(x, 1, 2, _("last requires one or two arguments")) |
|
1307 | l = getargs(x, 1, 2, _("last requires one or two arguments")) | |
1311 | try: |
|
|||
1312 |
|
|
1308 | lim = 1 | |
1313 |
|
|
1309 | if len(l) == 2: | |
1314 |
|
|
1310 | # i18n: "last" is a keyword | |
1315 |
|
|
1311 | lim = getinteger(l[1], _("last expects a number")) | |
1316 | except (TypeError, ValueError): |
|
|||
1317 | # i18n: "last" is a keyword |
|
|||
1318 | raise error.ParseError(_("last expects a number")) |
|
|||
1319 | os = getset(repo, fullreposet(repo), l[0]) |
|
1312 | os = getset(repo, fullreposet(repo), l[0]) | |
1320 | os.reverse() |
|
1313 | os.reverse() | |
1321 | result = [] |
|
1314 | result = [] |
General Comments 0
You need to be logged in to leave comments.
Login now