D4790: wireprotov2: derive "required" from presence of default value

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Wed Oct 3 15:04:40 UTC 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG582676acaf6d: wireprotov2: derive "required" from presence of default value (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4790?vs=11473&id=11604

REVISION DETAIL
  https://phab.mercurial-scm.org/D4790

AFFECTED FILES
  mercurial/wireprotov2server.py

CHANGE DETAILS

diff --git a/mercurial/wireprotov2server.py b/mercurial/wireprotov2server.py
--- a/mercurial/wireprotov2server.py
+++ b/mercurial/wireprotov2server.py
@@ -477,9 +477,6 @@
           A callable returning the default value for this argument. If not
           specified, ``None`` will be the default value.
 
-       ``required``
-          Bool indicating whether the argument is required.
-
        ``example``
           An example value for this argument.
 
@@ -535,13 +532,9 @@
             raise error.ProgrammingError('%s argument for command %s does not '
                                          'declare example field' % (arg, name))
 
-        if 'default' in meta and meta.get('required'):
-            raise error.ProgrammingError('%s argument for command %s is marked '
-                                         'as required but has a default value' %
-                                         (arg, name))
+        meta['required'] = 'default' not in meta
 
         meta.setdefault('default', lambda: None)
-        meta.setdefault('required', False)
         meta.setdefault('validvalues', None)
 
     def register(func):
@@ -570,14 +563,17 @@
     args={
         'noderange': {
             'type': 'list',
+            'default': lambda: None,
             'example': [[b'0123456...'], [b'abcdef...']],
         },
         'nodes': {
             'type': 'list',
+            'default': lambda: None,
             'example': [b'0123456...'],
         },
         'nodesdepth': {
             'type': 'int',
+            'default': lambda: None,
             'example': 10,
         },
         'fields': {
@@ -746,7 +742,6 @@
         },
         'nodes': {
             'type': 'list',
-            'required': True,
             'example': [b'0123456...'],
         },
         'fields': {
@@ -757,7 +752,6 @@
         },
         'path': {
             'type': 'bytes',
-            'required': True,
             'example': b'foo.txt',
         }
     },
@@ -848,7 +842,6 @@
     args={
         'namespace': {
             'type': 'bytes',
-            'required': True,
             'example': b'ns',
         },
     },
@@ -865,7 +858,6 @@
     args={
         'key': {
             'type': 'bytes',
-            'required': True,
             'example': b'foo',
         },
     },
@@ -883,7 +875,6 @@
     args={
         'nodes': {
             'type': 'list',
-            'required': True,
             'example': [b'0123456...'],
         },
         'haveparents': {
@@ -899,7 +890,6 @@
         },
         'tree': {
             'type': 'bytes',
-            'required': True,
             'example': b'',
         },
     },
@@ -956,22 +946,18 @@
     args={
         'namespace': {
             'type': 'bytes',
-            'required': True,
             'example': b'ns',
         },
         'key': {
             'type': 'bytes',
-            'required': True,
             'example': b'key',
         },
         'old': {
             'type': 'bytes',
-            'required': True,
             'example': b'old',
         },
         'new': {
             'type': 'bytes',
-            'required': True,
             'example': 'new',
         },
     },



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list