changeset 10078:97c75ad3b1a0

hgweb: Make get_mtime use repository to find store path. It was calculating it directly, which is redundant and caused it to break with shared repositories.
author Brendan Cully <brendan@kublai.com>
date Tue, 15 Dec 2009 12:33:04 -0800
parents 89617aacb495
children 6d4fa274ae75
files mercurial/hgweb/common.py mercurial/hgweb/hgweb_mod.py mercurial/hgweb/hgwebdir_mod.py tests/test-share tests/test-share.out
diffstat 5 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/common.py	Sun Dec 13 18:29:16 2009 +0100
+++ b/mercurial/hgweb/common.py	Tue Dec 15 12:33:04 2009 -0800
@@ -86,15 +86,12 @@
 def statusmessage(code, message=None):
     return '%d %s' % (code, message or _statusmessage(code))
 
-def get_mtime(repo_path):
-    store_path = os.path.join(repo_path, ".hg")
-    if not os.path.isdir(os.path.join(store_path, "data")):
-        store_path = os.path.join(store_path, "store")
-    cl_path = os.path.join(store_path, "00changelog.i")
+def get_mtime(spath):
+    cl_path = os.path.join(spath, "00changelog.i")
     if os.path.exists(cl_path):
         return os.stat(cl_path).st_mtime
     else:
-        return os.stat(store_path).st_mtime
+        return os.stat(spath).st_mtime
 
 def staticfile(directory, fname, req):
     """return a file inside directory with guessed Content-Type header
--- a/mercurial/hgweb/hgweb_mod.py	Sun Dec 13 18:29:16 2009 +0100
+++ b/mercurial/hgweb/hgweb_mod.py	Tue Dec 15 12:33:04 2009 -0800
@@ -57,7 +57,7 @@
     def refresh(self, request=None):
         if request:
             self.repo.ui.environ = request.env
-        mtime = get_mtime(self.repo.root)
+        mtime = get_mtime(self.repo.spath)
         if mtime != self.mtime:
             self.mtime = mtime
             self.repo = hg.repository(self.repo.ui, self.repo.root)
--- a/mercurial/hgweb/hgwebdir_mod.py	Sun Dec 13 18:29:16 2009 +0100
+++ b/mercurial/hgweb/hgwebdir_mod.py	Tue Dec 15 12:33:04 2009 -0800
@@ -235,7 +235,8 @@
 
                 # update time with local timezone
                 try:
-                    d = (get_mtime(path), util.makedate()[1])
+                    r = hg.repository(self.ui, path)
+                    d = (get_mtime(r.spath), util.makedate()[1])
                 except OSError:
                     continue
 
--- a/tests/test-share	Sun Dec 13 18:29:16 2009 +0100
+++ b/tests/test-share	Tue Dec 15 12:33:04 2009 -0800
@@ -41,3 +41,8 @@
 hg update
 cat b             # should exist with one "b"
 
+echo % hg serve shared clone
+hg serve -n test -p $HGPORT -d --pid-file=hg.pid
+cat hg.pid >> $DAEMON_PIDS
+
+"$TESTDIR/get-with-headers.py" localhost:$HGPORT '/raw-file/'
--- a/tests/test-share.out	Sun Dec 13 18:29:16 2009 +0100
+++ b/tests/test-share.out	Tue Dec 15 12:33:04 2009 -0800
@@ -43,3 +43,11 @@
 
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 b
+% hg serve shared clone
+200 Script output follows
+
+
+-rw-r--r-- 4 a
+-rw-r--r-- 2 b
+
+