Comments
Patch
@@ -1001,22 +1001,30 @@ class paths(object):
for name, p in sorted(r.items()):
yield p
+ def __getitem__(self, key):
+ for path in self:
+ if path.name == key:
+ return path
+ raise KeyError('path not known: %s' % key)
+
def getpath(self, name, default=None):
"""Return a ``path`` for the specified name.
Returns None if the specified path or the default path was not
found.
"""
- p = self.ui.config('paths', name)
- if not p and default is not None:
- p = self.ui.config('paths', default)
+ try:
+ return self[name]
+ except KeyError:
+ if default is not None:
+ try:
+ return self[default]
+ except KeyError:
+ pass
- if p:
- return path(name, url=p)
- else:
- return None
+ return None
class path(object):
"""Represents an individual path and its configuration."""