comparison mercurial/utils/urlutil.py @ 47030:c2b5365aa827

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
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 15 Apr 2021 11:46:31 +0200
parents 9ea75ea23534
children a2632ce1f15b
comparison
equal deleted inserted replaced
47029:9ea75ea23534 47030:c2b5365aa827
443 u = url(u) 443 u = url(u)
444 u.user = u.passwd = None 444 u.user = u.passwd = None
445 return bytes(u) 445 return bytes(u)
446 446
447 447
448 def list_paths(ui, target_path=None):
449 """list all the (name, paths) in the passed ui"""
450 if target_path is None:
451 return sorted(pycompat.iteritems(ui.paths))
452 else:
453 path = ui.paths.get(target_path)
454 if path is None:
455 return []
456 else:
457 return [(target_path, path)]
458
459
448 def try_path(ui, url): 460 def try_path(ui, url):
449 """try to build a path from a url 461 """try to build a path from a url
450 462
451 Return None if no Path could built. 463 Return None if no Path could built.
452 """ 464 """