Mercurial URL Parser - libvcs.url.hg¶
For hg, aka hg(1).
Detect, parse, and validate hg (Mercurial) URLs.
Detect:
HgURL.is_valid()Parse:
HgURLcompare to
urllib.parse.ParseResultOutput
hg(1)URL:HgURL.to_url()
Note
Use Mercurial at your job or project? This module welcomes a champion / maintainer to assure support is top-tier. Stop by the project tracker and make yourself known. We won’t stabilize any APIs until we’re satisfied support is up to snuff and is bullet proofed.
-
libvcs.url.hg.DEFAULT_RULES: list[Rule] = [Rule(label=core-hg, description=Vanilla hg pattern, pattern=re.compile('\n ^\n (?P<scheme>\n (\n http|https|ssh\n )\n )\n\n ://\n \n ((?P<user>[^/:@]+)@)?\n\n \n (?P<hostname>([^/:]+))\n (:(?P<port>\\d{1,5}))?\n, re.VERBOSE), defaults={}), Rule(label=core-hg-scp, description=Vanilla scp(1) / ssh(1) type URL, pattern=re.compile("\n ^(?P<scheme>ssh)?\n \n ((?P<user>[^/:@]+)@)?\n\n \n # Server, e.g. 'github.com'.\n (?P<hostname>([^/:]+))\n (?P<separator>:)\n # The server-side path. e.g. 'use, re.VERBOSE), defaults={'username': 'hg'})]¶
Core regular expressions. These are patterns understood by
hg(1)
-
libvcs.url.hg.PIP_DEFAULT_RULES: list[Rule] = [Rule(label=pip-url, description=pip-style hg URL, pattern=re.compile('\n ^\n (?P<scheme>\n (\n hg\\+ssh|\n hg\\+https|\n hg\\+http|\n hg\\+file\n )\n )\n\n ://\n \n ((?P<user>[^/:@]+)@)?\n\n \n , re.VERBOSE), defaults={}, is_explicit=True), Rule(label=pip-file-url, description=pip-style hg+file:// URL, pattern=re.compile('\n (?P<scheme>hg\\+file)://\n (?P<path>.*)\n ', re.VERBOSE), defaults={}, is_explicit=True)]¶
pip-style hg URLs.
Examples of PIP-style hg URLs (via pip.pypa.io):
MyProject @ hg+http://hg.myproject.org/MyProject MyProject @ hg+https://hg.myproject.org/MyProject MyProject @ hg+ssh://hg.myproject.org/MyProject MyProject @ hg+file:///home/user/projects/MyProject
Refs (via pip.pypa.io):
MyProject @ hg+http://hg.example.com/MyProject@da39a3ee5e6b MyProject @ hg+http://hg.example.com/MyProject@2019 MyProject @ hg+http://hg.example.com/MyProject@v1.0 MyProject @ hg+http://hg.example.com/MyProject@special_feature
Notes
-
class libvcs.url.hg.HgBaseURL¶
Bases:
URLProtocol,SkipDefaultFieldsReprMixinMercurial repository location. Parses URLs on initialization.
Examples
>>> HgBaseURL(url='https://hg.mozilla.org/mozilla-central/') HgBaseURL(url=https://hg.mozilla.org/mozilla-central/, scheme=https, hostname=hg.mozilla.org, path=mozilla-central/, rule=core-hg)
>>> myrepo = HgURL(url='https://hg.mozilla.org/mozilla-central/')
>>> myrepo.hostname 'hg.mozilla.org'
>>> myrepo.path 'mozilla-central/'
>>> HgBaseURL.is_valid(url='ssh://username@machinename/path/to/repo') True
>>> HgBaseURL(url='ssh://username@machinename/path/to/repo') HgBaseURL(url=ssh://username@machinename/path/to/repo, scheme=ssh, user=username, hostname=machinename, path=path/to/repo, rule=core-hg)
Compatibility checking:
HgURL.is_valid()URLs compatible with
hg(1):HgURL.to_url()
-
class libvcs.url.hg.HgPipURL¶
Bases:
HgBaseURL,URLProtocol,SkipDefaultFieldsReprMixinSupports pip hg URLs.
-
class libvcs.url.hg.HgURL¶
Bases:
HgPipURL,HgBaseURL,URLProtocol,SkipDefaultFieldsReprMixinBatteries included URL Parser. Supports hg(1) and pip URLs.
Ancestors (MRO) This URL parser inherits methods and attributes from the following parsers: