D5813: revset: add expect to check the size of a set

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Mon Feb 4 07:20:53 EST 2019


yuja added a comment.


  > + at predicate('expect(set[, size[, min, max]])', safe=True, takeorder=True)
  
  First, I think the word `expect` is too general. Perhaps, this should be called
  `expectsize()` or `expectlen()`.
  
  It's also unclear what's the difference between `size` and `min`/`max`.
  Instead of these parameters, maybe we can add a `size` parameter that takes
  a number or a range `min:max`. See also the following patch.
  
  https://www.mercurial-scm.org/pipermail/mercurial-devel/2019-February/127916.html
  
  > +        if len(rev) != n:
  >  +            raise error.Abort(_('revset is not of expected size'))
  
  Better to raise RepoLookupError so the error can be caught by `present(...)`.
  
  > +    return rev
  
  You need to filter rev by subset. Since we'll probably want to get an ordered
  result from `expect(set)`, we'll have to conditionalize the filtering direction:
  
    if order == followorder:
        return subset & rev
    else:
        return rev & subset
  
  You can try out some combinations of `expect(5:0) & 1:10` and
  `10:1 & expect(0:5)`.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5813

To: navaneeth.suresh, #hg-reviewers
Cc: yuja, pulkit, durin42, mjpieters, mercurial-devel


More information about the Mercurial-devel mailing list