10000 !url hg more · vcs-python/libvcs@ad87abd · GitHub
[go: up one dir, main page]

Skip to content

Commit ad87abd

Browse files
committed
!url hg more
1 parent 4b7d136 commit ad87abd

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/libvcs/url/hg.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -434,18 +434,18 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
434434
435435
**Will** match normal ``hg(1)`` URLs, use :meth:`HgURL.is_valid` for that.
436436
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')
438438
True
439439
440440
>>> HgURL.is_valid(url='hg@hg.mozilla.org:MyProject/project')
441441
True
442442
443443
Pip-style URLs:
444444
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')
446446
True
447447
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')
449449
True
450450
451451
>>> HgURL.is_valid(url='notaurl')
@@ -457,24 +457,24 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
457457
unambigously narrow the type of VCS:
458458
459459
>>> 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
461461
... )
462462
True
463463
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):
466466
467467
>>> 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
469469
... )
470470
False
471471
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
473473
exclusively hg:
474474
475-
>>> HgHubRule = Rule(
475+
>>> MozillaRule = Rule(
476476
... # Since hg.mozilla.org exclusively serves hg repos, make explicit
477-
... label='gh-rule',
477+
... label='mozilla-rule',
478478
... description='Matches hg.mozilla.org https URLs, exact VCS match',
479479
... pattern=re.compile(
480480
... rf'''
@@ -492,21 +492,21 @@ def is_valid(cls, url: str, is_explicit: Optional[bool] = None) -> bool:
492492
... }
493493
... )
494494
495-
>>> HgURL.rule_map.register(HgHubRule)
495+
>>> HgURL.rule_map.register(MozillaRule)
496496
497497
>>> 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
499499
... )
500500
True
501501
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'
504504
505505
This is just us cleaning up:
506506
507-
>>> HgURL.rule_map.unregister('gh-rule')
507+
>>> HgURL.rule_map.unregister('mozilla-rule')
508508
509-
>>> HgURL(url='hg@hg.mozilla.org:MyProject/libvcs.hg').rule
509+
>>> HgURL(url='hg@hg.mozilla.org:mozilla-central/mozilla-rule').rule
510510
'core-hg-scp'
511511
"""
512512
return super().is_valid(url=url, is_explicit=is_explicit)

0 commit comments

Comments
 (0)
0