Show More
@@ -302,6 +302,8 b' def tokenize(program, lookup=None, symin' | |||||
302 |
|
302 | |||
303 | # helpers |
|
303 | # helpers | |
304 |
|
304 | |||
|
305 | _notset = object() | |||
|
306 | ||||
305 | def getsymbol(x): |
|
307 | def getsymbol(x): | |
306 | if x and x[0] == 'symbol': |
|
308 | if x and x[0] == 'symbol': | |
307 | return x[1] |
|
309 | return x[1] | |
@@ -312,7 +314,9 b' def getstring(x, err):' | |||||
312 | return x[1] |
|
314 | return x[1] | |
313 | raise error.ParseError(err) |
|
315 | raise error.ParseError(err) | |
314 |
|
316 | |||
315 | def getinteger(x, err): |
|
317 | def getinteger(x, err, default=_notset): | |
|
318 | if not x and default is not _notset: | |||
|
319 | return default | |||
316 | try: |
|
320 | try: | |
317 | return int(getstring(x, err)) |
|
321 | return int(getstring(x, err)) | |
318 | except ValueError: |
|
322 | except ValueError: | |
@@ -1274,13 +1278,10 b' def limit(repo, subset, x):' | |||||
1274 | if 'set' not in args: |
|
1278 | if 'set' not in args: | |
1275 | # i18n: "limit" is a keyword |
|
1279 | # i18n: "limit" is a keyword | |
1276 | raise error.ParseError(_("limit requires one to three arguments")) |
|
1280 | raise error.ParseError(_("limit requires one to three arguments")) | |
1277 | lim, ofs = 1, 0 |
|
1281 | # i18n: "limit" is a keyword | |
1278 | if 'n' in args: |
|
1282 | lim = getinteger(args.get('n'), _("limit expects a number"), default=1) | |
1279 |
|
|
1283 | # i18n: "limit" is a keyword | |
1280 |
|
|
1284 | ofs = getinteger(args.get('offset'), _("limit expects a number"), default=0) | |
1281 | if 'offset' in args: |
|
|||
1282 | # i18n: "limit" is a keyword |
|
|||
1283 | ofs = getinteger(args['offset'], _("limit expects a number")) |
|
|||
1284 | if ofs < 0: |
|
1285 | if ofs < 0: | |
1285 | raise error.ParseError(_("negative offset")) |
|
1286 | raise error.ParseError(_("negative offset")) | |
1286 | os = getset(repo, fullreposet(repo), args['set']) |
|
1287 | os = getset(repo, fullreposet(repo), args['set']) |
General Comments 0
You need to be logged in to leave comments.
Login now