Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgwebdir_mod.py @ 11239:99bc18d1ab0f stable
hgweb: fix race in refreshing repo list (issue2188)
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 14 May 2010 12:57:24 -0500 |
parents | 3c05ecffe20d |
children | 258c98567aff |
comparison
equal
deleted
inserted
replaced
11237:feb2a58fc592 | 11239:99bc18d1ab0f |
---|---|
54 def refresh(self): | 54 def refresh(self): |
55 if self.lastrefresh + self.refreshinterval > time.time(): | 55 if self.lastrefresh + self.refreshinterval > time.time(): |
56 return | 56 return |
57 | 57 |
58 if self.baseui: | 58 if self.baseui: |
59 self.ui = self.baseui.copy() | 59 u = self.baseui.copy() |
60 else: | 60 else: |
61 self.ui = ui.ui() | 61 u = ui.ui() |
62 self.ui.setconfig('ui', 'report_untrusted', 'off') | 62 u.setconfig('ui', 'report_untrusted', 'off') |
63 self.ui.setconfig('ui', 'interactive', 'off') | 63 u.setconfig('ui', 'interactive', 'off') |
64 | 64 |
65 if not isinstance(self.conf, (dict, list, tuple)): | 65 if not isinstance(self.conf, (dict, list, tuple)): |
66 map = {'paths': 'hgweb-paths'} | 66 map = {'paths': 'hgweb-paths'} |
67 self.ui.readconfig(self.conf, remap=map, trust=True) | 67 u.readconfig(self.conf, remap=map, trust=True) |
68 paths = self.ui.configitems('hgweb-paths') | 68 paths = u.configitems('hgweb-paths') |
69 elif isinstance(self.conf, (list, tuple)): | 69 elif isinstance(self.conf, (list, tuple)): |
70 paths = self.conf | 70 paths = self.conf |
71 elif isinstance(self.conf, dict): | 71 elif isinstance(self.conf, dict): |
72 paths = self.conf.items() | 72 paths = self.conf.items() |
73 | 73 |
74 repos = findrepos(paths) | |
75 for prefix, root in u.configitems('collections'): | |
76 prefix = util.pconvert(prefix) | |
77 for path in util.walkrepos(root, followsym=True): | |
78 repo = os.path.normpath(path) | |
79 name = util.pconvert(repo) | |
80 if name.startswith(prefix): | |
81 name = name[len(prefix):] | |
82 repos.append((name.lstrip('/'), repo)) | |
83 | |
84 self.repos = repos | |
85 self.ui = u | |
74 encoding.encoding = self.ui.config('web', 'encoding', | 86 encoding.encoding = self.ui.config('web', 'encoding', |
75 encoding.encoding) | 87 encoding.encoding) |
76 self.style = self.ui.config('web', 'style', 'paper') | 88 self.style = self.ui.config('web', 'style', 'paper') |
77 self.stripecount = self.ui.config('web', 'stripes', 1) | 89 self.stripecount = self.ui.config('web', 'stripes', 1) |
78 if self.stripecount: | 90 if self.stripecount: |
79 self.stripecount = int(self.stripecount) | 91 self.stripecount = int(self.stripecount) |
80 self._baseurl = self.ui.config('web', 'baseurl') | 92 self._baseurl = self.ui.config('web', 'baseurl') |
81 | |
82 self.repos = findrepos(paths) | |
83 for prefix, root in self.ui.configitems('collections'): | |
84 prefix = util.pconvert(prefix) | |
85 for path in util.walkrepos(root, followsym=True): | |
86 repo = os.path.normpath(path) | |
87 name = util.pconvert(repo) | |
88 if name.startswith(prefix): | |
89 name = name[len(prefix):] | |
90 self.repos.append((name.lstrip('/'), repo)) | |
91 | |
92 self.lastrefresh = time.time() | 93 self.lastrefresh = time.time() |
93 | 94 |
94 def run(self): | 95 def run(self): |
95 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."): | 96 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."): |
96 raise RuntimeError("This function is only intended to be " | 97 raise RuntimeError("This function is only intended to be " |