mercurial/hgweb/webutil.py
changeset 7637 1d54e2f6c0b7
parent 7361 9fe97eea5510
child 7671 06cf09c822c4
equal deleted inserted replaced
7636:e3f8c6d6b72e 7637:1d54e2f6c0b7
     5 #
     5 #
     6 # This software may be used and distributed according to the terms
     6 # This software may be used and distributed according to the terms
     7 # of the GNU General Public License, incorporated herein by reference.
     7 # of the GNU General Public License, incorporated herein by reference.
     8 
     8 
     9 import os, copy
     9 import os, copy
    10 from mercurial import match, patch
    10 from mercurial import match, patch, util, error
    11 from mercurial.node import hex, nullid
    11 from mercurial.node import hex, nullid
    12 from mercurial.repo import RepoError
       
    13 from mercurial import util
       
    14 
    12 
    15 def up(p):
    13 def up(p):
    16     if p[0] != "/":
    14     if p[0] != "/":
    17         p = "/" + p
    15         p = "/" + p
    18     if p[-1] == "/":
    16     if p[-1] == "/":
    53 
    51 
    54             for label, node in l:
    52             for label, node in l:
    55                 yield {"label": label, "node": node}
    53                 yield {"label": label, "node": node}
    56 
    54 
    57             yield {"label": "tip", "node": "tip"}
    55             yield {"label": "tip", "node": "tip"}
    58         except RepoError:
    56         except error.RepoError:
    59             pass
    57             pass
    60 
    58 
    61     return nav
    59     return nav
    62 
    60 
    63 def siblings(siblings=[], hiderev=None, **args):
    61 def siblings(siblings=[], hiderev=None, **args):
   122     elif 'manifest' in req.form:
   120     elif 'manifest' in req.form:
   123         changeid = req.form['manifest'][0]
   121         changeid = req.form['manifest'][0]
   124 
   122 
   125     try:
   123     try:
   126         ctx = repo[changeid]
   124         ctx = repo[changeid]
   127     except RepoError:
   125     except error.RepoError:
   128         man = repo.manifest
   126         man = repo.manifest
   129         ctx = repo[man.linkrev(man.rev(man.lookup(changeid)))]
   127         ctx = repo[man.linkrev(man.rev(man.lookup(changeid)))]
   130 
   128 
   131     return ctx
   129     return ctx
   132 
   130 
   136         changeid = req.form['node'][0]
   134         changeid = req.form['node'][0]
   137     else:
   135     else:
   138         changeid = req.form['filenode'][0]
   136         changeid = req.form['filenode'][0]
   139     try:
   137     try:
   140         fctx = repo[changeid][path]
   138         fctx = repo[changeid][path]
   141     except RepoError:
   139     except error.RepoError:
   142         fctx = repo.filectx(path, fileid=changeid)
   140         fctx = repo.filectx(path, fileid=changeid)
   143 
   141 
   144     return fctx
   142     return fctx
   145 
   143 
   146 def listfilediffs(tmpl, files, node, max):
   144 def listfilediffs(tmpl, files, node, max):