hg site extension
 
(Arne Babenhauserheide)
2011-11-24: merge default into release. releases 0.1.2

merge default into release.

diff --git a/.bugs/details/0fde104c4206be8245ff0716ee2e91ea3971db8f.txt b/.bugs/details/0fde104c4206be8245ff0716ee2e91ea3971db8f.txt
new file mode 100644
--- /dev/null
+++ b/.bugs/details/0fde104c4206be8245ff0716ee2e91ea3971db8f.txt
@@ -0,0 +1,43 @@
+# Lines starting with u'#' and sections without content
+# are not displayed by a call to u'details'
+#
+[paths]
+# Paths related to this bug.
+# suggested format: REPO_PATH:LINENUMBERS
+
+
+[details]
+# Additional details
+What I want: 
+
+Branches
+--------
+
+(list of commits)
+
+Bookmarks
+---------
+
+(list of bookmarks
+
+Tags
+----
+
+(list of tags)
+
+Goes on the overview site.
+
+[expected]
+# The expected result
+
+
+[actual]
+# What happened instead
+
+
+[reproduce]
+# Reproduction steps
+
+
+[comments]
+# Comments and updates - leave your name
diff --git a/.hgtags b/.hgtags
new file mode 100644
--- /dev/null
+++ b/.hgtags
@@ -0,0 +1,2 @@
+d30f0a2067a11a679b99b476dc51945628e23d3a v0.1
+753a939405dc25d1fcd45355c1724d6d38874b4d 0.1.1
diff --git a/site.py b/site.py
--- a/site.py
+++ b/site.py
@@ -54,13 +54,13 @@ templates = {
 </head>
 <body>
 """,
-    "foot": "</body></html>",
+    "foot": "</body></html>\n",
     "screenstyle": """ """,
     "printstyle": """ """,
     "manifesthead": """<h2>""" + _("Commit")+""": <a href='../../commit/{hex}.html'>{hex}</a></h2>
 <p>{desc}</p><p>{user}</p>
     <h2>""" + _("Files in this revision") + "</h2>", 
-    "commitlog": """<div style='float: right; padding-left: 0.5em'><em>({author|person})</em></div><strong> {date|shortdate}: <a href='{relativepath}src/{node}/index.html'>{desc|strip|fill68|firstline}</a></strong> <span style='font-size: xx-small'>{branches} {tags} {bookmarks}</span><p>{desc|escape}</p>\n"""
+    "commitlog": """\n<div style='float: right; padding-left: 0.5em'><em>({author|person})</em></div><strong> {date|shortdate}: <a href='{relativepath}src/{node}/index.html'>{desc|strip|fill68|firstline}</a></strong> <span style='font-size: xx-small'>{branches} {tags} {bookmarks}</span><p>{desc|escape}</p>\n"""
 }
 
 _indexregexp = re.compile("^\\.*index.html$")
@@ -87,6 +87,17 @@ def parsereadme(filepath):
         return "<pre>" + r.read() + "</pre>"
 
 
+def overviewlogstring(ui, repo, revs, template=templates["commitlog"]): 
+    """Get the string for a log of the given revisions for the overview page."""
+    ui.pushbuffer()
+    t = cmdutil.changeset_templater(ui, repo, patch=False, diffopts=None, mapfile=None, buffered=False)
+    t.use_template(template.replace("{relativepath}", ""))
+    for c in revs:
+        ctx = repo.changectx(c)
+        t.show(ctx)
+    return ui.popbuffer()
+
+
 def writeoverview(ui, repo, target, name):
     """Create the overview page"""
     overview = ""
@@ -111,6 +122,39 @@ def writeoverview(ui, repo, target, name
         ctx = repo.changectx(str(-c))
         t.show(ctx)
     overview += ui.popbuffer()
+    
+    # Add branch, bookmark and tag information, if they exist.
+    branches = []
+    for branch, heads in repo.branchmap().items(): 
+        if branch and branch != "default": # not default
+            branches.extend(heads)
+
+    tags = repo._tags
+    bookmarks = repo._bookmarks
+    if branches: # add branches
+        overview += "\n<h2>Branches</h2>\n"
+        overview += overviewlogstring(ui, repo, branches,
+                                      template=templates["commitlog"].replace(
+                "{branches}", "XXXXX").replace(
+                "{date|shortdate}", "{branches}").replace(
+                "XXXXX", "{date|shortdate}").replace(
+                "{tags}", "XXXXX").replace(
+                "{date|shortdate}", "{tags}").replace(
+                "XXXXX", "{date|shortdate}"))
+    if len(tags) > 1: 
+        overview += "\n<h2>Tags</h2>\n"
+        overview += overviewlogstring(ui, repo, [tags[t] for t in tags if t != "tip"],
+                                      template=templates["commitlog"].replace(
+                "{tags}", "XXXXX").replace(
+                "{date|shortdate}", "{tags}").replace(
+                "XXXXX", "{date|shortdate}"))
+    if len(bookmarks): 
+        overview += "\n<h2>Bookmarks</h2>\n"
+        overview += overviewlogstring(ui, repo, bookmarks.values(),
+                                      template=templates["commitlog"].replace(
+                "{bookmarks}", "XXXXX").replace(
+                "{date|shortdate}", "{bookmarks}").replace(
+                "XXXXX", "{date|shortdate}"))
 
     # add the full readme
     overview += "<h2>"+_("Readme")+"</h2>\n"