equal
deleted
inserted
replaced
475 |
475 |
476 ``default`` |
476 ``default`` |
477 A callable returning the default value for this argument. If not |
477 A callable returning the default value for this argument. If not |
478 specified, ``None`` will be the default value. |
478 specified, ``None`` will be the default value. |
479 |
479 |
480 ``required`` |
|
481 Bool indicating whether the argument is required. |
|
482 |
|
483 ``example`` |
480 ``example`` |
484 An example value for this argument. |
481 An example value for this argument. |
485 |
482 |
486 ``validvalues`` |
483 ``validvalues`` |
487 Set of recognized values for this argument. |
484 Set of recognized values for this argument. |
533 |
530 |
534 if 'example' not in meta: |
531 if 'example' not in meta: |
535 raise error.ProgrammingError('%s argument for command %s does not ' |
532 raise error.ProgrammingError('%s argument for command %s does not ' |
536 'declare example field' % (arg, name)) |
533 'declare example field' % (arg, name)) |
537 |
534 |
538 if 'default' in meta and meta.get('required'): |
535 meta['required'] = 'default' not in meta |
539 raise error.ProgrammingError('%s argument for command %s is marked ' |
|
540 'as required but has a default value' % |
|
541 (arg, name)) |
|
542 |
536 |
543 meta.setdefault('default', lambda: None) |
537 meta.setdefault('default', lambda: None) |
544 meta.setdefault('required', False) |
|
545 meta.setdefault('validvalues', None) |
538 meta.setdefault('validvalues', None) |
546 |
539 |
547 def register(func): |
540 def register(func): |
548 if name in COMMANDS: |
541 if name in COMMANDS: |
549 raise error.ProgrammingError('%s command already registered ' |
542 raise error.ProgrammingError('%s command already registered ' |
568 @wireprotocommand( |
561 @wireprotocommand( |
569 'changesetdata', |
562 'changesetdata', |
570 args={ |
563 args={ |
571 'noderange': { |
564 'noderange': { |
572 'type': 'list', |
565 'type': 'list', |
|
566 'default': lambda: None, |
573 'example': [[b'0123456...'], [b'abcdef...']], |
567 'example': [[b'0123456...'], [b'abcdef...']], |
574 }, |
568 }, |
575 'nodes': { |
569 'nodes': { |
576 'type': 'list', |
570 'type': 'list', |
|
571 'default': lambda: None, |
577 'example': [b'0123456...'], |
572 'example': [b'0123456...'], |
578 }, |
573 }, |
579 'nodesdepth': { |
574 'nodesdepth': { |
580 'type': 'int', |
575 'type': 'int', |
|
576 'default': lambda: None, |
581 'example': 10, |
577 'example': 10, |
582 }, |
578 }, |
583 'fields': { |
579 'fields': { |
584 'type': 'set', |
580 'type': 'set', |
585 'default': set, |
581 'default': set, |
744 'default': lambda: False, |
740 'default': lambda: False, |
745 'example': True, |
741 'example': True, |
746 }, |
742 }, |
747 'nodes': { |
743 'nodes': { |
748 'type': 'list', |
744 'type': 'list', |
749 'required': True, |
|
750 'example': [b'0123456...'], |
745 'example': [b'0123456...'], |
751 }, |
746 }, |
752 'fields': { |
747 'fields': { |
753 'type': 'set', |
748 'type': 'set', |
754 'default': set, |
749 'default': set, |
755 'example': {b'parents', b'revision'}, |
750 'example': {b'parents', b'revision'}, |
756 'validvalues': {b'parents', b'revision'}, |
751 'validvalues': {b'parents', b'revision'}, |
757 }, |
752 }, |
758 'path': { |
753 'path': { |
759 'type': 'bytes', |
754 'type': 'bytes', |
760 'required': True, |
|
761 'example': b'foo.txt', |
755 'example': b'foo.txt', |
762 } |
756 } |
763 }, |
757 }, |
764 permission='pull') |
758 permission='pull') |
765 def filedata(repo, proto, haveparents, nodes, fields, path): |
759 def filedata(repo, proto, haveparents, nodes, fields, path): |
846 @wireprotocommand( |
840 @wireprotocommand( |
847 'listkeys', |
841 'listkeys', |
848 args={ |
842 args={ |
849 'namespace': { |
843 'namespace': { |
850 'type': 'bytes', |
844 'type': 'bytes', |
851 'required': True, |
|
852 'example': b'ns', |
845 'example': b'ns', |
853 }, |
846 }, |
854 }, |
847 }, |
855 permission='pull') |
848 permission='pull') |
856 def listkeysv2(repo, proto, namespace): |
849 def listkeysv2(repo, proto, namespace): |
863 @wireprotocommand( |
856 @wireprotocommand( |
864 'lookup', |
857 'lookup', |
865 args={ |
858 args={ |
866 'key': { |
859 'key': { |
867 'type': 'bytes', |
860 'type': 'bytes', |
868 'required': True, |
|
869 'example': b'foo', |
861 'example': b'foo', |
870 }, |
862 }, |
871 }, |
863 }, |
872 permission='pull') |
864 permission='pull') |
873 def lookupv2(repo, proto, key): |
865 def lookupv2(repo, proto, key): |
881 @wireprotocommand( |
873 @wireprotocommand( |
882 'manifestdata', |
874 'manifestdata', |
883 args={ |
875 args={ |
884 'nodes': { |
876 'nodes': { |
885 'type': 'list', |
877 'type': 'list', |
886 'required': True, |
|
887 'example': [b'0123456...'], |
878 'example': [b'0123456...'], |
888 }, |
879 }, |
889 'haveparents': { |
880 'haveparents': { |
890 'type': 'bool', |
881 'type': 'bool', |
891 'default': lambda: False, |
882 'default': lambda: False, |
897 'example': {b'parents', b'revision'}, |
888 'example': {b'parents', b'revision'}, |
898 'validvalues': {b'parents', b'revision'}, |
889 'validvalues': {b'parents', b'revision'}, |
899 }, |
890 }, |
900 'tree': { |
891 'tree': { |
901 'type': 'bytes', |
892 'type': 'bytes', |
902 'required': True, |
|
903 'example': b'', |
893 'example': b'', |
904 }, |
894 }, |
905 }, |
895 }, |
906 permission='pull') |
896 permission='pull') |
907 def manifestdata(repo, proto, haveparents, nodes, fields, tree): |
897 def manifestdata(repo, proto, haveparents, nodes, fields, tree): |
954 @wireprotocommand( |
944 @wireprotocommand( |
955 'pushkey', |
945 'pushkey', |
956 args={ |
946 args={ |
957 'namespace': { |
947 'namespace': { |
958 'type': 'bytes', |
948 'type': 'bytes', |
959 'required': True, |
|
960 'example': b'ns', |
949 'example': b'ns', |
961 }, |
950 }, |
962 'key': { |
951 'key': { |
963 'type': 'bytes', |
952 'type': 'bytes', |
964 'required': True, |
|
965 'example': b'key', |
953 'example': b'key', |
966 }, |
954 }, |
967 'old': { |
955 'old': { |
968 'type': 'bytes', |
956 'type': 'bytes', |
969 'required': True, |
|
970 'example': b'old', |
957 'example': b'old', |
971 }, |
958 }, |
972 'new': { |
959 'new': { |
973 'type': 'bytes', |
960 'type': 'bytes', |
974 'required': True, |
|
975 'example': 'new', |
961 'example': 'new', |
976 }, |
962 }, |
977 }, |
963 }, |
978 permission='push') |
964 permission='push') |
979 def pushkeyv2(repo, proto, namespace, key, old, new): |
965 def pushkeyv2(repo, proto, namespace, key, old, new): |