##// END OF EJS Templates
shelve: refactor option combination check to easily add new ones...
FUJIWARA Katsunori -
r21851:aad28ff8 default
parent child Browse files
Show More
@@ -675,20 +675,31 b' def shelvecmd(ui, repo, *pats, **opts):'
675 '''
675 '''
676 cmdutil.checkunfinished(repo)
676 cmdutil.checkunfinished(repo)
677
677
678 def checkopt(opt, incompatible):
678 allowables = [
679 ('addremove', 'create'), # 'create' is pseudo action
680 ('cleanup', 'cleanup'),
681 # ('date', 'create'), # ignored for passing '--date "0 0"' in tests
682 ('delete', 'delete'),
683 ('list', 'list'),
684 ('message', 'create'),
685 ('name', 'create'),
686 ('patch', 'list'),
687 ('stat', 'list'),
688 ]
689 def checkopt(opt):
679 if opts[opt]:
690 if opts[opt]:
680 for i in incompatible.split():
691 for i, allowable in allowables:
681 if opts[i]:
692 if opts[i] and opt != allowable:
682 raise util.Abort(_("options '--%s' and '--%s' may not be "
693 raise util.Abort(_("options '--%s' and '--%s' may not be "
683 "used together") % (opt, i))
694 "used together") % (opt, i))
684 return True
695 return True
685 if checkopt('cleanup', 'addremove delete list message name patch stat'):
696 if checkopt('cleanup'):
686 if pats:
697 if pats:
687 raise util.Abort(_("cannot specify names when using '--cleanup'"))
698 raise util.Abort(_("cannot specify names when using '--cleanup'"))
688 return cleanupcmd(ui, repo)
699 return cleanupcmd(ui, repo)
689 elif checkopt('delete', 'addremove cleanup list message name patch stat'):
700 elif checkopt('delete'):
690 return deletecmd(ui, repo, pats)
701 return deletecmd(ui, repo, pats)
691 elif checkopt('list', 'addremove cleanup delete message name'):
702 elif checkopt('list'):
692 return listcmd(ui, repo, pats, opts)
703 return listcmd(ui, repo, pats, opts)
693 else:
704 else:
694 for i in ('patch', 'stat'):
705 for i in ('patch', 'stat'):
General Comments 0
You need to be logged in to leave comments. Login now