[PATCH 3 of 3 V2] hgweb: generate last change date for an empty atom-bookmarks feed (issue5022)

Anton Shestakov av6 at dwimlabs.net
Thu Mar 31 10:32:38 EDT 2016


# HG changeset patch
# User Anton Shestakov <av6 at dwimlabs.net>
# Date 1459409841 -28800
#      Thu Mar 31 15:37:21 2016 +0800
# Node ID 7a360e4287b882549f913c212569a2b5d7a5aab4
# Parent  33c78222a8c3e55af767fbe0c6016fd1797845fb
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.

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -620,8 +620,14 @@ def bookmarks(web, req, tmpl):
                    "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))
 
diff --git a/mercurial/templates/atom/bookmarks.tmpl b/mercurial/templates/atom/bookmarks.tmpl
--- a/mercurial/templates/atom/bookmarks.tmpl
+++ b/mercurial/templates/atom/bookmarks.tmpl
@@ -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>
diff --git a/tests/test-hgweb-empty.t b/tests/test-hgweb-empty.t
--- a/tests/test-hgweb-empty.t
+++ b/tests/test-hgweb-empty.t
@@ -472,7 +472,7 @@ Some tests for hgweb in an empty reposit
    <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>


More information about the Mercurial-devel mailing list