mercurial/hgweb/webcommands.py
changeset 6762 f67d1468ac50
parent 6750 fb42030d79d6
child 6857 e8c2dae47799
equal deleted inserted replaced
6761:cb981fc955fb 6762:f67d1468ac50
    11 from mercurial.node import short, hex, nullid
    11 from mercurial.node import short, hex, nullid
    12 from mercurial.util import binary, datestr
    12 from mercurial.util import binary, datestr
    13 from mercurial.repo import RepoError
    13 from mercurial.repo import RepoError
    14 from common import paritygen, staticfile, get_contact, ErrorResponse
    14 from common import paritygen, staticfile, get_contact, ErrorResponse
    15 from common import HTTP_OK, HTTP_NOT_FOUND
    15 from common import HTTP_OK, HTTP_NOT_FOUND
    16 from mercurial import graphmod
    16 from mercurial import graphmod, util
    17 
    17 
    18 # __all__ is populated with the allowed commands. Be sure to add to it if
    18 # __all__ is populated with the allowed commands. Be sure to add to it if
    19 # you're adding a new command, or the new command won't work.
    19 # you're adding a new command, or the new command won't work.
    20 
    20 
    21 __all__ = [
    21 __all__ = [
   286 
   286 
   287     if not files:
   287     if not files:
   288         raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
   288         raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
   289 
   289 
   290     def filelist(**map):
   290     def filelist(**map):
   291         fl = files.keys()
   291         for f in util.sort(files):
   292         fl.sort()
       
   293         for f in fl:
       
   294             full, fnode = files[f]
   292             full, fnode = files[f]
   295             if not fnode:
   293             if not fnode:
   296                 continue
   294                 continue
   297 
   295 
   298             fctx = ctx.filectx(full)
   296             fctx = ctx.filectx(full)
   302                    "date": fctx.date(),
   300                    "date": fctx.date(),
   303                    "size": fctx.size(),
   301                    "size": fctx.size(),
   304                    "permissions": mf.flags(full)}
   302                    "permissions": mf.flags(full)}
   305 
   303 
   306     def dirlist(**map):
   304     def dirlist(**map):
   307         fl = files.keys()
   305         for f in util.sort(files):
   308         fl.sort()
       
   309         for f in fl:
       
   310             full, fnode = files[f]
   306             full, fnode = files[f]
   311             if fnode:
   307             if fnode:
   312                 continue
   308                 continue
   313 
   309 
   314             yield {"parity": parity.next(),
   310             yield {"parity": parity.next(),
   376     def branches(**map):
   372     def branches(**map):
   377         parity = paritygen(web.stripecount)
   373         parity = paritygen(web.stripecount)
   378 
   374 
   379         b = web.repo.branchtags()
   375         b = web.repo.branchtags()
   380         l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.items()]
   376         l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.items()]
   381         l.sort()
   377         for r,n,t in util.sort(l):
   382 
       
   383         for r,n,t in l:
       
   384             yield {'parity': parity.next(),
   378             yield {'parity': parity.next(),
   385                    'branch': t,
   379                    'branch': t,
   386                    'node': hex(n),
   380                    'node': hex(n),
   387                    'date': web.repo[n].date()}
   381                    'date': web.repo[n].date()}
   388 
   382