hgweb: add display of bookmarks for changelog and changeset stable
authorAlexander Solovyov <alexander@solovyov.net>
Sat, 12 Mar 2011 11:19:44 +0100
branchstable
changeset 13596 270f57d35525
parent 13594 64a458707fd4
child 13597 38c9837b1f75
hgweb: add display of bookmarks for changelog and changeset
mercurial/hgweb/webcommands.py
mercurial/hgweb/webutil.py
mercurial/templates/paper/changeset.tmpl
mercurial/templates/paper/graph.tmpl
mercurial/templates/paper/map
mercurial/templates/paper/shortlogentry.tmpl
tests/test-hgweb-commands.t
tests/test-hgweb-diffs.t
tests/test-hgweb-empty.t
tests/test-hgweb-removed.t
--- a/mercurial/hgweb/webcommands.py	Sat Mar 12 13:02:03 2011 +0100
+++ b/mercurial/hgweb/webcommands.py	Sat Mar 12 11:19:44 2011 +0100
@@ -205,6 +205,7 @@
                          "rev": i,
                          "node": hex(n),
                          "tags": webutil.nodetagsdict(web.repo, n),
+                         "bookmarks": webutil.nodebookmarksdict(web.repo, n),
                          "inbranch": webutil.nodeinbranch(web.repo, ctx),
                          "branches": webutil.nodebranchdict(web.repo, ctx)
                         })
@@ -247,6 +248,8 @@
 def changeset(web, req, tmpl):
     ctx = webutil.changectx(web.repo, req)
     showtags = webutil.showtag(web.repo, tmpl, 'changesettag', ctx.node())
+    showbookmarks = webutil.showbookmark(web.repo, tmpl, 'changesetbookmark',
+                                         ctx.node())
     showbranch = webutil.nodebranchnodefault(ctx)
 
     files = []
@@ -270,6 +273,7 @@
                 parent=webutil.parents(ctx),
                 child=webutil.children(ctx),
                 changesettag=showtags,
+                changesetbookmark=showbookmarks,
                 changesetbranch=showbranch,
                 author=ctx.user(),
                 desc=ctx.description(),
@@ -277,6 +281,7 @@
                 files=files,
                 archives=web.archivelist(ctx.hex()),
                 tags=webutil.nodetagsdict(web.repo, ctx.node()),
+                bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()),
                 branch=webutil.nodebranchnodefault(ctx),
                 inbranch=webutil.nodeinbranch(web.repo, ctx),
                 branches=webutil.nodebranchdict(web.repo, ctx))
@@ -721,7 +726,7 @@
         user = cgi.escape(templatefilters.person(ctx.user()))
         branch = ctx.branch()
         branch = branch, web.repo.branchtags().get(branch) == ctx.node()
-        data.append((node, vtx, edges, desc, user, age, branch, ctx.tags()))
+        data.append((node, vtx, edges, desc, user, age, branch, ctx.tags(), ctx.bookmarks()))
 
     return tmpl('graph', rev=rev, revcount=revcount, uprev=uprev,
                 lessvars=lessvars, morevars=morevars, downrev=downrev,
--- a/mercurial/hgweb/webutil.py	Sat Mar 12 13:02:03 2011 +0100
+++ b/mercurial/hgweb/webutil.py	Sat Mar 12 11:19:44 2011 +0100
@@ -90,6 +90,9 @@
 def nodetagsdict(repo, node):
     return [{"name": i} for i in repo.nodetags(node)]
 
+def nodebookmarksdict(repo, node):
+    return [{"name": i} for i in repo.nodebookmarks(node)]
+
 def nodebranchdict(repo, ctx):
     branches = []
     branch = ctx.branch()
@@ -118,6 +121,10 @@
     for t in repo.nodetags(node):
         yield tmpl(t1, tag=t, **args)
 
+def showbookmark(repo, tmpl, t1, node=nullid, **args):
+    for t in repo.nodebookmarks(node):
+        yield tmpl(t1, bookmark=t, **args)
+
 def cleanpath(repo, path):
     path = path.lstrip('/')
     return util.canonpath(repo.root, '', path)
--- a/mercurial/templates/paper/changeset.tmpl	Sat Mar 12 13:02:03 2011 +0100
+++ b/mercurial/templates/paper/changeset.tmpl	Sat Mar 12 11:19:44 2011 +0100
@@ -30,7 +30,7 @@
 <div class="main">
 
 <h2><a href="{url}{sessionvars%urlparameter}">{repo|escape}</a></h2>
-<h3>changeset {rev}:{node|short} {changesetbranch%changelogbranchname} {changesettag}</h3>
+<h3>changeset {rev}:{node|short} {changesetbranch%changelogbranchname} {changesettag} {changesetbookmark}</h3>
 
 <form class="search" action="{url}log">
 {sessionvars%hiddenformentry}
--- a/mercurial/templates/paper/graph.tmpl	Sat Mar 12 13:02:03 2011 +0100
+++ b/mercurial/templates/paper/graph.tmpl	Sat Mar 12 11:19:44 2011 +0100
@@ -110,6 +110,12 @@
 				tagspan += '<span class="tag">' + tag + '</span> ';
 			}
 		}
