comparison mercurial/commands.py @ 42124:d6437f414437

branch: return early if we find an open named branch apart from default The current code builds a list of all the open named branches except default and then bool that. This is mostly fine until you get a repo which has thousands of named branches. Differential Revision: https://phab.mercurial-scm.org/D6211
author Pulkit Goyal <pulkit@yandex-team.ru>
date Fri, 05 Apr 2019 16:05:20 +0300
parents 2a3c0106ded9
children 232a33a11ce0
comparison
equal deleted inserted replaced
42123:be5eeaf5c24a 42124:d6437f414437
1123 1123
1124 repo.dirstate.setbranch(label) 1124 repo.dirstate.setbranch(label)
1125 ui.status(_('marked working directory as branch %s\n') % label) 1125 ui.status(_('marked working directory as branch %s\n') % label)
1126 1126
1127 # find any open named branches aside from default 1127 # find any open named branches aside from default
1128 others = [n for n, h, t, c in repo.branchmap().iterbranches() 1128 for n, h, t, c in repo.branchmap().iterbranches():
1129 if n != "default" and not c] 1129 if n != "default" and not c:
1130 if not others: 1130 return 0
1131 ui.status(_('(branches are permanent and global, ' 1131 ui.status(_('(branches are permanent and global, '
1132 'did you want a bookmark?)\n')) 1132 'did you want a bookmark?)\n'))
1133 1133
1134 @command('branches', 1134 @command('branches',
1135 [('a', 'active', False, 1135 [('a', 'active', False,
1136 _('show only branches that have unmerged heads (DEPRECATED)')), 1136 _('show only branches that have unmerged heads (DEPRECATED)')),
1137 ('c', 'closed', False, _('show normal and closed branches')), 1137 ('c', 'closed', False, _('show normal and closed branches')),