# HG changeset patch # User Benoit Boissinot # Date 1129833674 25200 # Node ID 68f81ba07b2a79f82e78f1c29088c72af42b1b3f # Parent 90b62337f8dd652f13227b40c98cbca3ba88d8dd Make hgweb work when the repository is empty (no 00changelog.i) diff -r 90b62337f8dd -r 68f81ba07b2a mercurial/hgweb.py --- a/mercurial/hgweb.py Thu Oct 20 00:26:24 2005 -0700 +++ b/mercurial/hgweb.py Thu Oct 20 11:41:14 2005 -0700 @@ -63,6 +63,14 @@ return "/" return up + "/" +def get_mtime(repo_path): + hg_path = os.path.join(repo_path, ".hg") + cl_path = os.path.join(hg_path, "00changelog.i") + if os.path.exists(os.path.join(cl_path)): + return os.stat(cl_path).st_mtime + else: + return os.stat(hg_path).st_mtime + class hgrequest: def __init__(self, inp=None, out=None, env=None): self.inp = inp or sys.stdin @@ -178,9 +186,9 @@ self.archives = 'zip', 'gz', 'bz2' def refresh(self): - s = os.stat(os.path.join(self.repo.root, ".hg", "00changelog.i")) - if s.st_mtime != self.mtime: - self.mtime = s.st_mtime + mtime = get_mtime(self.repo.root) + if mtime != self.mtime: + self.mtime = mtime self.repo = hg.repository(self.repo.ui, self.repo.root) self.maxchanges = int(self.repo.ui.config("web", "maxchanges", 10)) self.maxfiles = int(self.repo.ui.config("web", "maxfiles", 10)) @@ -989,9 +997,7 @@ .replace("//", "/")) # update time with local timezone - d = (os.stat(os.path.join(path, - ".hg", "00changelog.d")).st_mtime, - util.makedate()[1]) + d = (get_mtime(path), util.makedate()[1]) yield dict(contact=(get("ui", "username") or # preferred get("web", "contact") or # deprecated