+		if (cur[8].length) \{
+			for (var b in cur[8]) \{
+				var bookmark = cur[8][b];
+				tagspan += '<span class="tag">' + bookmark + '</span> ';
+			}
+		}
 		tagspan += '</span>';
 	}
 	
--- a/mercurial/templates/paper/map	Sat Mar 12 13:02:03 2011 +0100
+++ b/mercurial/templates/paper/map	Sat Mar 12 11:19:44 2011 +0100
@@ -155,6 +155,7 @@
   </tr>'
 changelogtag = '<span class="tag">{name|escape}</span> '
 changesettag = '<span class="tag">{tag|escape}</span> '
+changesetbookmark = '<span class="tag">{bookmark|escape}</span> '
 changelogbranchhead = '<span class="branchhead">{name|escape}</span> '
 changelogbranchname = '<span class="branchname">{name|escape}</span> '
 
--- a/mercurial/templates/paper/shortlogentry.tmpl	Sat Mar 12 13:02:03 2011 +0100
+++ b/mercurial/templates/paper/shortlogentry.tmpl	Sat Mar 12 11:19:44 2011 +0100
@@ -1,5 +1,5 @@
  <tr class="parity{parity}">
   <td class="age">{age(date)}</td>
   <td class="author">{author|person}</td>
-  <td class="description"><a href="{url}rev/{node|short}{sessionvars%urlparameter}">{desc|strip|firstline|escape|nonempty}</a>{inbranch%changelogbranchname}{branches%changelogbranchhead}{tags % '<span class="tag">{name|escape}</span> '}</td>
+  <td class="description"><a href="{url}rev/{node|short}{sessionvars%urlparameter}">{desc|strip|firstline|escape|nonempty}</a>{inbranch%changelogbranchname}{branches%changelogbranchhead}{tags % '<span class="tag">{name|escape}</span> '}{bookmarks % '<span class="tag">{name|escape}</span> '}</td>
  </tr>
--- a/tests/test-hgweb-commands.t	Sat Mar 12 13:02:03 2011 +0100
+++ b/tests/test-hgweb-commands.t	Sat Mar 12 11:19:44 2011 +0100
@@ -15,6 +15,7 @@
   adding da/foo
   adding foo
   $ hg tag 1.0
+  $ hg bookmark something
   $ echo another > foo
   $ hg branch stable
   marked working directory as branch stable
@@ -244,7 +245,7 @@
    <tr class="parity0">
     <td class="age">1970-01-01</td>
     <td class="author">test</td>
-    <td class="description"><a href="/rev/1d22e65f027e">branch</a><span class="branchhead">stable</span> <span class="tag">tip</span> </td>
+    <td class="description"><a href="/rev/1d22e65f027e">branch</a><span class="branchhead">stable</span> <span class="tag">tip</span> <span class="tag">something</span> </td>
    </tr>
    <tr class="parity1">
     <td class="age">1970-01-01</td>
