From ebfd01568102fd1a782eddb026f14fd611fad87e Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Wed, 26 Oct 2005 14:51:47 -0400 Subject: [PATCH] Make listing branches more efficient Listing branches appears to "init" the series twice for each branch in the list. Similarly for deleting a branch. Signed-off-by: Chuck Lever --- stgit/commands/branch.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/stgit/commands/branch.py b/stgit/commands/branch.py index 3e5efef..8420ec6 100644 --- a/stgit/commands/branch.py +++ b/stgit/commands/branch.py @@ -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) -- 2.11.0