marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches.
REVISION SUMMARY To have `path://xxx` referencing paths that use `path://` too, we need to analyze dependencies to initialize them in the right order (and to detect cycle). I don't want to deal with that right now, so I just disallow it for now. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10264 AFFECTED FILES mercurial/ui.py mercurial/util.py tests/test-paths.t CHANGE DETAILS 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] 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/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 To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel