@@ -114,8 +114,7 @@ def validate_manifest_main(argv: Sequence[str] | None = None) -> int:
114114META = 'meta'
115115
116116
117- # should inherit from cfgv.Conditional if sha support is dropped
118- class WarnMutableRev (cfgv .ConditionalOptional ):
117+ class WarnMutableRev (cfgv .Conditional ):
119118 def check (self , dct : dict [str , Any ]) -> None :
120119 super ().check (dct )
121120
@@ -171,36 +170,6 @@ def check(self, dct: dict[str, Any]) -> None:
171170 )
172171
173172
174- class MigrateShaToRev :
175- key = 'rev'
176-
177- @staticmethod
178- def _cond (key : str ) -> cfgv .Conditional :
179- return cfgv .Conditional (
180- key , cfgv .check_string ,
181- condition_key = 'repo' ,
182- condition_value = cfgv .NotIn (LOCAL , META ),
183- ensure_absent = True ,
184- )
185-
186- def check (self , dct : dict [str , Any ]) -> None :
187- if dct .get ('repo' ) in {LOCAL , META }:
188- self ._cond ('rev' ).check (dct )
189- self ._cond ('sha' ).check (dct )
190- elif 'sha' in dct and 'rev' in dct :
191- raise cfgv .ValidationError ('Cannot specify both sha and rev' )
192- elif 'sha' in dct :
193- self ._cond ('sha' ).check (dct )
194- else :
195- self ._cond ('rev' ).check (dct )
196-
197- def apply_default (self , dct : dict [str , Any ]) -> None :
198- if 'sha' in dct :
199- dct ['rev' ] = dct .pop ('sha' )
200-
201- remove_default = cfgv .Required .remove_default
202-
203-
204173def _entry (modname : str ) -> str :
205174 """the hook `entry` is passed through `shlex.split()` by the command
206175 runner, so to prevent issues with spaces and backslashes (on Windows)
@@ -324,14 +293,11 @@ def check(self, dct: dict[str, Any]) -> None:
324293 'repo' , META ,
325294 ),
326295
327- MigrateShaToRev (),
328296 WarnMutableRev (
329- 'rev' ,
330- cfgv .check_string ,
331- '' ,
332- 'repo' ,
333- cfgv .NotIn (LOCAL , META ),
334- True ,
297+ 'rev' , cfgv .check_string ,
298+ condition_key = 'repo' ,
299+ condition_value = cfgv .NotIn (LOCAL , META ),
300+ ensure_absent = True ,
335301 ),
336302 cfgv .WarnAdditionalKeys (('repo' , 'rev' , 'hooks' ), warn_unknown_keys_repo ),
337303)
0 commit comments