[PATCH] Provide accurate last-modified times in hgwebdir repository index

Tom Tobin korpios at korpios.com
Sun Jun 24 15:20:28 CDT 2007


# HG changeset patch
# User Tom Tobin <korpios at korpios.com>
# Date 1182715948 18000
# Node ID 28ad5556171439749c9b88a71375add2058549f7
# Parent  a6b62584d0b28edc9bab7035529019742dd83187
Provide accurate last-modified times in hgwebdir repository index.

As ``hgwebdir_mod.py`` currently stands, the "last change" times will be
inaccurate when the repository's path modification time does not match the
commit time of tip.  This tends to happen if hgwebdir is serving
remotely-pushed repositories or converted mirrors of non-mercurial
repositories.  By extracting the commit time from the tip of each repository
in question, this problem is avoided.

diff -r a6b62584d0b2 -r 28ad55561714 mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py	Sun Jun 24 10:08:38 2007 -0500
+++ b/mercurial/hgweb/hgwebdir_mod.py	Sun Jun 24 15:12:28 2007 -0500
@@ -146,10 +146,9 @@ class hgwebdir(object):
                        .replace("//", "/")) + '/'
 
                 # update time with local timezone
-                try:
-                    d = (get_mtime(path), util.makedate()[1])
-                except OSError:
-                    continue
+                r = hg.repository(u, path)
+                ctx = r.changectx()
+                d = (ctx.date()[0], util.makedate()[1])
 
                 contact = (get("ui", "username") or # preferred
                            get("web", "contact") or # deprecated


More information about the Mercurial-devel mailing list