[PATCH V5] revset: support ranges in #generations relation

Anton Shestakov av6 at dwimlabs.net
Fri Jan 18 05:00:15 EST 2019


On Thu, 17 Jan 2019 23:28:22 +0900
Yuya Nishihara <yuya at tcha.org> wrote:

> On Thu, 17 Jan 2019 21:17:26 +0800, Anton Shestakov wrote:
> > # HG changeset patch
> > # User Anton Shestakov <av6 at dwimlabs.net>
> > # Date 1547564229 -28800
> > #      Tue Jan 15 22:57:09 2019 +0800
> > # Node ID d1e7a57a62ca4dd99a11659148baf672bc9cab38
> > # Parent  8aca89a694d4bd7d25877b3652fb83e187ea1802
> > revset: support ranges in #generations relation
> 
> > +def _splitrange(a, b):
> > +    """ Split range with bounds a and b into two ranges at 0 and return two
> > +    lists of numbers for use as startdepth and stopdepth arguments of
> > +    _ancestors and _descendants.
> > +
> > +    If 0 is in the input range, it is included only in the second list.
> > +
> > +    >>> _splitrange(None, None)  # [:]
> > +    ([1, None], [0, None])
> > +    >>> _splitrange(-10, None)   # [-10:]
> > +    ([1, 11], [0, None])
> > +    >>> _splitrange(None, 10)    # [:10]
> > +    ([1, None], [0, 11])
> > +    >>> _splitrange(-10, -5)     # [-10:-5]
> > +    ([5, 11], [None, None])
> > +    >>> _splitrange(5, 10)       # [5:10]
> > +    ([None, None], [5, 11])
> > +    >>> _splitrange(-10, 10)     # [-10:10]
> > +    ([1, 11], [0, 11])
> 
> > +    >>> _splitrange(-10, 0)      # [-10:0]
> > +    ([1, 11], [0, 1])
> 
> So this would result in silly computation 'anc + desc'?
> As I said 'anc{x} + desc{x}' won't yield 'x' twice, so including 0 in both
> sets should be fine.

It would be fine, but we don't want to call both _ancestors() and
_descendants() if we can get the 0 from just one of these functions.
This is improved in V6.


More information about the Mercurial-devel mailing list