@@ -314,7 +315,7 @@
   <div class="main">
   
   <h2><a href="/">test</a></h2>
-  <h3>changeset 0:2ef0ac749a14  <span class="tag">1.0</span> </h3>
+  <h3>changeset 0:2ef0ac749a14  <span class="tag">1.0</span>  </h3>
   
   <form class="search" action="/log">
   
@@ -811,7 +812,7 @@
   <script>
   <!-- hide script content
   
-  var data = [["1d22e65f027e", [0, 1], [[0, 0, 1]], "branch", "test", "1970-01-01", ["stable", true], ["tip"]], ["a4f92ed23982", [0, 1], [[0, 0, 1]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"]]];
+  var data = [["1d22e65f027e", [0, 1], [[0, 0, 1]], "branch", "test", "1970-01-01", ["stable", true], ["tip"], ["something"]], ["a4f92ed23982", [0, 1], [[0, 0, 1]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], [], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"], []]];
   var graph = new Graph();
   graph.scale(39);
   
@@ -1070,7 +1071,7 @@
 
   $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/graph/' \
   >     | grep '^var data ='
-  var data = [["40b4d6888e92", [0, 1], [[0, 0, 1]], "\u80fd", "test", "1970-01-01", ["stable", true], ["tip"]], ["1d22e65f027e", [0, 1], [[0, 0, 1]], "branch", "test", "1970-01-01", ["stable", false], []], ["a4f92ed23982", [0, 1], [[0, 0, 1]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"]]];
+  var data = [["40b4d6888e92", [0, 1], [[0, 0, 1]], "\u80fd", "test", "1970-01-01", ["stable", true], ["tip"], ["something"]], ["1d22e65f027e", [0, 1], [[0, 0, 1]], "branch", "test", "1970-01-01", ["stable", false], [], []], ["a4f92ed23982", [0, 1], [[0, 0, 1]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], [], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"], []]];
 
 ERRORS ENCOUNTERED
 
--- a/tests/test-hgweb-diffs.t	Sat Mar 12 13:02:03 2011 +0100
+++ b/tests/test-hgweb-diffs.t	Sat Mar 12 11:19:44 2011 +0100
@@ -61,7 +61,7 @@
   <div class="main">
   
   <h2><a href="/">test</a></h2>
-  <h3>changeset 0:0cd96de13884  </h3>
+  <h3>changeset 0:0cd96de13884   </h3>
   
   <form class="search" action="/log">
   
@@ -286,7 +286,7 @@
   <div class="main">
   
   <h2><a href="/">test</a></h2>
-  <h3>changeset 0:0cd96de13884  </h3>
+  <h3>changeset 0:0cd96de13884   </h3>
   
   <form class="search" action="/log">
   
--- a/tests/test-hgweb-empty.t	Sat Mar 12 13:02:03 2011 +0100
+++ b/tests/test-hgweb-empty.t	Sat Mar 12 11:19:44 2011 +0100
@@ -289,6 +289,12 @@
   				tagspan += '<span class="tag">' + tag + '</span> ';
   			}
   		}
+  		if (cur[8].length) {
+  			for (var b in cur[8]) {
+  				var bookmark = cur[8][b];
+  				tagspan += '<span class="tag">' + bookmark + '</span> ';
+  			}
+  		}
   		tagspan += '</span>';
   	}
   	
--- a/tests/test-hgweb-removed.t	Sat Mar 12 13:02:03 2011 +0100
+++ b/tests/test-hgweb-removed.t	Sat Mar 12 11:19:44 2011 +0100
@@ -56,7 +56,7 @@
   <div class="main">
   
   <h2><a href="/">test</a></h2>
-  <h3>changeset 1:c78f6c5cbea9  <span class="tag">tip</span> </h3>
+  <h3>changeset 1:c78f6c5cbea9  <span class="tag">tip</span>  </h3>
   
   <form class="search" action="/log">