Mercurial > hg-stable
changeset 27561:723413ee000e
paths: make getpath() accept multiple defaults
This is necessary to handle "default-push" and "default" as fallback items.
We can't apply the same rule as "default:pushurl" because "default-push" is
a valid named path.
This series is for default branch. I have a simpler patch for stable.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 26 Dec 2015 16:10:39 +0900 |
parents | 15b06f306c1f |
children | cb0cfa9fd340 |
files | mercurial/ui.py |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Thu Dec 24 19:32:14 2015 +0000 +++ b/mercurial/ui.py Sat Dec 26 16:10:39 2015 +0900 @@ -1115,7 +1115,7 @@ self['default'].pushloc = defaultpush def getpath(self, name, default=None): - """Return a ``path`` from a string, falling back to a default. + """Return a ``path`` from a string, falling back to default. ``name`` can be a named path or locations. Locations are filesystem paths or URIs. @@ -1125,13 +1125,16 @@ """ # Only fall back to default if no path was requested. if name is None: - if default: + if not default: + default = () + elif not isinstance(default, (tuple, list)): + default = (default,) + for k in default: try: - return self[default] + return self[k] except KeyError: - return None - else: - return None + continue + return None # Most likely empty string. # This may need to raise in the future.