Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/utils/urlutil.py @ 49926:a9602a84a442
urlutil: drop the deprecated `getpath()`
This was deprecated in 5.9.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 03 Jan 2023 11:53:35 -0500 |
parents | bcae90c53def |
children | e0c0545e2e55 |
comparison
equal
deleted
inserted
replaced
49925:b7f33ed1d909 | 49926:a9602a84a442 |
---|---|
654 new_paths = [] | 654 new_paths = [] |
655 for p in old_paths: | 655 for p in old_paths: |
656 new_paths.extend(_chain_path(p, ui, self)) | 656 new_paths.extend(_chain_path(p, ui, self)) |
657 self[name] = new_paths | 657 self[name] = new_paths |
658 | 658 |
659 def getpath(self, ui, name, default=None): | |
660 """Return a ``path`` from a string, falling back to default. | |
661 | |
662 ``name`` can be a named path or locations. Locations are filesystem | |
663 paths or URIs. | |
664 | |
665 Returns None if ``name`` is not a registered path, a URI, or a local | |
666 path to a repo. | |
667 """ | |
668 msg = b'getpath is deprecated, use `get_*` functions from urlutil' | |
669 ui.deprecwarn(msg, b'6.0') | |
670 # Only fall back to default if no path was requested. | |
671 if name is None: | |
672 if not default: | |
673 default = () | |
674 elif not isinstance(default, (tuple, list)): | |
675 default = (default,) | |
676 for k in default: | |
677 try: | |
678 return self[k][0] | |
679 except KeyError: | |
680 continue | |
681 return None | |
682 | |
683 # Most likely empty string. | |
684 # This may need to raise in the future. | |
685 if not name: | |
686 return None | |
687 if name in self: | |
688 return self[name][0] | |
689 else: | |
690 # Try to resolve as a local path or URI. | |
691 path = try_path(ui, name) | |
692 if path is None: | |
693 raise error.RepoError(_(b'repository %s does not exist') % name) | |
694 return path.rawloc | |
695 | |
696 | 659 |
697 _pathsuboptions = {} | 660 _pathsuboptions = {} |
698 | 661 |
699 | 662 |
700 def pathsuboption(option, attr): | 663 def pathsuboption(option, attr): |