mercurial/hgweb.py
changeset 258 268bcb5a072a
parent 241 afe895fcc0d0
child 265 7ca05593bd30
equal deleted inserted replaced
257:65dccc4555c2 258:268bcb5a072a
   117     maxfiles = 10
   117     maxfiles = 10
   118 
   118 
   119     def __init__(self, path, name, templates = ""):
   119     def __init__(self, path, name, templates = ""):
   120         self.templates = templates or templatepath()
   120         self.templates = templates or templatepath()
   121         self.reponame = name
   121         self.reponame = name
   122         self.repo = repository(ui(), path)
   122         self.path = path
       
   123         self.mtime = -1
   123         self.viewonly = 0
   124         self.viewonly = 0
   124 
   125 
   125         self.filters = {
   126         self.filters = {
   126             "escape": cgi.escape,
   127             "escape": cgi.escape,
   127             "age": age,
   128             "age": age,
   128             "date": (lambda x: time.asctime(time.gmtime(x))),
   129             "date": (lambda x: time.asctime(time.gmtime(x))),
   129             "addbreaks": nl2br,
   130             "addbreaks": nl2br,
   130             "obfuscate": obfuscate,
   131             "obfuscate": obfuscate,
   131             "firstline": (lambda x: x.splitlines(1)[0]),
   132             "firstline": (lambda x: x.splitlines(1)[0]),
   132             }
   133             }
       
   134 
       
   135     def refresh(self):
       
   136         s = os.stat(os.path.join(self.path, ".hg", "00changelog.i"))
       
   137         if s.st_mtime != self.mtime:
       
   138             self.repo = repository(ui(), self.path)
   133 
   139 
   134     def date(self, cs):
   140     def date(self, cs):
   135         return time.asctime(time.gmtime(float(cs[2].split(' ')[0])))
   141         return time.asctime(time.gmtime(float(cs[2].split(' ')[0])))
   136 
   142 
   137     def listfiles(self, files, mf):
   143     def listfiles(self, files, mf):
   564     # add tags to things
   570     # add tags to things
   565     # tags -> list of changesets corresponding to tags
   571     # tags -> list of changesets corresponding to tags
   566     # find tag, changeset, file
   572     # find tag, changeset, file
   567 
   573 
   568     def run(self):
   574     def run(self):
       
   575         self.refresh()
   569         args = cgi.parse()
   576         args = cgi.parse()
   570 
   577 
   571         m = os.path.join(self.templates, "map")
   578         m = os.path.join(self.templates, "map")
   572         if args.has_key('style'):
   579         if args.has_key('style'):
   573             b = os.path.basename("map-" + args['style'][0])
   580             b = os.path.basename("map-" + args['style'][0])