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().
--- 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')