# HG changeset patch # User Pierre-Yves David # Date 2021-04-15 09:46:31 # Node ID 83902c579c9b29a320bd272cfd71e85ab79efed0 # Parent 31f36d9b0c6f557fa8ad233c318fa70f6368377b urlutil: introduce a new `list_paths` function This function will be useful for command and template that wants to display path related information. Differential Revision: https://phab.mercurial-scm.org/D10440 diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py --- a/mercurial/utils/urlutil.py +++ b/mercurial/utils/urlutil.py @@ -445,6 +445,18 @@ def removeauth(u): return bytes(u) +def list_paths(ui, target_path=None): + """list all the (name, paths) in the passed ui""" + if target_path is None: + return sorted(pycompat.iteritems(ui.paths)) + else: + path = ui.paths.get(target_path) + if path is None: + return [] + else: + return [(target_path, path)] + + def try_path(ui, url): """try to build a path from a url