changeset 28712:80e922479891

hgweb: generate last change date for an empty atom-bookmarks feed (issue5022) RFC 4287 states that atom feeds must have an <updated> element, so let's add one even when repo doesn't have a single bookmark.
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 31 Mar 2016 15:37:21 +0800
parents 06ae7a6daad0
children 806d260c6f3b
files mercurial/hgweb/webcommands.py mercurial/templates/atom/bookmarks.tmpl tests/test-hgweb-empty.t
diffstat 3 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Thu Mar 31 15:22:06 2016 +0800
+++ b/mercurial/hgweb/webcommands.py	Thu Mar 31 15:37:21 2016 +0800
@@ -620,8 +620,14 @@
                    "date": web.repo[n].date(),
                    "node": hex(n)}
 
+    if i:
+        latestrev = i[0][1]
+    else:
+        latestrev = -1
+
     return tmpl("bookmarks",
                 node=hex(web.repo.changelog.tip()),
+                lastchange=[{"date": web.repo[latestrev].date()}],
                 entries=lambda **x: entries(latestonly=False, **x),
                 latestentry=lambda **x: entries(latestonly=True, **x))
 
--- a/mercurial/templates/atom/bookmarks.tmpl	Thu Mar 31 15:22:06 2016 +0800
+++ b/mercurial/templates/atom/bookmarks.tmpl	Thu Mar 31 15:37:21 2016 +0800
@@ -5,7 +5,7 @@
  <title>{repo|escape}: bookmarks</title>
  <summary>{repo|escape} bookmark history</summary>
  <author><name>Mercurial SCM</name></author>
- {latestentry%feedupdated}
+ {lastchange%feedupdated}
 
 {entries%bookmarkentry}
 </feed>
--- a/tests/test-hgweb-empty.t	Thu Mar 31 15:22:06 2016 +0800
+++ b/tests/test-hgweb-empty.t	Thu Mar 31 15:37:21 2016 +0800
@@ -472,7 +472,7 @@
    <title>test: bookmarks</title>
    <summary>test bookmark history</summary>
    <author><name>Mercurial SCM</name></author>
-   
+   <updated>1970-01-01T00:00:00+00:00</updated>
   
   
   </feed>