hgext3rd/topic/stack.py
changeset 4650 7c05b1625921
parent 4649 6b7ad4b50d00
child 4651 55c347b4874f
--- a/hgext3rd/topic/stack.py	Sun May 05 16:14:53 2019 +0800
+++ b/hgext3rd/topic/stack.py	Sun May 05 17:39:46 2019 +0800
@@ -242,38 +242,38 @@
     if topic == repo.currenttopic:
         label = 'topic.active'
 
-    data = stackdata(repo, branch=branch, topic=topic)
+    st = stack(repo, branch, topic)
     empty = False
-    if data['changesetcount'] == 0:
+    if st.changesetcount == 0:
         empty = True
     if topic is not None:
         fm.plain(_('### topic: %s')
                  % ui.label(topic, label),
                  label='topic.stack.summary.topic')
 
-        if 1 < data['headcount']:
+        if 1 < len(st.heads):
             fm.plain(' (')
-            fm.plain('%d heads' % data['headcount'],
+            fm.plain('%d heads' % len(st.heads),
                      label='topic.stack.summary.headcount.multiple')
             fm.plain(')')
         fm.plain('\n')
     fm.plain(_('### target: %s (branch)')
-             % '+'.join(data['branches']), # XXX handle multi branches
+             % '+'.join(st.branches), # XXX handle multi branches
              label='topic.stack.summary.branches')
     if topic is None:
-        if 1 < data['headcount']:
+        if 1 < len(st.heads):
             fm.plain(' (')
-            fm.plain('%d heads' % data['headcount'],
+            fm.plain('%d heads' % len(st.heads),
                      label='topic.stack.summary.headcount.multiple')
             fm.plain(')')
     else:
-        if data['behindcount'] == -1:
+        if st.behindcount == -1:
             fm.plain(', ')
-            fm.plain('ambiguous rebase destination - %s' % data['behinderror'],
+            fm.plain('ambiguous rebase destination - %s' % st.behinderror,
                      label='topic.stack.summary.behinderror')
-        elif data['behindcount']:
+        elif st.behindcount:
             fm.plain(', ')
-            fm.plain('%d behind' % data['behindcount'], label='topic.stack.summary.behindcount')
+            fm.plain('%d behind' % st.behindcount, label='topic.stack.summary.behindcount')
     fm.plain('\n')
 
     if empty:
@@ -376,21 +376,3 @@
                      label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states))
         fm.plain('\n')
     fm.end()
-
-def stackdata(repo, branch=None, topic=None):
-    """get various data about a stack
-
-    :changesetcount: number of non-obsolete changesets in the stack
-    :unstablecount: number of unstable changesets
-    :headcount: number of heads on the topic
-    :behindcount: number of changeset on rebase destination
-    """
-    data = {}
-    current = stack(repo, branch, topic)
-    data['changesetcount'] = current.changesetcount
-    data['unstablecount'] = current.unstablecount
-    data['headcount'] = len(current.heads)
-    data['behindcount'] = current.behindcount
-    data['behinderror'] = current.behinderror
-    data['branches'] = current.branches
-    return data