make stash ID argument to "stash show" optional

This commit is contained in:
Josh Holtrop 2012-03-26 15:33:29 -04:00
parent 3b4944f6f7
commit 09a6f91f49
2 changed files with 8 additions and 4 deletions

1
README
View File

@ -66,6 +66,7 @@ Implemented subcommands:
- <id> defaults to the newest stash object created - <id> defaults to the newest stash object created
show [id]: show [id]:
- display the diff stored in stash with ID <id> - display the diff stored in stash with ID <id>
- <id> defaults to the newest stash object created
drop [id]: drop [id]:
- delete stash object <id> - delete stash object <id>
- <id> defaults to the newest stash object created - <id> defaults to the newest stash object created

11
jsvn
View File

@ -68,6 +68,7 @@
# - <id> defaults to the newest stash object created # - <id> defaults to the newest stash object created
# show [id]: # show [id]:
# - display the diff stored in stash with ID <id> # - display the diff stored in stash with ID <id>
# - <id> defaults to the newest stash object created
# drop [id]: # drop [id]:
# - delete stash object <id> # - delete stash object <id>
# - <id> defaults to the newest stash object created # - <id> defaults to the newest stash object created
@ -843,9 +844,11 @@ def stash(argv, svn, out):
out.write('No stashes to pop\n') out.write('No stashes to pop\n')
os.chdir(owd) os.chdir(owd)
elif action == 'show': elif action == 'show':
if len(argv) >= 3: stash_ids = get_stash_ids(svn)
stash_id = int(argv[2]) if len(stash_ids) > 0:
stash_ids = get_stash_ids(svn) stash_id = stash_ids[-1]
if len(argv) >= 3:
stash_id = int(argv[2])
if stash_id in stash_ids: if stash_id in stash_ids:
stash_fname = get_stash_fname(svn, stash_id) stash_fname = get_stash_fname(svn, stash_id)
fd = open(stash_fname, 'r') fd = open(stash_fname, 'r')
@ -855,7 +858,7 @@ def stash(argv, svn, out):
else: else:
out.write('Invalid stash ID\n') out.write('Invalid stash ID\n')
else: else:
out.write('Usage: stash show <ID>\n') out.write('No stashes to show\n')
elif action == 'drop': elif action == 'drop':
stash_ids = get_stash_ids(svn) stash_ids = get_stash_ids(svn)
if len(stash_ids) > 0: if len(stash_ids) > 0: