# HG changeset patch # User Yuya Nishihara # Date 2015-12-26 07:10:39 # Node ID 723413ee000eb2ea4d73147f179e02d881aa1391 # Parent 15b06f306c1f4ac13e7eb4ac8b484b43df1e220f 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. diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -1115,7 +1115,7 @@ class paths(dict): 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 @@ class paths(dict): """ # 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.