mercurial/hgweb/webutil.py
changeset 37335 956260cbc564
parent 37334 6407507e12b6
child 37503 49a8c2cc7978
equal deleted inserted replaced
37334:6407507e12b6 37335:956260cbc564
    30     mdiff,
    30     mdiff,
    31     obsutil,
    31     obsutil,
    32     patch,
    32     patch,
    33     pathutil,
    33     pathutil,
    34     pycompat,
    34     pycompat,
       
    35     scmutil,
    35     templatefilters,
    36     templatefilters,
    36     templatekw,
    37     templatekw,
    37     ui as uimod,
    38     ui as uimod,
    38     util,
    39     util,
    39 )
    40 )
   301         changeid = req.qsparams['node']
   302         changeid = req.qsparams['node']
   302         ipos = changeid.find(':')
   303         ipos = changeid.find(':')
   303         if ipos != -1:
   304         if ipos != -1:
   304             changeid = changeid[(ipos + 1):]
   305             changeid = changeid[(ipos + 1):]
   305 
   306 
   306     return repo[changeid]
   307     return scmutil.revsymbol(repo, changeid)
   307 
   308 
   308 def basechangectx(repo, req):
   309 def basechangectx(repo, req):
   309     if 'node' in req.qsparams:
   310     if 'node' in req.qsparams:
   310         changeid = req.qsparams['node']
   311         changeid = req.qsparams['node']
   311         ipos = changeid.find(':')
   312         ipos = changeid.find(':')
   312         if ipos != -1:
   313         if ipos != -1:
   313             changeid = changeid[:ipos]
   314             changeid = changeid[:ipos]
   314             return repo[changeid]
   315             return scmutil.revsymbol(repo, changeid)
   315 
   316 
   316     return None
   317     return None
   317 
   318 
   318 def filectx(repo, req):
   319 def filectx(repo, req):
   319     if 'file' not in req.qsparams:
   320     if 'file' not in req.qsparams:
   324     elif 'filenode' in req.qsparams:
   325     elif 'filenode' in req.qsparams:
   325         changeid = req.qsparams['filenode']
   326         changeid = req.qsparams['filenode']
   326     else:
   327     else:
   327         raise ErrorResponse(HTTP_NOT_FOUND, 'node or filenode not given')
   328         raise ErrorResponse(HTTP_NOT_FOUND, 'node or filenode not given')
   328     try:
   329     try:
   329         fctx = repo[changeid][path]
   330         fctx = scmutil.revsymbol(repo, changeid)[path]
   330     except error.RepoError:
   331     except error.RepoError:
   331         fctx = repo.filectx(path, fileid=changeid)
   332         fctx = repo.filectx(path, fileid=changeid)
   332 
   333 
   333     return fctx
   334     return fctx
   334 
   335