Mercurial > public > mercurial-scm > hg
diff mercurial/revset.py @ 32799:b36ec65ea583
revset: reject negative number to select first/last n members
Negative 'lim' doesn't make sense here, and it makes things complicated
when using list[:lim].
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 10 Jun 2017 18:35:11 +0900 |
parents | 573b792872c1 |
children | 3e6f9bff7e3f |
line wrap: on
line diff
--- a/mercurial/revset.py Sat Jun 10 18:04:56 2017 +0900 +++ b/mercurial/revset.py Sat Jun 10 18:35:11 2017 +0900 @@ -1162,6 +1162,8 @@ raise error.ParseError(_("limit requires one to three arguments")) # i18n: "limit" is a keyword lim = getinteger(args.get('n'), _("limit expects a number"), default=1) + if lim < 0: + raise error.ParseError(_("negative number to select")) # i18n: "limit" is a keyword ofs = getinteger(args.get('offset'), _("limit expects a number"), default=0) if ofs < 0: @@ -1192,6 +1194,8 @@ if len(l) == 2: # i18n: "last" is a keyword lim = getinteger(l[1], _("last expects a number")) + if lim < 0: + raise error.ParseError(_("negative number to select")) os = getset(repo, fullreposet(repo), l[0]) os.reverse() result = []