Patchwork hgweb: show obsolescence status of a commit

login
register
mail settings
Submitter Anton Shestakov
Date Nov. 17, 2017, 8:39 a.m.
Message ID <6ff29042647acd6d5f93.1510907956@neuro>
Download mbox | patch
Permalink /patch/25617/
State Superseded
Headers show

Comments

Anton Shestakov - Nov. 17, 2017, 8:39 a.m.
# HG changeset patch
# User Anton Shestakov <av6@dwimlabs.net>
# Date 1510906994 -28800
#      Fri Nov 17 16:23:14 2017 +0800
# Node ID 6ff29042647acd6d5f938b0e321afe4ce7df5508
# Parent  f1e997d4a24fb59ddd33c3780104dc002f870f5c
# EXP-Topic hgweb-more-info
hgweb: show obsolescence status of a commit

A new method is added to basefilectx class because filectx and changectx are
used interchangeably in hgweb views related to files (e.g. file view, diff,
annotate).

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. 17, 2017, 1:01 p.m.
On Fri, 17 Nov 2017 16:39:16 +0800
Anton Shestakov <av6@dwimlabs.net> wrote:

> # HG changeset patch
> # User Anton Shestakov <av6@dwimlabs.net>
> # Date 1510906994 -28800
> #      Fri Nov 17 16:23:14 2017 +0800
> # Node ID 6ff29042647acd6d5f938b0e321afe4ce7df5508
> # Parent  f1e997d4a24fb59ddd33c3780104dc002f870f5c
> # EXP-Topic hgweb-more-info
> hgweb: show obsolescence status of a commit
> 
> A new method is added to basefilectx class because filectx and changectx are
> used interchangeably in hgweb views related to files (e.g. file view, diff,
> annotate).
> 
> 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.

[snip]

> 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 changeset with instabilities

Oops, this should say "obsolete changeset". I can resend, but I will
wait for more feedback first.
Augie Fackler - Nov. 17, 2017, 6 p.m.
On Fri, Nov 17, 2017 at 04:39:16PM +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov <av6@dwimlabs.net>
> # Date 1510906994 -28800
> #      Fri Nov 17 16:23:14 2017 +0800
> # Node ID 6ff29042647acd6d5f938b0e321afe4ce7df5508
> # Parent  f1e997d4a24fb59ddd33c3780104dc002f870f5c
> # EXP-Topic hgweb-more-info
> hgweb: show obsolescence status of a commit
>
> A new method is added to basefilectx class because filectx and changectx are
> used interchangeably in hgweb views related to files (e.g. file view, diff,
> annotate).
>
> 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.
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -819,6 +819,8 @@ class basefilectx(object):
>          return self._changectx.phase()
>      def phasestr(self):
>          return self._changectx.phasestr()
> +    def obsolete(self):
> +        return self._changectx.obsolete()

My only comment is to send the context.py as a standalone change, but
even that's not really a hard requirement.

I like the feature, go ahead and send v2?

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -819,6 +819,8 @@  class basefilectx(object):
         return self._changectx.phase()
     def phasestr(self):
         return self._changectx.phasestr()
+    def obsolete(self):
+        return self._changectx.obsolete()
     def manifest(self):
         return self._changectx.manifest()
     def changectx(self):
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -361,6 +361,7 @@  def commonentry(repo, ctx):
         'date': ctx.date(),
         'extra': ctx.extra(),
         'phase': ctx.phasestr(),
+        'obsolete': ctx.obsolete(),
         'branch': nodebranchnodefault(ctx),
         'inbranch': nodeinbranch(repo, ctx),
         'branches': nodebranchdict(repo, ctx),
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 changeset with instabilities
+
+  $ 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
 ===============================================================================