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.
--- 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.