changeset 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 be5eeaf5c24a
children bc15e37ecc16
files mercurial/commands.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Apr 05 15:57:09 2019 +0300
+++ b/mercurial/commands.py	Fri Apr 05 16:05:20 2019 +0300
@@ -1125,11 +1125,11 @@
             ui.status(_('marked working directory as branch %s\n') % label)
 
             # find any open named branches aside from default
-            others = [n for n, h, t, c in repo.branchmap().iterbranches()
-                      if n != "default" and not c]
-            if not others:
-                ui.status(_('(branches are permanent and global, '
-                            'did you want a bookmark?)\n'))
+            for n, h, t, c in repo.branchmap().iterbranches():
+                if n != "default" and not c:
+                    return 0
+            ui.status(_('(branches are permanent and global, '
+                        'did you want a bookmark?)\n'))
 
 @command('branches',
     [('a', 'active', False,