# HG changeset patch # User Anton Shestakov # Date 1557302434 -28800 # Node ID b72cd597a88780f430c7a464c6b41b2262e9b5e8 # Parent 55c347b4874facd765bb00f469e735764048717a stack: check if stack is empty more pythonically diff -r 55c347b4874f -r b72cd597a887 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Wed May 08 15:57:54 2019 +0800 +++ b/hgext3rd/topic/__init__.py Wed May 08 16:00:34 2019 +0800 @@ -735,8 +735,8 @@ ct = repo.currenttopic if clear: if ct: - empty = stack.stack(repo, topic=ct).changesetcount == 0 - if empty: + st = stack.stack(repo, topic=ct) + if not st: ui.status(_('clearing empty topic "%s"\n') % ct) return _changecurrenttopic(repo, None) @@ -1234,8 +1234,8 @@ if t and t != ot: repo.ui.status(_("switching to topic %s\n") % t) if ot and not t: - empty = stack.stack(repo, topic=ot).changesetcount == 0 - if empty: + st = stack.stack(repo, topic=ot) + if not st: repo.ui.status(_('clearing empty topic "%s"\n') % ot) elif ist0: repo.ui.status(_("preserving the current topic '%s'\n") % ot) diff -r 55c347b4874f -r b72cd597a887 hgext3rd/topic/stack.py --- a/hgext3rd/topic/stack.py Wed May 08 15:57:54 2019 +0800 +++ b/hgext3rd/topic/stack.py Wed May 08 16:00:34 2019 +0800 @@ -248,9 +248,6 @@ label = 'topic.active' st = stack(repo, branch, topic) - empty = False - if st.changesetcount == 0: - empty = True if topic is not None: fm.plain(_('### topic: %s') % ui.label(topic, label), @@ -281,7 +278,7 @@ fm.plain('%d behind' % st.behindcount, label='topic.stack.summary.behindcount') fm.plain('\n') - if empty: + if not st: fm.plain(_("(stack is empty)\n")) st = stack(repo, branch=branch, topic=topic)