@@ -434,18 +434,18 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
434
434
435
435
**Will** match normal ``hg(1)`` URLs, use :meth:`HgURL.is_valid` for that.
436
436
437
- >>> HgURL.is_valid(url='https://hg.mozilla.org/mozilla-central/libvcs.hg ')
437
+ >>> HgURL.is_valid(url='https://hg.mozilla.org/mozilla-central/libvcs')
438
438
True
439
439
440
440
>>> HgURL.is_valid(url='hg@hg.mozilla.org:MyProject/project')
441
441
True
442
442
443
443
Pip-style URLs:
444
444
445
- >>> HgURL.is_valid(url='hg+https://hg.mozilla.org/mozilla-central/project.hg ')
445
+ >>> HgURL.is_valid(url='hg+https://hg.mozilla.org/mozilla-central/project')
446
446
True
447
447
448
- >>> HgURL.is_valid(url='hg+ssh://hg@hg.mozilla.org:MyProject/project.hg ')
448
+ >>> HgURL.is_valid(url='hg+ssh://hg@hg.mozilla.org:MyProject/project')
449
449
True
450
450
451
451
>>> HgURL.is_valid(url='notaurl')
@@ -457,24 +457,24 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
457
457
unambigously narrow the type of VCS:
458
458
459
459
>>> HgURL.is_valid(
460
- ... url='hg+ssh://hg@hg.mozilla.org:MyProject/libvcs.hg ', is_explicit=True
460
+ ... url='hg+ssh://hg@hg.mozilla.org:mozilla-central/image ', is_explicit=True
461
461
... )
462
462
True
463
463
464
- Below, while it's GitHub , that doesn't necessarily mean that the URL itself
465
- is conclusively a `hg` URL (e.g. the pattern is too lax ):
464
+ Below, while it's hg.mozilla.org , that doesn't necessarily mean that the URL
465
+ itself is conclusively a `hg` URL (e.g. the pattern is too broad ):
466
466
467
467
>>> HgURL.is_valid(
468
- ... url='hg@hg.mozilla.org:MyProject/libvcs.hg ', is_explicit=True
468
+ ... url='hg@hg.mozilla.org:mozilla-central/image ', is_explicit=True
469
469
... )
470
470
False
471
471
472
- You could create a HgHub rule that consider hg.mozilla.org hostnames to be
472
+ You could create a Mozilla rule that consider hg.mozilla.org hostnames to be
473
473
exclusively hg:
474
474
475
- >>> HgHubRule = Rule(
475
+ >>> MozillaRule = Rule(
476
476
... # Since hg.mozilla.org exclusively serves hg repos, make explicit
477
- ... label='gh -rule',
477
+ ... label='mozilla -rule',
478
478
... description='Matches hg.mozilla.org https URLs, exact VCS match',
479
479
... pattern=re.compile(
480
480
... rf'''
@@ -492,21 +492,21 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
492
492
... }
493
493
... )
494
494
495
- >>> HgURL.rule_map.register(HgHubRule )
495
+ >>> HgURL.rule_map.register(MozillaRule )
496
496
497
497
>>> HgURL.is_valid(
498
- ... url='hg@hg.mozilla.org:MyProject/libvcs.hg ', is_explicit=True
498
+ ... url='hg@hg.mozilla.org:mozilla-central/image ', is_explicit=True
499
499
... )
500
500
True
501
501
502
- >>> HgURL(url='hg@hg.mozilla.org:MyProject/libvcs.hg ').rule
503
- 'gh -rule'
502
+ >>> HgURL(url='hg@hg.mozilla.org:mozilla-central/image ').rule
503
+ 'mozilla -rule'
504
504
505
505
This is just us cleaning up:
506
506
507
- >>> HgURL.rule_map.unregister('gh -rule')
507
+ >>> HgURL.rule_map.unregister('mozilla -rule')
508
508
509
- >>> HgURL(url='hg@hg.mozilla.org:MyProject/libvcs.hg ').rule
509
+ >>> HgURL(url='hg@hg.mozilla.org:mozilla-central/mozilla-rule ').rule
510
510
'core-hg-scp'
511
511
"""
512
512
return super ().is_valid (url = url , is_explicit = is_explicit )
0 commit comments