X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/c1fe1f9953a874eef1f4e975af0430766176e3f2..93aa248c1f7d093c77959a70942e1ae6208750c8:/stgit/commands/branch.py diff --git a/stgit/commands/branch.py b/stgit/commands/branch.py index 56a5fe6..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) @@ -161,8 +166,11 @@ def func(parser, options, args): if not os.path.isfile(base): raise CmdException, 'Branch "%s" is not controlled by StGit' % branch - print 'Protecting branch "%s"...' % branch + print 'Protecting branch "%s"...' % branch, + sys.stdout.flush() stack.Series(branch).protect() + print 'done' + return elif options.rename: @@ -185,12 +193,18 @@ def func(parser, options, args): if not os.path.isfile(base): raise CmdException, 'Branch "%s" is not controlled by StGit' % branch - print 'Unprotecting branch "%s"...' % branch + print 'Unprotecting branch "%s"...' % branch, + sys.stdout.flush() stack.Series(branch).unprotect() + print 'done' + return elif len(args) == 1: + if args[0] == git.get_head_file(): + raise CmdException, 'Branch "%s" is already the current branch' % args[0] + print 'Switching to branch "%s"...' % args[0], sys.stdout.flush()