diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -2317,6 +2317,8 @@ u.fragment = None self.url = u + # the url from the config/command line before dealing with `path://` + self.raw_url = u.copy() self.branch = branch self.name = name @@ -2338,6 +2340,10 @@ if self.url.scheme == b'path': assert self.url.path is None subpath = paths[self.url.host] + if subpath.raw_url.scheme == b'path': + m = _('cannot use `%s`, "%s" is also define 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 diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -3144,6 +3144,21 @@ if v is not None: setattr(self, a, urlreq.unquote(v)) + def copy(self): + u = url(b'temporary useless value') + u.path = self.path + u.scheme = self.scheme + u.user = self.user + u.passwd = self.passwd + u.host = self.host + u.path = self.path + u.query = self.query + u.fragment = self.fragment + u._localpath = self._localpath + u._hostport = self._hostport + u._origpath = self._origpath + return u + @encoding.strmethod def __repr__(self): attrs = [] diff --git a/tests/test-paths.t b/tests/test-paths.t --- a/tests/test-paths.t +++ b/tests/test-paths.t @@ -334,3 +334,39 @@ adding manifests adding file changes added 5 changesets with 0 changes to 0 files (+1 heads) + +Test chaining path:// definition +-------------------------------- + +This is currently unsupported, but feel free to implement the necessary +dependency detection. + + $ cat << EOF >> .hg/hgrc + > chain_path=path://other_default + > EOF + + $ hg id + 000000000000 + $ hg path + abort: cannot use `path://other_default`, "other_default" is also define as a `path://` + [255] + $ hg pull chain_path + abort: cannot use `path://other_default`, "other_default" is also define as a `path://` + [255] + +Doing an actual circle should always be an issue + + $ cat << EOF >> .hg/hgrc + > rock=path://cissors + > cissors=path://paper + > paper=://rock + > EOF + + $ hg id + 000000000000 + $ hg path + abort: cannot use `path://other_default`, "other_default" is also define as a `path://` + [255] + $ hg pull chain_path + abort: cannot use `path://other_default`, "other_default" is also define as a `path://` + [255]