[PATCH V2] show: implement "stack" view
Yuya Nishihara
yuya at tcha.org
Mon Jul 3 10:38:53 EDT 2017
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.
> + 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?
> + 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.
More information about the Mercurial-devel
mailing list