[Updated] D10446: urlutil: extract `chain_path` in a function
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Sat May 15 23:22:00 UTC 2021
Closed by commit rHG26b3953ba1b0: urlutil: extract `chain_path` in a function (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10446?vs=27418&id=27923
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10446/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D10446
AFFECTED FILES
mercurial/utils/urlutil.py
CHANGE DETAILS
diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py
--- a/mercurial/utils/urlutil.py
+++ b/mercurial/utils/urlutil.py
@@ -611,7 +611,7 @@
self[name] = path(ui, name, rawloc=loc, suboptions=sub_opts)
for name, p in sorted(self.items()):
- p.chain_path(ui, self)
+ self[name] = _chain_path(p, ui, self)
def getpath(self, ui, name, default=None):
"""Return a ``path`` from a string, falling back to default.
@@ -704,6 +704,33 @@
return value
+def _chain_path(path, ui, paths):
+ """return the result of "path://" logic applied on a given path"""
+ if path.url.scheme == b'path':
+ assert path.url.path is None
+ subpath = paths.get(path.url.host)
+ if subpath is None:
+ m = _(b'cannot use `%s`, "%s" is not a known path')
+ m %= (path.rawloc, path.url.host)
+ raise error.Abort(m)
+ if subpath.raw_url.scheme == b'path':
+ m = _(b'cannot use `%s`, "%s" is also defined as a `path://`')
+ m %= (path.rawloc, path.url.host)
+ raise error.Abort(m)
+ path.url = subpath.url
+ path.rawloc = subpath.rawloc
+ path.loc = subpath.loc
+ if path.branch is None:
+ path.branch = subpath.branch
+ else:
+ base = path.rawloc.rsplit(b'#', 1)[0]
+ path.rawloc = b'%s#%s' % (base, path.branch)
+ suboptions = subpath._all_sub_opts.copy()
+ suboptions.update(path._own_sub_opts)
+ path._apply_suboptions(ui, suboptions)
+ return path
+
+
class path(object):
"""Represents an individual path and its configuration."""
@@ -756,31 +783,6 @@
self._apply_suboptions(ui, sub_opts)
- def chain_path(self, ui, paths):
- if self.url.scheme == b'path':
- assert self.url.path is None
- try:
- subpath = paths[self.url.host]
- except KeyError:
- m = _(b'cannot use `%s`, "%s" is not a known path')
- m %= (self.rawloc, self.url.host)
- raise error.Abort(m)
- if subpath.raw_url.scheme == b'path':
- m = _(b'cannot use `%s`, "%s" is also defined as a `path://`')
- m %= (self.rawloc, self.url.host)
- raise error.Abort(m)
- self.url = subpath.url
- self.rawloc = subpath.rawloc
- self.loc = subpath.loc
- if self.branch is None:
- self.branch = subpath.branch
- else:
- base = self.rawloc.rsplit(b'#', 1)[0]
- self.rawloc = b'%s#%s' % (base, self.branch)
- suboptions = subpath._all_sub_opts.copy()
- suboptions.update(self._own_sub_opts)
- self._apply_suboptions(ui, suboptions)
-
def copy(self):
"""make a copy of this path object"""
new = self.__class__()
To: marmoute, #hg-reviewers, Alphare, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210515/f4c4255d/attachment-0001.html>
More information about the Mercurial-patches
mailing list