allow optional source argument to "branch"
This commit is contained in:
parent
8dc3cc969e
commit
3b7bf12da8
25
README
25
README
@ -27,11 +27,14 @@ Implemented subcommands:
|
|||||||
- bad mark the current revision as bad - containing the change sought
|
- bad mark the current revision as bad - containing the change sought
|
||||||
- good mark the current revision as good - older than 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
|
- reset terminate the bisect operation and return to the original revision
|
||||||
branch[es] [-d] [-s] [<branch_name>]
|
branch[es]
|
||||||
- with no arguments, list branches with '*' by the current one
|
- branch: list branches with '*' by the current one
|
||||||
- with -d, delete <branch>
|
- branch -d name: delete branch <name>
|
||||||
- otherwise, create a new branch from the current one
|
- branch [-s] name [source[@rev]]: create branch <name>
|
||||||
- also switch to the new branch if -s is given
|
- if <source> is given it is resolved as a reference name (can be 'trunk',
|
||||||
|
or a tag or branch name)
|
||||||
|
- if <source> is not given the HEAD of the current working-copy URL is used.
|
||||||
|
- also switch to the new branch if -s is given
|
||||||
diff
|
diff
|
||||||
- allow specifying ref1..ref2 syntax to show the diff between two references
|
- allow specifying ref1..ref2 syntax to show the diff between two references
|
||||||
- references can be tag names, branch names, or 'trunk'
|
- references can be tag names, branch names, or 'trunk'
|
||||||
@ -78,12 +81,12 @@ Implemented subcommands:
|
|||||||
- falls back to Subversion "switch" if <short_name> doesn't exist
|
- falls back to Subversion "switch" if <short_name> doesn't exist
|
||||||
tag[s]
|
tag[s]
|
||||||
- tag: list tags
|
- tag: list tags
|
||||||
- tag -d <name>: delete tag <name>
|
- tag -d name: delete tag <name>
|
||||||
- tag -m <old> <new>: rename tag <old> to <new>
|
- tag -m old new: rename tag <old> to <new>
|
||||||
- tag <name> [source_ref[@rev]]: create tag <name>; if source_ref is given
|
- tag name [source[@rev]]: create tag <name>
|
||||||
it is resolved as a reference name (can be 'trunk', or another tag or a
|
- if <source> is given it is resolved as a reference name (can be 'trunk',
|
||||||
branch name); if source is not given the HEAD of the current working-
|
or another tag or a branch name)
|
||||||
copy URL is used
|
- if <source> is not given the HEAD of the current working-copy URL is used.
|
||||||
url
|
url
|
||||||
- output repository URL of current working directory
|
- output repository URL of current working directory
|
||||||
users
|
users
|
||||||
|
44
jsvn
44
jsvn
@ -679,6 +679,9 @@ Operations:
|
|||||||
update_h(['update', '-r%d' % rev], svn, out, config)
|
update_h(['update', '-r%d' % rev], svn, out, config)
|
||||||
return RET_OK
|
return RET_OK
|
||||||
|
|
||||||
|
# branch # list branches
|
||||||
|
# branch -d name # delete branch <name>
|
||||||
|
# branch [-s] name [source[@rev]] # create branch <name> [from <source> [at revision <rev>]]
|
||||||
def branch_h(argv, svn, out, config):
|
def branch_h(argv, svn, out, config):
|
||||||
argv = argv[1:] # strip 'branch' command
|
argv = argv[1:] # strip 'branch' command
|
||||||
options, args = getopt.getopt(argv, 'ds')
|
options, args = getopt.getopt(argv, 'ds')
|
||||||
@ -687,7 +690,19 @@ def branch_h(argv, svn, out, config):
|
|||||||
if origin == '' or root == '':
|
if origin == '' or root == '':
|
||||||
sys.stderr.write("Could not determine origin/root URL\n")
|
sys.stderr.write("Could not determine origin/root URL\n")
|
||||||
return RET_ERR
|
return RET_ERR
|
||||||
if len(options) == 0 and len(args) == 0:
|
do_switch = False
|
||||||
|
for opt, val in options:
|
||||||
|
if opt == '-d':
|
||||||
|
# delete branch
|
||||||
|
if len(args) < 1:
|
||||||
|
sys.stderr.write('Must supply branch name\n')
|
||||||
|
return RET_ERR
|
||||||
|
Popen([svn, 'rm', root + '/branches/' + args[0], '-m',
|
||||||
|
"Removed branch '%s'" % args[0]], stdout=out).wait()
|
||||||
|
return RET_OK
|
||||||
|
elif opt == '-s':
|
||||||
|
do_switch = True
|
||||||
|
if len(args) == 0:
|
||||||
bl = ['trunk'] + get_svn_branch_list(svn)
|
bl = ['trunk'] + get_svn_branch_list(svn)
|
||||||
current = origin.split('/')[-1]
|
current = origin.split('/')[-1]
|
||||||
bl.sort()
|
bl.sort()
|
||||||
@ -702,26 +717,27 @@ def branch_h(argv, svn, out, config):
|
|||||||
ansi_reset(out)
|
ansi_reset(out)
|
||||||
out.write('\n')
|
out.write('\n')
|
||||||
return RET_OK
|
return RET_OK
|
||||||
if len(args) == 0:
|
|
||||||
sys.stderr.write('Error: must supply branch name\n')
|
|
||||||
return RET_ERR
|
|
||||||
branch_name = args[0]
|
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)
|
bl = get_svn_branch_list(svn)
|
||||||
if branch_name in bl:
|
if branch_name in bl:
|
||||||
sys.stderr.write('Error: branch %s already exists\n' % branch_name)
|
sys.stderr.write('Error: branch %s already exists\n' % branch_name)
|
||||||
return RET_ERR
|
return RET_ERR
|
||||||
comment = "Created '%s' branch" % branch_name
|
comment = "Created '%s' branch" % branch_name
|
||||||
branch_path = root + '/branches/' + branch_name
|
branch_path = root + '/branches/' + branch_name
|
||||||
Popen([svn, 'copy', origin, branch_path, '-m', comment], stdout=out).wait()
|
branch_source = origin
|
||||||
|
if len(args) >= 2:
|
||||||
|
source = args[1]
|
||||||
|
m = re.match(r'(.*?)(@\d+)?$', source)
|
||||||
|
if m is not None:
|
||||||
|
ref_name, rev_str = m.group(1, 2)
|
||||||
|
url, path = resolve_reference(svn, ref_name)
|
||||||
|
if url != '':
|
||||||
|
branch_source = url
|
||||||
|
if rev_str is not None:
|
||||||
|
branch_source += rev_str
|
||||||
|
else:
|
||||||
|
branch_source = source
|
||||||
|
Popen([svn, 'copy', branch_source, branch_path, '-m', comment], stdout=out).wait()
|
||||||
if do_switch:
|
if do_switch:
|
||||||
return switch_h(['switch', branch_name], svn, out, config)
|
return switch_h(['switch', branch_name], svn, out, config)
|
||||||
return RET_OK
|
return RET_OK
|
||||||
|
Loading…
x
Reference in New Issue
Block a user