chiark / gitweb /
Make listing branches more efficient
authorChuck Lever <cel@netapp.com>
Wed, 26 Oct 2005 18:51:47 +0000 (14:51 -0400)
committerCatalin Marinas <catalin.marinas@gmail.com>
Thu, 27 Oct 2005 19:47:12 +0000 (20:47 +0100)
Listing branches appears to "init" the series twice for each branch in
the list.  Similarly for deleting a branch.

Signed-off-by: Chuck Lever <cel@netapp.com>
stgit/commands/branch.py

index 3e5efef132d98d54baa5703a41d1b67c3c8fc08d..8420ec6393b0071383946993c8ec06fd49d7c630 100644 (file)
@@ -67,23 +67,28 @@ def print_branch(branch_name):
     initialized = ' '
     current = ' '
     protected = ' '
+
+    branch = stack.Series(branch_name)
+
     if os.path.isdir(os.path.join(git.base_dir, 'patches', branch_name)):
         initialized = 's'
     if is_current_branch(branch_name):
         current = '>'
-    if stack.Series(branch_name).get_protected():
+    if branch.get_protected():
         protected = 'p'
     print '%s %s%s\t%s\t%s' % (current, initialized, protected, branch_name, \
-                               stack.Series(branch_name).get_description())
+                               branch.get_description())
 
 def delete_branch(doomed_name, force = False):
-    if stack.Series(doomed_name).get_protected():
+    doomed = stack.Series(doomed_name)
+
+    if doomed.get_protected():
         raise CmdException, 'This branch is protected. Delete is not permitted'
 
     if is_current_branch(doomed_name) and doomed_name != 'master':
         git.switch_branch('master')
 
-    stack.Series(doomed_name).delete(force)
+    doomed.delete(force)
 
     if doomed_name != 'master':
         git.delete_branch(doomed_name)