break up stash subcommand handlers into their own functions
This commit is contained in:
parent
9ffbd09477
commit
f9c474a53f
48
jsvn
48
jsvn
@ -1225,15 +1225,7 @@ def revert_h(argv, svn, out, config):
|
||||
break
|
||||
return RET_OK if did_something else RET_REEXEC
|
||||
|
||||
def stash_h(argv, svn, out, config):
|
||||
argv = argv[1:] # strip 'stash' command
|
||||
action = 'save'
|
||||
if len(argv) >= 1:
|
||||
if not argv[0].startswith('-'):
|
||||
action = argv[0]
|
||||
argv = argv[1:]
|
||||
# now argv only contains options/arguments to the stash subcommand itself
|
||||
if action == 'save':
|
||||
def stash_save_h(argv, svn, out, config):
|
||||
keep_wc = False
|
||||
options, args = getopt.getopt(argv, 'k')
|
||||
for opt, val in options:
|
||||
@ -1321,7 +1313,9 @@ def stash_h(argv, svn, out, config):
|
||||
fh.close()
|
||||
out.write('Created stash %d\n' % stash_idx)
|
||||
os.chdir(owd)
|
||||
elif action == 'list':
|
||||
return RET_OK
|
||||
|
||||
def stash_list_h(argv, svn, out, config):
|
||||
stash_ids = get_stash_ids(svn)
|
||||
for si in reversed(stash_ids):
|
||||
ins_text = ''
|
||||
@ -1376,7 +1370,9 @@ def stash_h(argv, svn, out, config):
|
||||
ansi_reset(out)
|
||||
out.write(')')
|
||||
out.write('\n')
|
||||
elif action == 'pop':
|
||||
return RET_OK
|
||||
|
||||
def stash_pop_h(argv, svn, out, config):
|
||||
keep = False
|
||||
options, args = getopt.getopt(argv, 'k')
|
||||
for opt, val in options:
|
||||
@ -1403,7 +1399,9 @@ def stash_h(argv, svn, out, config):
|
||||
else:
|
||||
out.write('No stashes to pop\n')
|
||||
os.chdir(owd)
|
||||
elif action == 'show':
|
||||
return RET_OK
|
||||
|
||||
def stash_show_h(argv, svn, out, config):
|
||||
stash_ids = get_stash_ids(svn)
|
||||
if len(stash_ids) > 0:
|
||||
stash_id = stash_ids[-1]
|
||||
@ -1420,7 +1418,9 @@ def stash_h(argv, svn, out, config):
|
||||
out.write('Invalid stash ID\n')
|
||||
else:
|
||||
out.write('No stashes to show\n')
|
||||
elif action == 'drop':
|
||||
return RET_OK
|
||||
|
||||
def stash_drop_h(argv, svn, out, config):
|
||||
stash_ids = get_stash_ids(svn)
|
||||
if len(stash_ids) > 0:
|
||||
stash_id = stash_ids[-1]
|
||||
@ -1431,10 +1431,28 @@ def stash_h(argv, svn, out, config):
|
||||
out.write('Dropped stash %d\n' % stash_id)
|
||||
else:
|
||||
out.write('No stashes to drop\n')
|
||||
else:
|
||||
out.write('Unknown action "%s"\n' % action)
|
||||
return RET_OK
|
||||
|
||||
def stash_h(argv, svn, out, config):
|
||||
argv = argv[1:] # strip 'stash' command
|
||||
action = 'save'
|
||||
if len(argv) >= 1:
|
||||
if not argv[0].startswith('-'):
|
||||
action = argv[0]
|
||||
argv = argv[1:]
|
||||
# now argv only contains options/arguments to the stash subcommand itself
|
||||
actions = {
|
||||
'save': stash_save_h,
|
||||
'list': stash_list_h,
|
||||
'pop': stash_pop_h,
|
||||
'show': stash_show_h,
|
||||
'drop': stash_drop_h
|
||||
}
|
||||
if action in actions:
|
||||
return actions[action](argv, svn, out, config)
|
||||
sys.stderr.write('Unknown action "%s"\n' % action)
|
||||
return RET_ERR
|
||||
|
||||
def root_h(argv, svn, out, config):
|
||||
out.write(get_svn_root_url(svn) + '\n')
|
||||
return RET_OK
|
||||
|
Loading…
x
Reference in New Issue
Block a user