comparison mercurial/hgweb/webcommands.py @ 8209:a1a5a57efe90

replace util.sort with sorted built-in This is marginally faster for small and moderately-sized lists
author Matt Mackall <mpm@selenic.com>
date Sun, 26 Apr 2009 16:50:44 -0500
parents aa983c3d94a9
children 46293a0c7e9f
comparison
equal deleted inserted replaced
8208:32a2a1e244f1 8209:a1a5a57efe90
291 291
292 if mf and not files and not dirs: 292 if mf and not files and not dirs:
293 raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path) 293 raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
294 294
295 def filelist(**map): 295 def filelist(**map):
296 for f in util.sort(files): 296 for f in sorted(files):
297 full = files[f] 297 full = files[f]
298 298
299 fctx = ctx.filectx(full) 299 fctx = ctx.filectx(full)
300 yield {"file": full, 300 yield {"file": full,
301 "parity": parity.next(), 301 "parity": parity.next(),
303 "date": fctx.date(), 303 "date": fctx.date(),
304 "size": fctx.size(), 304 "size": fctx.size(),
305 "permissions": mf.flags(full)} 305 "permissions": mf.flags(full)}
306 306
307 def dirlist(**map): 307 def dirlist(**map):
308 for d in util.sort(dirs): 308 for d in sorted(dirs):
309 309
310 emptydirs = [] 310 emptydirs = []
311 h = dirs[d] 311 h = dirs[d]
312 while isinstance(h, dict) and len(h) == 1: 312 while isinstance(h, dict) and len(h) == 1:
313 k,v = h.items()[0] 313 k,v = h.items()[0]
382 def branches(**map): 382 def branches(**map):
383 parity = paritygen(web.stripecount) 383 parity = paritygen(web.stripecount)
384 384
385 b = web.repo.branchtags() 385 b = web.repo.branchtags()
386 l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.iteritems()] 386 l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.iteritems()]
387 for r,n,t in util.sort(l): 387 for r,n,t in sorted(l):
388 yield {'parity': parity.next(), 388 yield {'parity': parity.next(),
389 'branch': t, 389 'branch': t,
390 'node': hex(n), 390 'node': hex(n),
391 'date': web.repo[n].date()} 391 'date': web.repo[n].date()}
392 392