Mercurial > hg
annotate hgext/zeroconf/__init__.py @ 8190:9b8ac5fb7760
ui: kill most users of parentui name and arg, replace with .copy()
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 26 Apr 2009 16:50:43 -0500 |
parents | 14f27921932a |
children | 35604226d712 |
rev | line source |
---|---|
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 # zeroconf.py - zeroconf support for Mercurial |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 # |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
6 # the GNU General Public License (version 2), incorporated herein by |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 # reference. |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
8 |
7606
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
9 '''zeroconf support for mercurial repositories |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
10 |
8003
14f27921932a
zeroconf: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
11 Zeroconf enabled repositories will be announced in a network without |
14f27921932a
zeroconf: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
12 the need to configure a server or a service. They can be discovered |
14f27921932a
zeroconf: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
13 without knowing their actual IP address. |
7606
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
14 |
8003
14f27921932a
zeroconf: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
15 To use the zeroconf extension add the following entry to your hgrc |
14f27921932a
zeroconf: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
16 file: |
7606
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
17 |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
18 [extensions] |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
19 hgext.zeroconf = |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
20 |
8003
14f27921932a
zeroconf: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
21 To allow other people to discover your repository using run "hg serve" |
14f27921932a
zeroconf: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7874
diff
changeset
|
22 in your repository. |
7606
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
23 |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
24 $ cd test |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
25 $ hg serve |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
26 |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
27 You can discover zeroconf enabled repositories by running "hg paths". |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
28 |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
29 $ hg paths |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
30 zc-test = http://example.com:8000/test |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
31 ''' |
e86ca711544d
zeroconf: add extension documentation
David Soria Parra <dsp@php.net>
parents:
7295
diff
changeset
|
32 |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
33 import Zeroconf, socket, time, os |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
34 from mercurial import ui |
7216
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7088
diff
changeset
|
35 from mercurial import extensions |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
36 from mercurial.hgweb import hgweb_mod |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
37 from mercurial.hgweb import hgwebdir_mod |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
38 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
39 # publish |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
40 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
41 server = None |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
42 localip = None |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
43 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
44 def getip(): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
45 # finds external-facing interface without sending any packets (Linux) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
46 try: |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
47 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
48 s.connect(('1.0.0.1', 0)) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
49 ip = s.getsockname()[0] |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
50 return ip |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
51 except: |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
52 pass |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
53 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
54 # Generic method, sometimes gives useless results |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
55 dumbip = socket.gethostbyaddr(socket.gethostname())[2][0] |
7777
e3425726b80d
zeroconf: don't allow ipv6 addresses
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7606
diff
changeset
|
56 if not dumbip.startswith('127.') and ':' not in dumbip: |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
57 return dumbip |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
58 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
59 # works elsewhere, but actually sends a packet |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
60 try: |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
61 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
62 s.connect(('1.0.0.1', 1)) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
63 ip = s.getsockname()[0] |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
64 return ip |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
65 except: |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
66 pass |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
67 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
68 return dumbip |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
69 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
70 def publish(name, desc, path, port): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
71 global server, localip |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
72 if not server: |
7295
66d0fc108044
zeroconf: Don't break serve if no internet connection is present.
Augie Fackler <durin42@gmail.com>
parents:
7282
diff
changeset
|
73 try: |
66d0fc108044
zeroconf: Don't break serve if no internet connection is present.
Augie Fackler <durin42@gmail.com>
parents:
7282
diff
changeset
|
74 server = Zeroconf.Zeroconf() |
66d0fc108044
zeroconf: Don't break serve if no internet connection is present.
Augie Fackler <durin42@gmail.com>
parents:
7282
diff
changeset
|
75 except socket.gaierror: |
66d0fc108044
zeroconf: Don't break serve if no internet connection is present.
Augie Fackler <durin42@gmail.com>
parents:
7282
diff
changeset
|
76 # if we have no internet connection, this can happen. |
66d0fc108044
zeroconf: Don't break serve if no internet connection is present.
Augie Fackler <durin42@gmail.com>
parents:
7282
diff
changeset
|
77 return |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
78 ip = getip() |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
79 localip = socket.inet_aton(ip) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
80 |
7845
c2cd8d772805
zeroconf: advertise repositories with hostname
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7777
diff
changeset
|
81 hostname = socket.gethostname().split('.')[0] |
c2cd8d772805
zeroconf: advertise repositories with hostname
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7777
diff
changeset
|
82 host = hostname + ".local" |
c2cd8d772805
zeroconf: advertise repositories with hostname
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7777
diff
changeset
|
83 name = "%s-%s" % (hostname, name) |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
84 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
85 # advertise to browsers |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
86 svc = Zeroconf.ServiceInfo('_http._tcp.local.', |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
87 name + '._http._tcp.local.', |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
88 server = host, |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
89 port = port, |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
90 properties = {'description': desc, |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
91 'path': "/" + path}, |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
92 address = localip, weight = 0, priority = 0) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
93 server.registerService(svc) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
94 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
95 # advertise to Mercurial clients |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
96 svc = Zeroconf.ServiceInfo('_hg._tcp.local.', |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
97 name + '._hg._tcp.local.', |
7088
58b7b5ef6cd0
zeroconf: advertise a proper hostname for _hg services
Matt Mackall <mpm@selenic.com>
parents:
7087
diff
changeset
|
98 server = host, |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
99 port = port, |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
100 properties = {'description': desc, |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
101 'path': "/" + path}, |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
102 address = localip, weight = 0, priority = 0) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
103 server.registerService(svc) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
104 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
105 class hgwebzc(hgweb_mod.hgweb): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
106 def __init__(self, repo, name=None): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
107 super(hgwebzc, self).__init__(repo, name) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
108 name = self.reponame or os.path.basename(repo.root) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
109 desc = self.repo.ui.config("web", "description", name) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
110 publish(name, desc, name, int(repo.ui.config("web", "port", 8000))) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
111 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
112 class hgwebdirzc(hgwebdir_mod.hgwebdir): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
113 def run(self): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
114 for r, p in self.repos: |
8190
9b8ac5fb7760
ui: kill most users of parentui name and arg, replace with .copy()
Matt Mackall <mpm@selenic.com>
parents:
8003
diff
changeset
|
115 u = self.parentui.copy() |
7282
6541696b5f66
fix zeroconf handling for hgwebdir (error found by pychecker)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7280
diff
changeset
|
116 u.readconfig(os.path.join(p, '.hg', 'hgrc')) |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
117 n = os.path.basename(r) |
7282
6541696b5f66
fix zeroconf handling for hgwebdir (error found by pychecker)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7280
diff
changeset
|
118 publish(n, "hgweb", p, int(u.config("web", "port", 8000))) |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
119 return super(hgwebdirzc, self).run() |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
120 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
121 # listen |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
122 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
123 class listener(object): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
124 def __init__(self): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
125 self.found = {} |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
126 def removeService(self, server, type, name): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
127 if repr(name) in self.found: |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
128 del self.found[repr(name)] |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
129 def addService(self, server, type, name): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
130 self.found[repr(name)] = server.getServiceInfo(type, name) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
131 |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
132 def getzcpaths(): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
133 server = Zeroconf.Zeroconf() |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
134 l = listener() |
7874
d812029cda85
cleanup: drop variables for unused return values
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
7845
diff
changeset
|
135 Zeroconf.ServiceBrowser(server, "_hg._tcp.local.", l) |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
136 time.sleep(1) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
137 server.close() |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
138 for v in l.found.values(): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
139 n = v.name[:v.name.index('.')] |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
140 n.replace(" ", "-") |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
141 u = "http://%s:%s%s" % (socket.inet_ntoa(v.address), v.port, |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
142 v.properties.get("path", "/")) |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
143 yield "zc-" + n, u |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
144 |
7216
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7088
diff
changeset
|
145 def config(orig, self, section, key, default=None, untrusted=False): |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
146 if section == "paths" and key.startswith("zc-"): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
147 for n, p in getzcpaths(): |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
148 if n == key: |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
149 return p |
7216
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7088
diff
changeset
|
150 return orig(self, section, key, default, untrusted) |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
151 |
7238
b1a9ad7b464e
zeroconf: don't break on hg showconfig
Matt Mackall <mpm@selenic.com>
parents:
7216
diff
changeset
|
152 def configitems(orig, self, section, untrusted=False): |
b1a9ad7b464e
zeroconf: don't break on hg showconfig
Matt Mackall <mpm@selenic.com>
parents:
7216
diff
changeset
|
153 r = orig(self, section, untrusted) |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
154 if section == "paths": |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
155 r += getzcpaths() |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
156 return r |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
157 |
7216
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7088
diff
changeset
|
158 extensions.wrapfunction(ui.ui, 'config', config) |
292fb2ad2846
extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents:
7088
diff
changeset
|
159 extensions.wrapfunction(ui.ui, 'configitems', configitems) |
7071
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
160 hgweb_mod.hgweb = hgwebzc |
643c751e60b2
zeroconf: initial implementation
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
161 hgwebdir_mod.hgwebdir = hgwebdirzc |