Mercurial > public > mercurial-scm > hg-stable
diff hgext/shelve.py @ 38715:905b66681004
shelve: pick the most recent shelve if none specified for --patch/--stat
Differential Revision: https://phab.mercurial-scm.org/D3950
author | Danny Hooper <hooper@google.com> |
---|---|
date | Mon, 16 Jul 2018 14:04:48 -0700 |
parents | abcf500d527c |
children | e7aa113b14f7 |
line wrap: on
line diff
--- a/hgext/shelve.py Fri Jul 13 13:48:56 2018 -0700 +++ b/hgext/shelve.py Mon Jul 16 14:04:48 2018 -0700 @@ -594,10 +594,15 @@ for chunk, label in patch.diffstatui(difflines, width=width): ui.write(chunk, label=label) -def patchcmds(ui, repo, pats, opts, subcommand): +def patchcmds(ui, repo, pats, opts): """subcommand that displays shelves""" if len(pats) == 0: - raise error.Abort(_("--%s expects at least one shelf") % subcommand) + shelves = listshelves(repo) + if not shelves: + raise error.Abort(_("there are no shelves to show")) + mtime, name = shelves[0] + sname = util.split(name)[1] + pats = [sname] for shelfname in pats: if not shelvedfile(repo, shelfname, patchextension).exists(): @@ -1082,10 +1087,8 @@ return deletecmd(ui, repo, pats) elif checkopt('list'): return listcmd(ui, repo, pats, opts) - elif checkopt('patch'): - return patchcmds(ui, repo, pats, opts, subcommand='patch') - elif checkopt('stat'): - return patchcmds(ui, repo, pats, opts, subcommand='stat') + elif checkopt('patch') or checkopt('stat'): + return patchcmds(ui, repo, pats, opts) else: return createcmd(ui, repo, pats, opts)