changeset 1418:68f81ba07b2a

Make hgweb work when the repository is empty (no 00changelog.i)
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Thu, 20 Oct 2005 11:41:14 -0700
parents 90b62337f8dd
children 22041f754f4a
files mercurial/hgweb.py
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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