Patchwork [1,of,2] shelve: refactor allowables to specify sets of valid operations

login
register
mail settings
Submitter Tony Tung
Date May 15, 2015, 4:43 a.m.
Message ID <78db3bff2fcfdaeb2e50.1431665015@andromeda.local>
Download mbox | patch
Permalink /patch/9085/
State Accepted
Headers show

Comments

Tony Tung - May 15, 2015, 4:43 a.m.
# HG changeset patch
# User Tony Tung <tonytung@fb.com>
# Date 1429042987 14400
#      Tue Apr 14 16:23:07 2015 -0400
# Node ID 78db3bff2fcfdaeb2e50f979454e59e707f26427
# Parent  d1bd0fd07ee6adf4ab3be2b0a0a7c0df54d55abf
shelve: refactor allowables to specify sets of valid operations

This allows us to have --patch and --stat as standalone operations that
don't require --list, as well as pairing them with --list.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -693,21 +693,21 @@ 
     cmdutil.checkunfinished(repo)
 
     allowables = [
-        ('addremove', 'create'), # 'create' is pseudo action
-        ('cleanup', 'cleanup'),
-#       ('date', 'create'), # ignored for passing '--date "0 0"' in tests
-        ('delete', 'delete'),
-        ('edit', 'create'),
-        ('list', 'list'),
-        ('message', 'create'),
-        ('name', 'create'),
-        ('patch', 'list'),
-        ('stat', 'list'),
+        ('addremove', set(['create'])), # 'create' is pseudo action
+        ('cleanup', set(['cleanup'])),
+#       ('date', set(['create'])), # ignored for passing '--date "0 0"' in tests
+        ('delete', set(['delete'])),
+        ('edit', set(['create'])),
+        ('list', set(['list'])),
+        ('message', set(['create'])),
+        ('name', set(['create'])),
+        ('patch', set(['list'])),
+        ('stat', set(['list'])),
     ]
     def checkopt(opt):
         if opts[opt]:
             for i, allowable in allowables:
-                if opts[i] and opt != allowable:
+                if opts[i] and opt not in allowable:
                     raise util.Abort(_("options '--%s' and '--%s' may not be "
                                        "used together") % (opt, i))
             return True