src/topic/stack.py
author Pierre-Yves David <pierre-yves.david@fb.com>
Mon, 14 Mar 2016 17:37:39 +0000
changeset 1895 c8e4c6e03957
child 1896 4ae421cbb07c
permissions -rw-r--r--
stack: add a very first version of stack display with 'hg topic --list' This mark the first step toward a set of feature dedicated to displaying and moving within the current stack of work. Everything is still super basic so don't look too much at the feature. The goals of this changeset are: * having a flag to trigger the feature * having a basic (imperfect selection mechanism)

# stack.py - code related to stack workflow
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from mercurial.i18n import _
from mercurial import error

def _getstack(repo, topic):
    # XXX need to exclude obsolete changesets
    # XXX need sorting
    return repo.revs("topic(%s)", topic)

def showstack(ui, repo, topic):
    if not topic:
        topic = repo.currenttopic
    if not topic:
        raise error.Abort(_('no active topic to list'))
    for r in _getstack(repo, topic):
        # super crude initial version
        ui.write(repo[r].description().splitlines()[0] + '\n')