From c395cc3521ee7f080877560e149a87b7b67021f6 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 27 Jun 2012 09:39:49 -0400 Subject: [PATCH] branch: add -s option to immediately switch to newly-created branch --- README | 3 ++- jsvn | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README b/README index 312a812..dbb6a34 100644 --- a/README +++ b/README @@ -22,10 +22,11 @@ Implemented subcommands: - bad mark the current revision as bad - containing the change sought - good mark the current revision as good - older than the change sought - reset terminate the bisect operation and return to the original revision - branch[es] [[-d] ] + branch[es] [-d] [-s] [] - with no arguments, list branches with '*' by the current one - with -d, delete - otherwise, create a new branch from the current one + - also switch to the new branch if -s is given tag[s] [[-d] ] | [-m ] - with no arguments, list tags - with -d, delete diff --git a/jsvn b/jsvn index 252046c..615bacd 100755 --- a/jsvn +++ b/jsvn @@ -437,7 +437,7 @@ Operations: def branch(argv, svn, out): argv = argv[1:] # strip 'branch' command - options, args = getopt.getopt(argv, 'd') + options, args = getopt.getopt(argv, 'ds') origin = get_svn_top_level(svn) root = get_svn_root_url(svn) if origin == '' or root == '': @@ -462,12 +462,15 @@ def branch(argv, svn, out): sys.stderr.write('Error: must supply branch name\n') return RET_ERR branch_name = args[0] + do_switch = False for opt, val in options: if opt == '-d': # delete branch Popen([svn, 'rm', root + '/branches/' + branch_name, '-m', "Removed branch '%s'" % branch_name], stdout=out).wait() return RET_OK + elif opt == '-s': + do_switch = True bl = get_svn_branch_list(svn) if branch_name in bl: sys.stderr.write('Error: branch %s already exists\n' % branch_name) @@ -475,6 +478,8 @@ def branch(argv, svn, out): comment = "Created '%s' branch" % branch_name branch_path = root + '/branches/' + branch_name Popen([svn, 'copy', origin, branch_path, '-m', comment], stdout=out).wait() + if do_switch: + return switch(['switch', branch_name], svn, out) return RET_OK def tag(argv, svn, out):