changeset 3155:02b220984b01

topics: use stack.stack() instead of stack.stackdata() stack.stackdata() also calls stack.stack() internally. Moreover if we just want to calculate changesetcount, troubled count, it will be cheap to calculate using stack.stack rather than stackdata().
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 13 Oct 2017 10:01:38 +0530
parents cb8ae3cb0bbc
children f43a310c4338
files hgext3rd/topic/__init__.py
diffstat 1 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -780,33 +780,40 @@
         fm.data(active=active)
         if ui.verbose:
             # XXX we should include the data even when not verbose
-            data = stack.stackdata(repo, topic=topic)
+            data = stack.stack(repo, topic=topic)
+
             fm.plain(' (')
             fm.write('branches+', 'on branch: %s',
-                     '+'.join(data['branches']), # XXX use list directly after 4.0 is released
+                     '+'.join(data.branches), # XXX use list directly after 4.0 is released
                      label='topic.list.branches')
+
             fm.plain(', ')
-            fm.write('changesetcount', '%d changesets', data['changesetcount'],
+            fm.write('changesetcount', '%d changesets', data.changesetcount,
                      label='topic.list.changesetcount')
-            if data['troubledcount']:
+
+            if data.troubledcount:
                 fm.plain(', ')
                 fm.write('troubledcount', '%d troubled',
-                         data['troubledcount'],
+                         data.troubledcount,
                          label='topic.list.troubledcount')
-            if 1 < data['headcount']:
+
+            headcount = len(data.heads)
+            if 1 < headcount:
                 fm.plain(', ')
                 fm.write('headcount', '%d heads',
-                         data['headcount'],
+                         headcount,
                          label='topic.list.headcount.multiple')
-            if 0 < data['behindcount']:
+
+            behindcount = data.behindcount
+            if 0 < behindcount:
                 fm.plain(', ')
                 fm.write('behindcount', '%d behind',
-                         data['behindcount'],
+                         behindcount,
                          label='topic.list.behindcount')
-            elif -1 == data['behindcount']:
+            elif -1 == behindcount:
                 fm.plain(', ')
                 fm.write('behinderror', '%s',
-                         _('ambiguous destination: %s') % data['behinderror'],
+                         _('ambiguous destination: %s') % data.behinderror,
                          label='topic.list.behinderror')
             fm.plain(')')
         fm.plain('\n')