##// END OF EJS Templates
shelve: allow --patch and --stat without --list for a single shelf...
Tony Tung -
r25104:d6453f6f default
parent child Browse files
Show More
@@ -361,6 +361,17 def listcmd(ui, repo, pats, opts):
361 finally:
361 finally:
362 fp.close()
362 fp.close()
363
363
364 def singlepatchcmds(ui, repo, pats, opts, subcommand):
365 """subcommand that displays a single shelf"""
366 if len(pats) != 1:
367 raise util.Abort(_("--%s expects a single shelf") % subcommand)
368 shelfname = pats[0]
369
370 if not shelvedfile(repo, shelfname, 'patch').exists():
371 raise util.Abort(_("cannot find shelf %s") % shelfname)
372
373 listcmd(ui, repo, pats, opts)
374
364 def checkparents(repo, state):
375 def checkparents(repo, state):
365 """check parent while resuming an unshelve"""
376 """check parent while resuming an unshelve"""
366 if state.parents != repo.dirstate.parents():
377 if state.parents != repo.dirstate.parents():
@@ -699,8 +710,8 def shelvecmd(ui, repo, *pats, **opts):
699 ('list', set(['list'])),
710 ('list', set(['list'])),
700 ('message', set(['create'])),
711 ('message', set(['create'])),
701 ('name', set(['create'])),
712 ('name', set(['create'])),
702 ('patch', set(['list'])),
713 ('patch', set(['patch', 'list'])),
703 ('stat', set(['list'])),
714 ('stat', set(['stat', 'list'])),
704 ]
715 ]
705 def checkopt(opt):
716 def checkopt(opt):
706 if opts[opt]:
717 if opts[opt]:
@@ -717,11 +728,11 def shelvecmd(ui, repo, *pats, **opts):
717 return deletecmd(ui, repo, pats)
728 return deletecmd(ui, repo, pats)
718 elif checkopt('list'):
729 elif checkopt('list'):
719 return listcmd(ui, repo, pats, opts)
730 return listcmd(ui, repo, pats, opts)
731 elif checkopt('patch'):
732 return singlepatchcmds(ui, repo, pats, opts, subcommand='patch')
733 elif checkopt('stat'):
734 return singlepatchcmds(ui, repo, pats, opts, subcommand='stat')
720 else:
735 else:
721 for i in ('patch', 'stat'):
722 if opts[i]:
723 raise util.Abort(_("option '--%s' may not be "
724 "used when shelving a change") % (i,))
725 return createcmd(ui, repo, pats, opts)
736 return createcmd(ui, repo, pats, opts)
726
737
727 def extsetup(ui):
738 def extsetup(ui):
@@ -862,4 +862,45 Test interactive shelve
862 c
862 c
863 x
863 x
864 x
864 x
865 $ cd ..
865
866 shelve --patch and shelve --stat should work with a single valid shelfname
867
868 $ hg up --clean .
869 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
870 $ hg shelve --list
871 $ echo 'patch a' > shelf-patch-a
872 $ hg add shelf-patch-a
873 $ hg shelve
874 shelved as default
875 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
876 $ echo 'patch b' > shelf-patch-b
877 $ hg add shelf-patch-b
878 $ hg shelve
879 shelved as default-01
880 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
881 $ hg shelve --patch default default-01
882 abort: --patch expects a single shelf
883 [255]
884 $ hg shelve --stat default default-01
885 abort: --stat expects a single shelf
886 [255]
887 $ hg shelve --patch default
888 default (* ago) changes to 'create conflict' (glob)
889
890 diff --git a/shelf-patch-a b/shelf-patch-a
891 new file mode 100644
892 --- /dev/null
893 +++ b/shelf-patch-a
894 @@ -0,0 +1,1 @@
895 +patch a
896 $ hg shelve --stat default
897 default (* ago) changes to 'create conflict' (glob)
898 shelf-patch-a | 1 +
899 1 files changed, 1 insertions(+), 0 deletions(-)
900 $ hg shelve --patch nonexistentshelf
901 abort: cannot find shelf nonexistentshelf
902 [255]
903 $ hg shelve --stat nonexistentshelf
904 abort: cannot find shelf nonexistentshelf
905 [255]
906
General Comments 0
You need to be logged in to leave comments. Login now