comparison mercurial/hgweb/hgwebdir_mod.py @ 8346:b579823cc546

hgweb: get rid of inaccurate hgwebdir.repos_sorted, localize machinery
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Mon, 11 May 2009 14:19:49 +0200
parents dcebff8a25dd
children 07ddec2ea203
comparison
equal deleted inserted replaced
8345:dcebff8a25dd 8346:b579823cc546
28 else: 28 else:
29 self.ui = ui.ui() 29 self.ui = ui.ui()
30 self.ui.setconfig('ui', 'report_untrusted', 'off') 30 self.ui.setconfig('ui', 'report_untrusted', 'off')
31 self.ui.setconfig('ui', 'interactive', 'off') 31 self.ui.setconfig('ui', 'interactive', 'off')
32 32
33 self.repos_sorted = ('name', False)
34
35 if isinstance(conf, (list, tuple)): 33 if isinstance(conf, (list, tuple)):
36 self.repos = cleannames(conf) 34 self.repos = cleannames(conf)
37 self.repos_sorted = ('', False)
38 elif isinstance(conf, dict): 35 elif isinstance(conf, dict):
39 self.repos = sorted(cleannames(conf.items())) 36 self.repos = sorted(cleannames(conf.items()))
40 else: 37 else:
41 self.ui.readconfig(conf, remap={'paths': 'hgweb-paths'}) 38 self.ui.readconfig(conf, remap={'paths': 'hgweb-paths'})
42 self.repos = [] 39 self.repos = []
182 if i[0] in allowed or ui.configbool("web", "allow" + i[0], 179 if i[0] in allowed or ui.configbool("web", "allow" + i[0],
183 untrusted=True): 180 untrusted=True):
184 yield {"type" : i[0], "extension": i[1], 181 yield {"type" : i[0], "extension": i[1],
185 "node": nodeid, "url": url} 182 "node": nodeid, "url": url}
186 183
184 sortdefault = 'name', False
187 def entries(sortcolumn="", descending=False, subdir="", **map): 185 def entries(sortcolumn="", descending=False, subdir="", **map):
188 rows = [] 186 rows = []
189 parity = paritygen(self.stripecount) 187 parity = paritygen(self.stripecount)
190 for name, path in self.repos: 188 for name, path in self.repos:
191 if not name.startswith(subdir): 189 if not name.startswith(subdir):
231 description=description or "unknown", 229 description=description or "unknown",
232 description_sort=description.upper() or "unknown", 230 description_sort=description.upper() or "unknown",
233 lastchange=d, 231 lastchange=d,
234 lastchange_sort=d[1]-d[0], 232 lastchange_sort=d[1]-d[0],
235 archives=archivelist(u, "tip", url)) 233 archives=archivelist(u, "tip", url))
236 if (not sortcolumn 234 if (not sortcolumn or (sortcolumn, descending) == sortdefault):
237 or (sortcolumn, descending) == self.repos_sorted):
238 # fast path for unsorted output 235 # fast path for unsorted output
239 row['parity'] = parity.next() 236 row['parity'] = parity.next()
240 yield row 237 yield row
241 else: 238 else:
242 rows.append((row["%s_sort" % sortcolumn], row)) 239 rows.append((row["%s_sort" % sortcolumn], row))
247 for key, row in rows: 244 for key, row in rows:
248 row['parity'] = parity.next() 245 row['parity'] = parity.next()
249 yield row 246 yield row
250 247
251 sortable = ["name", "description", "contact", "lastchange"] 248 sortable = ["name", "description", "contact", "lastchange"]
252 sortcolumn, descending = self.repos_sorted 249 sortcolumn, descending = sortdefault
253 if 'sort' in req.form: 250 if 'sort' in req.form:
254 sortcolumn = req.form['sort'][0] 251 sortcolumn = req.form['sort'][0]
255 descending = sortcolumn.startswith('-') 252 descending = sortcolumn.startswith('-')
256 if descending: 253 if descending:
257 sortcolumn = sortcolumn[1:] 254 sortcolumn = sortcolumn[1:]