comparison mercurial/hgweb.py @ 258:268bcb5a072a

hgweb: watch changelog for changes -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hgweb: watch changelog for changes Check the mtime of the changelog for updates on each invocation of run(). For the standalone server, this means you don't need to re-run it to pick up changes. manifest hash: 398bdbf03b867df27da9e803a094dd265f62e12c -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFConlTywK+sNU5EO8RAljMAKCigJKR2aXabt1kuYeiAl+PZEN1owCeKShZ oZKfo+I7e967FqI9l7NIPFE= =pTp6 -----END PGP SIGNATURE-----
author mpm@selenic.com
date Sat, 04 Jun 2005 20:02:27 -0800
parents afe895fcc0d0
children 7ca05593bd30
comparison
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])