[PATCH 4 of 4] revset: introduce a 'foo#stack[n]' subscript relation to access stack revisions

Anton Shestakov av6 at dwimlabs.net
Wed Sep 25 06:20:11 EDT 2019


On Wed, 25 Sep 2019 02:48:09 +0200
Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:

> On 9/25/19 1:25 AM, Yuya Nishihara wrote:
> > On Tue, 24 Sep 2019 21:16:53 +0200, Pierre-Yves David wrote:  
> >> On 9/23/19 2:58 PM, Yuya Nishihara wrote:  
> >>> On Mon, 23 Sep 2019 10:39:52 +0700, Anton Shestakov wrote:  
> >>>> # HG changeset patch
> >>>> # User Anton Shestakov <av6 at dwimlabs.net>
> >>>> # Date 1569139969 -25200
> >>>> #      Sun Sep 22 15:12:49 2019 +0700
> >>>> # Node ID ab8f097abacb8ce0f9cea2bce0924bb2fd3261a2
> >>>> # Parent  07af98a1e730c1ffa6911c9ab2cdcc06d4ffe52d
> >>>> # EXP-Topic stack-object
> >>>> revset: introduce a 'foo#stack[n]' subscript relation to access stack revisions
> >>>>
> >>>> The idea behind making n = 0 cases special is that stack base should be
> >>>> accessible, but only when users ask for it explicitly.  
> >>>  
> >>>> +def stackrel(repo, subset, x, rel, z, order):
> >>>> +    a, b = getintrange(z,
> >>>> +                       _('relation subscript must be an integer or a range'),
> >>>> +                       _('relation subscript bounds must be integers'),
> >>>> +                       deffirst=None,
> >>>> +                       deflast=None)
> >>>> +
> >>>> +    s = getset(repo, fullreposet(repo), x)
> >>>> +    if not s:
> >>>> +        return baseset()
> >>>> +
> >>>> +    def getrange(st, a, b):
> >>>> +        start = 1 if a is None else a
> >>>> +        end = len(st.indexedrevs) if b is None else b + 1  
> >>>
> >>> I feel it's weird that stack[:] doesn't include stack[0].  
> >>
> >> [0] is the "root" of the stack, but not part of it. It is handy to have
> >> it around when one want to insert and initial commit or test thing
> >> without any of the stack changes, however it not part of the stack.
> >>
> >> For example if you want to update all changesets in the stack you could
> >> do `hg metaedit --rev '.#stack[:]' --user foobar`. You don't want to
> >> select s0 it might even be a public changesets.  
> > 
> > I understand that. My point is it may be confusing if foo[:] includes #foo[0],
> > but #bar[:] doesn't.  
> 
> I suspect we already have a "every namespace behave differently 
> situation". The "generation" namespace is not table indexing ".#g[0]" is 
> ".", and ".#g[X]' might return more than on revision.

Yeah, the problem with handling [0] in this special way is usability.
We do want to access stack base sometimes, but it's also not a part of a
stack. So we obviously can't leave it to users to just write a revset to
pick stack base, but it's also cumbersome to write "foo#s[:] - foo#s[0]"
every time you want to pick the whole stack. Maybe removing subscript
would make it more special (and somewhat less confusing), like
"foo#stack"? That's my only idea so far, and I'm not a fan of it.

> Alternatively, maybe stacks needs a different syntax ?

While we decide that, I've pushed a V2 of this series, it doesn't
include #stack[] (i.e. just patches 2 and 3 of the V1 with feedback
addressed). It's not much, but it will allow me to start making stack
implementation in topic extension use bits of stack in core.


More information about the Mercurial-devel mailing list