[PATCH V2] show: implement "stack" view
Gregory Szorc
gregory.szorc at gmail.com
Tue Jul 4 04:21:58 UTC 2017
On Mon, Jul 3, 2017 at 7:38 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> On Sat, 01 Jul 2017 22:39:40 -0700, Gregory Szorc wrote:
> > # HG changeset patch
> > # User Gregory Szorc <gregory.szorc at gmail.com>
> > # Date 1498973922 25200
> > # Sat Jul 01 22:38:42 2017 -0700
> > # Node ID eaf601d0ea04ad80ee3d763cb3274286a780f16d
> > # Parent 6d678ab1b10d0fddc73003d21aa3c7ec43194e2e
> > show: implement "stack" view
>
> Looks generally good to me, so queued, thanks.
>
Thanks for the feedback! Will send some fix-ups shortly...
>
> > + at showview('stack', csettopic='stack')
> > +def showstack(ui, repo, displayer):
> > + """current line of work"""
> > + wdirctx = repo['.']
> > + if wdirctx.rev() == nullrev:
> > + raise error.Abort(_('stack view only available when there is a '
> > + 'working directory'))
> > +
> > + if wdirctx.phase() == phases.public:
> > + ui.write(_('(empty stack; working directory is a published '
> > + 'changeset)\n'))
>
> "." isn't called "working directory", but "working directory parent".
>
> > + for rev in cl.descendants([wdirctx.rev()]):
> > + ctx = repo[rev]
> > +
> > + # Will only happen if . is public.
> > + if ctx.phase() == phases.public:
> > + break
> > +
> > + stackrevs.add(ctx.rev())
> > +
> > + if len(ctx.children()) > 1:
> > + branchpointattip = True
> > + break
>
> Maybe this is quadratic?
>
Indeed. But since the number of revisions iterated by cl.descendants()
should be small, I think we'll be OK.
>
> > + stackrevs = list(reversed(sorted(stackrevs)))
>
> could be sorted(reverse=True).
>
> > + try:
> > + cmdutil.findcmd('rebase', commands.table)
> > + haverebase = True
> > + except error.UnknownCommand:
> > + haverebase = False
>
> Maybe AmbiguousCommand could be raised if there's no 'rebase', but
> 'rebasefoo'
> and 'rebasebar'. But nobody would care.
>
> > +def stackbase(ui, repo):
> > + # The histedit default base stops at public changesets,
> branchpoints,
> > + # and merges, which is exactly what we want for a stack.
> > + revs = scmutil.revrange(repo, [histeditdefaultrevset])
>
> Perhaps repo.revs() can be used here since alias expansion shouldn't be
> necessary.
>
> > + return revs.last() if revs else None
>
> revs.last() is documented to return None if the set is empty.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170703/8a38be35/attachment-0002.html>
More information about the Mercurial-devel
mailing list