topics: use stack.stack() instead of stack.stackdata()
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 13 Oct 2017 10:01:38 +0530
changeset 3059 02b220984b01
parent 3057 cb8ae3cb0bbc
child 3060 f43a310c4338
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().
hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py	Tue Oct 10 22:40:41 2017 +0200
+++ b/hgext3rd/topic/__init__.py	Fri Oct 13 10:01:38 2017 +0530
@@ -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')