##// END OF EJS Templates
revset: add default of 1 to limit and last functions
Matt Mackall -
r15116:d8501bcb default
parent child Browse files
Show More
@@ -513,14 +513,16 b' def keyword(repo, subset, x):'
513 return l
513 return l
514
514
515 def limit(repo, subset, x):
515 def limit(repo, subset, x):
516 """``limit(set, n)``
516 """``limit(set, [n])``
517 First n members of set.
517 First n members of set, defaulting to 1.
518 """
518 """
519 # i18n: "limit" is a keyword
519 # i18n: "limit" is a keyword
520 l = getargs(x, 2, 2, _("limit requires two arguments"))
520 l = getargs(x, 1, 2, _("limit requires one or two arguments"))
521 try:
521 try:
522 # i18n: "limit" is a keyword
522 lim = 1
523 lim = int(getstring(l[1], _("limit requires a number")))
523 if len(l) == 2:
524 # i18n: "limit" is a keyword
525 lim = int(getstring(l[1], _("limit requires a number")))
524 except (TypeError, ValueError):
526 except (TypeError, ValueError):
525 # i18n: "limit" is a keyword
527 # i18n: "limit" is a keyword
526 raise error.ParseError(_("limit expects a number"))
528 raise error.ParseError(_("limit expects a number"))
@@ -529,14 +531,16 b' def limit(repo, subset, x):'
529 return [r for r in os if r in ss]
531 return [r for r in os if r in ss]
530
532
531 def last(repo, subset, x):
533 def last(repo, subset, x):
532 """``last(set, n)``
534 """``last(set, [n])``
533 Last n members of set.
535 Last n members of set, defaulting to 1.
534 """
536 """
535 # i18n: "last" is a keyword
537 # i18n: "last" is a keyword
536 l = getargs(x, 2, 2, _("last requires two arguments"))
538 l = getargs(x, 1, 2, _("last requires one or two arguments"))
537 try:
539 try:
538 # i18n: "last" is a keyword
540 lim = 1
539 lim = int(getstring(l[1], _("last requires a number")))
541 if len(l) == 2:
542 # i18n: "last" is a keyword
543 lim = int(getstring(l[1], _("last requires a number")))
540 except (TypeError, ValueError):
544 except (TypeError, ValueError):
541 # i18n: "last" is a keyword
545 # i18n: "last" is a keyword
542 raise error.ParseError(_("last expects a number"))
546 raise error.ParseError(_("last expects a number"))
General Comments 0
You need to be logged in to leave comments. Login now