# HG changeset patch # User Pierre-Yves David # Date 1472207872 -7200 # Node ID 71410fa2c253a3b0a9050fb8bf310eff014d2d48 # Parent cf9414f2b5cddd65d21041527981d15a6fb6fd67 stack: extra argument validation logic outside of showstack It seems sensible keep the 'showstack' function purely about actually displaying and existing stack. diff -r cf9414f2b5cd -r 71410fa2c253 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Tue Aug 23 21:18:47 2016 +0200 +++ b/hgext3rd/topic/__init__.py Fri Aug 26 12:37:52 2016 +0200 @@ -196,6 +196,10 @@ if list: if clear or change: raise error.Abort(_("cannot use --clear or --change with --list")) + if not topic: + topic = repo.currenttopic + if not topic: + raise error.Abort(_('no active topic to list')) return stack.showstack(ui, repo, topic, opts) if change: @@ -275,6 +279,10 @@ """list all changesets in a topic List the current topic by default.""" + if not topic: + topic = repo.currenttopic + if not topic: + raise error.Abort(_('no active topic to list')) return stack.showstack(ui, repo, topic, opts) def _listtopics(ui, repo, opts): diff -r cf9414f2b5cd -r 71410fa2c253 hgext3rd/topic/stack.py --- a/hgext3rd/topic/stack.py Tue Aug 23 21:18:47 2016 +0200 +++ b/hgext3rd/topic/stack.py Fri Aug 26 12:37:52 2016 +0200 @@ -2,7 +2,6 @@ # # 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 ( destutil, error, @@ -16,10 +15,6 @@ return _orderrevs(repo, trevs) def showstack(ui, repo, topic, opts): - if not topic: - topic = repo.currenttopic - if not topic: - raise error.Abort(_('no active topic to list')) fm = ui.formatter('topicstack', opts) prev = None entries = []