hgweb: show obsolescence status of a commit
authorAnton Shestakov <av6@dwimlabs.net>
Sat, 18 Nov 2017 12:04:08 +0800
changeset 35089 69ea10d5b00c
parent 35088 a9454beb9dd8
child 35090 79cbf5cc4fb8
hgweb: show obsolescence status of a commit As with phases, spartan theme shows a simple "obsolete: yes" on its own line (this allows replacing "yes" with something more useful in future, like output of obsfate* template functions). Everywhere else a new "tag" is added to the same line that has phase, branch, etc of a changeset; in gitweb and monoblue the element has gray background, in paper and coal the element is gray with a dashed underline.
mercurial/templates/gitweb/map
mercurial/templates/monoblue/map
mercurial/templates/paper/map
mercurial/templates/spartan/changelogentry.tmpl
mercurial/templates/spartan/changeset.tmpl
mercurial/templates/static/style-gitweb.css
mercurial/templates/static/style-monoblue.css
mercurial/templates/static/style-paper.css
tests/test-hgweb.t
tests/test-obsolete.t
--- a/mercurial/templates/gitweb/map	Sat Nov 18 11:58:57 2017 +0800
+++ b/mercurial/templates/gitweb/map	Sat Nov 18 12:04:08 2017 +0800
@@ -263,11 +263,12 @@
 shortlog = shortlog.tmpl
 graph = graph.tmpl
 phasetag = '{ifeq(phase, 'public', '', '<span class="phasetag" title="{phase|escape}">{phase|escape}</span> ')}'
+obsoletetag = '{if(obsolete, '<span class="obsoletetag" title="obsolete">obsolete</span> ')}'
 tagtag = '<span class="tagtag" title="{name|escape}">{name|escape}</span> '
 branchtag = '<span class="branchtag" title="{name|escape}">{name|escape}</span> '
 inbranchtag = '<span class="inbranchtag" title="{name|escape}">{name|escape}</span> '
 bookmarktag = '<span class="bookmarktag" title="{name|escape}">{name|escape}</span> '
-alltags = '<span class="logtags">{phasetag}{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}{bookmarks%bookmarktag}</span>'
+alltags = '<span class="logtags">{phasetag}{obsoletetag}{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}{bookmarks%bookmarktag}</span>'
 shortlogentry = '
   <tr class="parity{parity}">
     <td class="age"><i class="age">{date|rfc822date}</i></td>
--- a/mercurial/templates/monoblue/map	Sat Nov 18 11:58:57 2017 +0800
+++ b/mercurial/templates/monoblue/map	Sat Nov 18 12:04:08 2017 +0800
@@ -222,11 +222,12 @@
   <dd><a href="{url|urlescape}comparison/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a></dd>'
 shortlog = shortlog.tmpl
 phasetag = '{ifeq(phase, 'public', '', '<span class="phasetag" title="{phase|escape}">{phase|escape}</span> ')}'
+obsoletetag = '{if(obsolete, '<span class="obsoletetag" title="obsolete">obsolete</span> ')}'
 tagtag = '<span class="tagtag" title="{name|escape}">{name|escape}</span> '
 branchtag = '<span class="branchtag" title="{name|escape}">{name|escape}</span> '
 inbranchtag = '<span class="inbranchtag" title="{name|escape}">{name|escape}</span> '
 bookmarktag = '<span class="bookmarktag" title="{name|escape}">{name|escape}</span> '
-alltags = '<span class="logtags">{phasetag}{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}{bookmarks%bookmarktag}</span>'
+alltags = '<span class="logtags">{phasetag}{obsoletetag}{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}{bookmarks%bookmarktag}</span>'
 shortlogentry = '
   <tr class="parity{parity}">
     <td class="nowrap age">{date|rfc822date}</td>
--- a/mercurial/templates/paper/map	Sat Nov 18 11:58:57 2017 +0800
+++ b/mercurial/templates/paper/map	Sat Nov 18 12:04:08 2017 +0800
@@ -199,12 +199,13 @@
     </td>
   </tr>'
 phasetag = '{ifeq(phase, 'public', '', '<span class="phase">{phase|escape}</span> ')}'
+obsoletetag = '{if(obsolete, '<span class="obsolete">obsolete</span> ')}'
 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> '
-alltags = '{phasetag}{inbranch%changelogbranchname}{branches%changelogbranchhead}{tags%changelogtag}{bookmarks%changelogtag}'
+alltags = '{phasetag}{obsoletetag}{inbranch%changelogbranchname}{branches%changelogbranchhead}{tags%changelogtag}{bookmarks%changelogtag}'
 
 filediffparent = '
   <tr>
--- a/mercurial/templates/spartan/changelogentry.tmpl	Sat Nov 18 11:58:57 2017 +0800
+++ b/mercurial/templates/spartan/changelogentry.tmpl	Sat Nov 18 12:04:08 2017 +0800
@@ -22,6 +22,10 @@
   <th class="phase">phase:</th>
   <td class="phase">{phase|escape}</td>
  </tr>')}
