Mercurial > hg
comparison mercurial/revset.py @ 14851:f96c354493d7 stable
revsets: actually catch type error on tip^p1(tip) (issue2884)
The previous commit was empty.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 12 Jul 2011 12:35:03 -0500 |
parents | 805651777188 |
children | fc3d6f300d7d |
comparison
equal
deleted
inserted
replaced
14850:a95242af945c | 14851:f96c354493d7 |
---|---|
215 """``set~n`` | 215 """``set~n`` |
216 Changesets that are the Nth ancestor (first parents only) of a changeset in set. | 216 Changesets that are the Nth ancestor (first parents only) of a changeset in set. |
217 """ | 217 """ |
218 try: | 218 try: |
219 n = int(n[1]) | 219 n = int(n[1]) |
220 except ValueError: | 220 except (TypeError, ValueError): |
221 raise error.ParseError(_("~ expects a number")) | 221 raise error.ParseError(_("~ expects a number")) |
222 ps = set() | 222 ps = set() |
223 cl = repo.changelog | 223 cl = repo.changelog |
224 for r in getset(repo, subset, x): | 224 for r in getset(repo, subset, x): |
225 for i in range(n): | 225 for i in range(n): |
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, 2, 2, _("limit requires two arguments")) |
521 try: | 521 try: |
522 # i18n: "limit" is a keyword | 522 # i18n: "limit" is a keyword |
523 lim = int(getstring(l[1], _("limit requires a number"))) | 523 lim = int(getstring(l[1], _("limit requires a number"))) |
524 except ValueError: | 524 except (TypeError, ValueError): |
525 # i18n: "limit" is a keyword | 525 # i18n: "limit" is a keyword |
526 raise error.ParseError(_("limit expects a number")) | 526 raise error.ParseError(_("limit expects a number")) |
527 ss = set(subset) | 527 ss = set(subset) |
528 os = getset(repo, range(len(repo)), l[0])[:lim] | 528 os = getset(repo, range(len(repo)), l[0])[:lim] |
529 return [r for r in os if r in ss] | 529 return [r for r in os if r in ss] |
535 # i18n: "last" is a keyword | 535 # i18n: "last" is a keyword |
536 l = getargs(x, 2, 2, _("last requires two arguments")) | 536 l = getargs(x, 2, 2, _("last requires two arguments")) |
537 try: | 537 try: |
538 # i18n: "last" is a keyword | 538 # i18n: "last" is a keyword |
539 lim = int(getstring(l[1], _("last requires a number"))) | 539 lim = int(getstring(l[1], _("last requires a number"))) |
540 except ValueError: | 540 except (TypeError, ValueError): |
541 # i18n: "last" is a keyword | 541 # i18n: "last" is a keyword |
542 raise error.ParseError(_("last expects a number")) | 542 raise error.ParseError(_("last expects a number")) |
543 ss = set(subset) | 543 ss = set(subset) |
544 os = getset(repo, range(len(repo)), l[0])[-lim:] | 544 os = getset(repo, range(len(repo)), l[0])[-lim:] |
545 return [r for r in os if r in ss] | 545 return [r for r in os if r in ss] |
674 """ | 674 """ |
675 try: | 675 try: |
676 n = int(n[1]) | 676 n = int(n[1]) |
677 if n not in (0, 1, 2): | 677 if n not in (0, 1, 2): |
678 raise ValueError | 678 raise ValueError |
679 except ValueError: | 679 except (TypeError, ValueError): |
680 raise error.ParseError(_("^ expects a number 0, 1, or 2")) | 680 raise error.ParseError(_("^ expects a number 0, 1, or 2")) |
681 ps = set() | 681 ps = set() |
682 cl = repo.changelog | 682 cl = repo.changelog |
683 for r in getset(repo, subset, x): | 683 for r in getset(repo, subset, x): |
684 if n == 0: | 684 if n == 0: |
716 # i18n: "rev" is a keyword | 716 # i18n: "rev" is a keyword |
717 l = getargs(x, 1, 1, _("rev requires one argument")) | 717 l = getargs(x, 1, 1, _("rev requires one argument")) |
718 try: | 718 try: |
719 # i18n: "rev" is a keyword | 719 # i18n: "rev" is a keyword |
720 l = int(getstring(l[0], _("rev requires a number"))) | 720 l = int(getstring(l[0], _("rev requires a number"))) |
721 except ValueError: | 721 except (TypeError, ValueError): |
722 # i18n: "rev" is a keyword | 722 # i18n: "rev" is a keyword |
723 raise error.ParseError(_("rev expects a number")) | 723 raise error.ParseError(_("rev expects a number")) |
724 return [r for r in subset if r == l] | 724 return [r for r in subset if r == l] |
725 | 725 |
726 def reverse(repo, subset, x): | 726 def reverse(repo, subset, x): |