Patchwork [2,of,2,v2] hgweb: show obsolescence status of a commit

login
register
mail settings
Submitter Anton Shestakov
Date Nov. 18, 2017, 4:41 a.m.
Message ID <38e695b081ed5fdbaad1.1510980066@neuro>
Download mbox | patch
Permalink /patch/25635/
State Superseded
Headers show

Comments

Anton Shestakov - Nov. 18, 2017, 4:41 a.m.
# HG changeset patch
# User Anton Shestakov <av6@dwimlabs.net>
# Date 1510977848 -28800
#      Sat Nov 18 12:04:08 2017 +0800
# Node ID 38e695b081ed5fdbaad1da0df6d8236ace5a9f29
# Parent  f7de3640058b0cef36a1af5b237827a922e84ca2
# EXP-Topic hgweb-more-info
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). In gitweb and monoblue the element has gray
background, in paper and coal the element is gray with a dashed underline.
Anton Shestakov - Nov. 18, 2017, 5:12 a.m.
On Sat, 18 Nov 2017 12:41:06 +0800
Anton Shestakov <av6@dwimlabs.net> wrote:

> diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
> --- a/tests/test-obsolete.t
> +++ b/tests/test-obsolete.t
> @@ -1015,6 +1015,43 @@ test summary output
>    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 -A3 '<td class="description">'

Turns out check-code tries to forbid grep with -A, only with not much
success (tests passed for me). I've sent a patch for it.

I'll send a v3.

Patch

diff --git a/mercurial/templates/gitweb/map b/mercurial/templates/gitweb/map
--- a/mercurial/templates/gitweb/map
+++ b/mercurial/templates/gitweb/map
@@ -263,11 +263,12 @@  filecompchild = '
 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>
diff --git a/mercurial/templates/monoblue/map b/mercurial/templates/monoblue/map
--- a/mercurial/templates/monoblue/map
+++ b/mercurial/templates/monoblue/map
@@ -222,11 +222,12 @@  filecompchild = '
   <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>
diff --git a/mercurial/templates/paper/map b/mercurial/templates/paper/map
--- a/mercurial/templates/paper/map
+++ b/mercurial/templates/paper/map
@@ -199,12 +199,13 @@  branchentry = '
     </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>
diff --git a/mercurial/templates/spartan/changelogentry.tmpl b/mercurial/templates/spartan/changelogentry.tmpl
--- a/mercurial/templates/spartan/changelogentry.tmpl
+++ b/mercurial/templates/spartan/changelogentry.tmpl
@@ -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>
diff --git a/mercurial/templates/spartan/changeset.tmpl b/mercurial/templates/spartan/changeset.tmpl
--- a/mercurial/templates/spartan/changeset.tmpl
+++ b/mercurial/templates/spartan/changeset.tmpl
@@ -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>
diff --git a/mercurial/templates/static/style-gitweb.css b/mercurial/templates/static/style-gitweb.css
--- a/mercurial/templates/static/style-gitweb.css
+++ b/mercurial/templates/static/style-gitweb.css
@@ -126,6 +126,10 @@  span.logtags span.phasetag {
 	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;
diff --git a/mercurial/templates/static/style-monoblue.css b/mercurial/templates/static/style-monoblue.css
--- a/mercurial/templates/static/style-monoblue.css
+++ b/mercurial/templates/static/style-monoblue.css
@@ -237,6 +237,10 @@  span.logtags span.phasetag {
   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;
diff --git a/mercurial/templates/static/style-paper.css b/mercurial/templates/static/style-paper.css
--- a/mercurial/templates/static/style-paper.css
+++ b/mercurial/templates/static/style-paper.css
@@ -146,6 +146,15 @@  a { text-decoration:none; }
   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%;
diff --git a/tests/test-hgweb.t b/tests/test-hgweb.t
--- a/tests/test-hgweb.t
+++ b/tests/test-hgweb.t
@@ -340,7 +340,7 @@  static file
 
   $ 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 @@  static file
   	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;
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -1015,6 +1015,43 @@  test summary output
   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 -A3 '<td class="description">'
+    <td class="description">
+     <a href="/rev/94b33453f93b?style=paper">add original_d</a>
+     <span class="phase">draft</span> <span class="obsolete">obsolete</span> 
+    </td>
+  $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=coal' | grep -A3 '<td class="description">'
+    <td class="description">
+     <a href="/rev/94b33453f93b?style=coal">add original_d</a>
+     <span class="phase">draft</span> <span class="obsolete">obsolete</span> 
+    </td>
+  $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=gitweb' | grep -A4 '<a class="title"'
+   <a class="title" href="/rev/94b33453f93b?style=gitweb">
+    <span class="age">Thu, 01 Jan 1970 00:00:00 +0000</span>
+    add original_d
+    <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="obsoletetag" title="obsolete">obsolete</span> </span>
+   </a>
+  $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=monoblue' | grep -A3 '<a class="title"'
+      <a class="title" href="/rev/94b33453f93b?style=monoblue">
+          add original_d
+          <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="obsoletetag" title="obsolete">obsolete</span> </span>
+      </a>
+  $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=spartan' | grep -A1 '<th 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
 ===============================================================================