Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 14153:f8047a059ca0
revset: avoid over-aggresive optimizations of non-filtering functions (issue2549)
When limit, last, min and max were evaluated they worked on a reduced set in the
wrong way. Now they work on an unrestricted set (the whole repo) and get
limited later on.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sun, 01 May 2011 17:35:05 +0200 |
parents | 9f5a0acb0056 |
children | 30273f0c776b |
comparison
equal
deleted
inserted
replaced
14152:00121103546a | 14153:f8047a059ca0 |
---|---|
466 # i18n: "limit" is a keyword | 466 # i18n: "limit" is a keyword |
467 lim = int(getstring(l[1], _("limit requires a number"))) | 467 lim = int(getstring(l[1], _("limit requires a number"))) |
468 except ValueError: | 468 except ValueError: |
469 # i18n: "limit" is a keyword | 469 # i18n: "limit" is a keyword |
470 raise error.ParseError(_("limit expects a number")) | 470 raise error.ParseError(_("limit expects a number")) |
471 return getset(repo, subset, l[0])[:lim] | 471 ss = set(subset) |
472 os = getset(repo, range(len(repo)), l[0])[:lim] | |
473 return [r for r in os if r in ss] | |
472 | 474 |
473 def last(repo, subset, x): | 475 def last(repo, subset, x): |
474 """``last(set, n)`` | 476 """``last(set, n)`` |
475 Last n members of set. | 477 Last n members of set. |
476 """ | 478 """ |
480 # i18n: "last" is a keyword | 482 # i18n: "last" is a keyword |
481 lim = int(getstring(l[1], _("last requires a number"))) | 483 lim = int(getstring(l[1], _("last requires a number"))) |
482 except ValueError: | 484 except ValueError: |
483 # i18n: "last" is a keyword | 485 # i18n: "last" is a keyword |
484 raise error.ParseError(_("last expects a number")) | 486 raise error.ParseError(_("last expects a number")) |
485 return getset(repo, subset, l[0])[-lim:] | 487 ss = set(subset) |
488 os = getset(repo, range(len(repo)), l[0])[-lim:] | |
489 return [r for r in os if r in ss] | |
486 | 490 |
487 def maxrev(repo, subset, x): | 491 def maxrev(repo, subset, x): |
488 """``max(set)`` | 492 """``max(set)`` |
489 Changeset with highest revision number in set. | 493 Changeset with highest revision number in set. |
490 """ | 494 """ |
491 s = getset(repo, subset, x) | 495 os = getset(repo, range(len(repo)), x) |
492 if s: | 496 if os: |
493 m = max(s) | 497 m = max(os) |
494 if m in subset: | 498 if m in subset: |
495 return [m] | 499 return [m] |
496 return [] | 500 return [] |
497 | 501 |
498 def merge(repo, subset, x): | 502 def merge(repo, subset, x): |
506 | 510 |
507 def minrev(repo, subset, x): | 511 def minrev(repo, subset, x): |
508 """``min(set)`` | 512 """``min(set)`` |
509 Changeset with lowest revision number in set. | 513 Changeset with lowest revision number in set. |
510 """ | 514 """ |
511 s = getset(repo, subset, x) | 515 os = getset(repo, range(len(repo)), x) |
512 if s: | 516 if os: |
513 m = min(s) | 517 m = min(os) |
514 if m in subset: | 518 if m in subset: |
515 return [m] | 519 return [m] |
516 return [] | 520 return [] |
517 | 521 |
518 def modifies(repo, subset, x): | 522 def modifies(repo, subset, x): |