zeroconf: fix crash in "hg paths" when zeroconf server is up
authorDanek Duvall <danek.duvall@oracle.com>
Thu, 25 Feb 2016 10:01:59 -0800
changeset 28250 6d0d11731e1c
parent 28249 c16949fcb566
child 28251 4591cd6b6794
zeroconf: fix crash in "hg paths" when zeroconf server is up Running "hg paths" with zeroconf enabled and when a zeroconf server is up and running gives a traceback with "ValueError: rawloc must be defined". This is because zeroconf needs to wrap ui.configsuboptions(), introduced in dccbebcff075.
hgext/zeroconf/__init__.py
--- a/hgext/zeroconf/__init__.py	Wed Feb 24 22:22:18 2016 -0800
+++ b/hgext/zeroconf/__init__.py	Thu Feb 25 10:01:59 2016 -0800
@@ -169,6 +169,16 @@
         repos += getzcpaths()
     return repos
 
+def configsuboptions(orig, self, section, name, *args, **kwargs):
+    opt, sub = orig(self, section, name, *args, **kwargs)
+    if section == "paths" and name.startswith("zc-"):
+        # We have to find the URL in the zeroconf paths.  We can't cons up any
+        # suboptions, so we use any that we found in the original config.
+        for zcname, zcurl in getzcpaths():
+            if zcname == name:
+                return zcurl, sub
+    return opt, sub
+
 def defaultdest(orig, source):
     for name, path in getzcpaths():
         if path == source:
@@ -189,5 +199,6 @@
 
 extensions.wrapfunction(ui.ui, 'config', config)
 extensions.wrapfunction(ui.ui, 'configitems', configitems)
+extensions.wrapfunction(ui.ui, 'configsuboptions', configsuboptions)
 extensions.wrapfunction(hg, 'defaultdest', defaultdest)
 extensions.wrapfunction(servermod, 'create_server', zc_create_server)