+ {if(obsolete, '<tr>
+  <th class="obsolete">obsolete:</th>
+  <td class="obsolete">yes</td>
+ </tr>')}
  <tr>
   <th class="files"><a href="{url|urlescape}file/{node|short}{sessionvars%urlparameter}">files</a>:</th>
   <td class="files">{files}</td>
--- a/mercurial/templates/spartan/changeset.tmpl	Sat Nov 18 11:58:57 2017 +0800
+++ b/mercurial/templates/spartan/changeset.tmpl	Sat Nov 18 12:04:08 2017 +0800
@@ -37,6 +37,10 @@
  <th class="phase">phase:</th>
  <td class="phase">{phase|escape}</td>
 </tr>')}
+{if(obsolete, '<tr>
+ <th class="obsolete">obsolete:</th>
+ <td class="obsolete">yes</td>
+</tr>')}
 <tr>
  <th class="files">files:</th>
  <td class="files">{files}</td>
--- a/mercurial/templates/static/style-gitweb.css	Sat Nov 18 11:58:57 2017 +0800
+++ b/mercurial/templates/static/style-gitweb.css	Sat Nov 18 12:04:08 2017 +0800
@@ -126,6 +126,10 @@
 	background-color: #dfafff;
 	border-color: #e2b8ff #ce48ff #ce48ff #e2b8ff;
 }
+span.logtags span.obsoletetag {
+	background-color: #dddddd;
+	border-color: #e4e4e4 #a3a3a3 #a3a3a3 #e4e4e4;
+}
 span.logtags span.tagtag {
 	background-color: #ffffaa;
 	border-color: #ffffcc #ffee00 #ffee00 #ffffcc;
--- a/mercurial/templates/static/style-monoblue.css	Sat Nov 18 11:58:57 2017 +0800
+++ b/mercurial/templates/static/style-monoblue.css	Sat Nov 18 12:04:08 2017 +0800
@@ -237,6 +237,10 @@
   background-color: #dfafff;
   border-color: #e2b8ff #ce48ff #ce48ff #e2b8ff;
 }
+span.logtags span.obsoletetag {
+  background-color: #dddddd;
+  border-color: #e4e4e4 #a3a3a3 #a3a3a3 #e4e4e4;
+}
 span.logtags span.tagtag {
   background-color: #ffffaa;
   border-color: #ffffcc #ffee00 #ffee00 #ffffcc;
--- a/mercurial/templates/static/style-paper.css	Sat Nov 18 11:58:57 2017 +0800
+++ b/mercurial/templates/static/style-paper.css	Sat Nov 18 12:04:08 2017 +0800
@@ -146,6 +146,15 @@
   vertical-align: baseline;
 }
 
+.obsolete {
+  color: #999;
+  font-size: 70%;
+  border-bottom: 1px dashed #999;
+  font-weight: normal;
+  margin-left: .5em;
+  vertical-align: baseline;
+}
+
 .tag {
   color: #999;
   font-size: 70%;
--- a/tests/test-hgweb.t	Sat Nov 18 11:58:57 2017 +0800
+++ b/tests/test-hgweb.t	Sat Nov 18 12:04:08 2017 +0800
@@ -340,7 +340,7 @@
 
   $ get-with-headers.py --twice localhost:$HGPORT 'static/style-gitweb.css' - date etag server
   200 Script output follows
-  content-length: 9151
+  content-length: 9261
   content-type: text/css
   
   body { font-family: sans-serif; font-size: 12px; border:solid #d9d8d1; border-width:1px; margin:10px; background: white; color: black; }
@@ -471,6 +471,10 @@
   	background-color: #dfafff;
   	border-color: #e2b8ff #ce48ff #ce48ff #e2b8ff;
   }
+  span.logtags span.obsoletetag {
+  	background-color: #dddddd;
+  	border-color: #e4e4e4 #a3a3a3 #a3a3a3 #e4e4e4;
+  }
   span.logtags span.tagtag {
   	background-color: #ffffaa;
   	border-color: #ffffcc #ffee00 #ffee00 #ffffcc;
--- a/tests/test-obsolete.t	Sat Nov 18 11:58:57 2017 +0800
+++ b/tests/test-obsolete.t	Sat Nov 18 12:04:08 2017 +0800
@@ -1015,6 +1015,30 @@
   orphan: 2 changesets
   phase-divergent: 1 changesets
 
+#if serve
+
+  $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
+  $ cat hg.pid >> $DAEMON_PIDS
+
+check obsolete changeset
+
+  $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=paper' | grep '<span class="obsolete">'
+     <span class="phase">draft</span> <span class="obsolete">obsolete</span> 
+  $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=coal' | grep '<span class="obsolete">'
+     <span class="phase">draft</span> <span class="obsolete">obsolete</span> 
+  $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=gitweb' | grep '<span class="logtags">'
+    <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="obsoletetag" title="obsolete">obsolete</span> </span>
+  $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=monoblue' | grep '<span class="logtags">'
+          <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="obsoletetag" title="obsolete">obsolete</span> </span>
+  $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=spartan' | grep 'class="obsolete"'
+    <th class="obsolete">obsolete:</th>
+    <td class="obsolete">yes</td>
+
+  $ killdaemons.py
+
+  $ rm hg.pid access.log errors.log
+#endif
+
 Test incoming/outcoming with changesets obsoleted remotely, known locally
 ===============================================================================