Patchwork [2,of,7,path-configs] ui.paths: teach paths how to iterate

login
register
mail settings
Submitter Gregory Szorc
Date Feb. 8, 2015, 1:13 a.m.
Message ID <492682e13efa98be4640.1423358018@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/7763/
State Changes Requested
Headers show

Comments

Gregory Szorc - Feb. 8, 2015, 1:13 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1423341730 28800
#      Sat Feb 07 12:42:10 2015 -0800
# Node ID 492682e13efa98be4640530ceed58e1f0b2adf75
# Parent  425462525dc5c44de575084d1516417286c43f51
ui.paths: teach paths how to iterate

paths instances can now iterate over available paths as path
instances.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -937,8 +937,16 @@  class paths(object):
     @property
     def ui(self):
         return self._uiref()
 
+    def __iter__(self):
+        """Iterate all available paths, as ``path`` instances."""
+        for name, loc in self.ui.configitems('paths'):
+            # No URL is the same as not existing.
+            if not loc:
+                continue
+            yield path(name, url=loc)
+
     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