hgweb: allow viewing diffs against p1 or p2 for merge commits (
issue3904)
This adds UI portion of the feature that has resided in mercurial since 2012.
Back then the interface was added together with the code, but was shortly
backed out because it was deemed "not ready". Code, however, stayed.
For the original feature and its implementation, see
issue2810 and
d605a82cf189.
In short, the backed-out interface had two outstanding issues:
1. it was introducing an entirely new term (baseline) and
2. it was present on every changeset's page, even for changesets with 1 parent
(or no parents), which didn't make sense
This patch implements a hopefully better interface because:
1. it uses the usual terms (diff) and
2. it only shows up when there actually are 2 parents.
--- a/mercurial/hgweb/webcommands.py Sun Dec 21 14:34:07 2014 -0800
+++ b/mercurial/hgweb/webcommands.py Sat Jan 03 17:50:21 2015 +0800
@@ -379,7 +379,7 @@
diff=diffs,
rev=ctx.rev(),
node=ctx.hex(),
- parent=webutil.parents(ctx),
+ parent=tuple(webutil.parents(ctx)),
child=webutil.children(ctx),
basenode=basectx.hex(),
changesettag=showtags,
--- a/mercurial/templates/coal/map Sun Dec 21 14:34:07 2014 -0800
+++ b/mercurial/templates/coal/map Sat Jan 03 17:50:21 2015 +0800
@@ -109,6 +109,12 @@
changesetparent = '<a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a> '
+changesetparentdiff = '
+ {changesetparent}
+ {ifeq(node, basenode, '(current diff)', '({difffrom})')}'
+
+difffrom = '<a href="{url|urlescape}rev/{node|short}:{originalnode|short}{sessionvars%urlparameter}">diff</a>'
+
filerevparent = '<a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rename%filerename}{node|short}</a> '
filerevchild = '<a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a> '
--- a/mercurial/templates/gitweb/changeset.tmpl Sun Dec 21 14:34:07 2014 -0800
+++ b/mercurial/templates/gitweb/changeset.tmpl Sat Jan 03 17:50:21 2015 +0800
@@ -36,7 +36,7 @@
<tr><td></td><td class="date age">{date|rfc822date}</td></tr>
{branch%changesetbranch}
<tr><td>changeset {rev}</td><td style="font-family:monospace">{node|short}</td></tr>
-{parent%changesetparent}
+{ifeq(count(parent), '2', parent%changesetparentdiff, parent%changesetparent)}
{child%changesetchild}
</table></div>
--- a/mercurial/templates/gitweb/map Sun Dec 21 14:34:07 2014 -0800
+++ b/mercurial/templates/gitweb/map Sat Jan 03 17:50:21 2015 +0800
@@ -127,14 +127,23 @@
<a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>
</td>
</tr>'
+changesetlink = '<a class="list" href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>'
changesetbranch = '<tr><td>branch</td><td>{name|escape}</td></tr>'
changesetparent = '
<tr>
<td>parent {rev}</td>
<td style="font-family:monospace">
- <a class="list" href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>
+ {changesetlink}
</td>
</tr>'
+changesetparentdiff = '
+ <tr>
+ <td>parent {rev}</td>
+ <td style="font-family:monospace">
+ {changesetlink} {ifeq(node, basenode, '(current diff)', \'({difffrom})\')}
+ </td>
+ </tr>'
+difffrom = '<a href="{url|urlescape}rev/{node|short}:{originalnode|short}{sessionvars%urlparameter}">diff</a>'
filerevbranch = '<tr><td>branch</td><td>{name|escape}</td></tr>'
filerevparent = '
<tr>
--- a/mercurial/templates/monoblue/changeset.tmpl Sun Dec 21 14:34:07 2014 -0800
+++ b/mercurial/templates/monoblue/changeset.tmpl Sat Jan 03 17:50:21 2015 +0800
@@ -48,7 +48,7 @@
{branch%changesetbranch}
<dt>changeset {rev}</dt>
<dd>{node|short}</dd>
- {parent%changesetparent}
+ {ifeq(count(parent), '2', parent%changesetparentdiff, parent%changesetparent)}
{child%changesetchild}
</dl>
--- a/mercurial/templates/monoblue/map Sun Dec 21 14:34:07 2014 -0800
+++ b/mercurial/templates/monoblue/map Sat Jan 03 17:50:21 2015 +0800
@@ -115,17 +115,22 @@
<td class="source {type}"><a class="linenr" href="#{lineid}" id="{lineid}">{rightlinenumber}</a> {rightline|escape}</td>
</tr>'
+changesetlink = '<a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>'
changelogparent = '
<tr>
<th class="parent">parent {rev}:</th>
<td class="parent">
- <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>
+ {changesetlink}
</td>
</tr>'
changesetbranch = '<dt>branch</dt><dd>{name|escape}</dd>'
changesetparent = '
<dt>parent {rev}</dt>
- <dd><a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></dd>'
+ <dd>{changesetlink}</dd>'
+changesetparentdiff = '
+ <dt>parent {rev}</dt>
+ <dd>{changesetlink} {ifeq(node, basenode, '(current diff)', \'({difffrom})\')}</dd>'
+difffrom = '<a href="{url|urlescape}rev/{node|short}:{originalnode|short}{sessionvars%urlparameter}">diff</a>'
filerevbranch = '<dt>branch</dt><dd>{name|escape}</dd>'
filerevparent = '
<dt>parent {rev}</dt>
--- a/mercurial/templates/paper/changeset.tmpl Sun Dec 21 14:34:07 2014 -0800
+++ b/mercurial/templates/paper/changeset.tmpl Sat Jan 03 17:50:21 2015 +0800
@@ -51,7 +51,7 @@
<td class="date age">{date|rfc822date}</td></tr>
<tr>
<th class="author">parents</th>
- <td class="author">{parent%changesetparent}</td>
+ <td class="author">{ifeq(count(parent), '2', parent%changesetparentdiff, parent%changesetparent)}</td>
</tr>
<tr>
<th class="author">children</th>
--- a/mercurial/templates/paper/map Sun Dec 21 14:34:07 2014 -0800
+++ b/mercurial/templates/paper/map Sat Jan 03 17:50:21 2015 +0800
@@ -112,7 +112,11 @@
changesetparent = '<a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a> '
-difffrom = '<a href="{url|urlescape}rev/{node|short}:{originalnode|short}{sessionvars%urlparameter}">{node|short}</a> '
+changesetparentdiff = '
+ {changesetparent}
+ {ifeq(node, basenode, '(current diff)', '({difffrom})')}'
+
+difffrom = '<a href="{url|urlescape}rev/{node|short}:{originalnode|short}{sessionvars%urlparameter}">diff</a>'
filerevparent = '<a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rename%filerename}{node|short}</a> '
filerevchild = '<a href="{url|urlescape}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a> '
--- a/mercurial/templates/spartan/changeset.tmpl Sun Dec 21 14:34:07 2014 -0800
+++ b/mercurial/templates/spartan/changeset.tmpl Sat Jan 03 17:50:21 2015 +0800
@@ -22,7 +22,7 @@
<th class="changeset">changeset {rev}:</th>
<td class="changeset"><a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td>
</tr>
-{parent%changesetparent}
+{ifeq(count(parent), '2', parent%changesetparentdiff, parent%changesetparent)}
{child%changesetchild}
{changesettag}
<tr>
--- a/mercurial/templates/spartan/map Sun Dec 21 14:34:07 2014 -0800
+++ b/mercurial/templates/spartan/map Sat Jan 03 17:50:21 2015 +0800
@@ -68,18 +68,25 @@
difflineminus = '<span class="minusline"><a class="lineno" href="#{lineid}" id="{lineid}">{linenumber}</a>{line|escape}</span>'
difflineat = '<span class="atline"><a class="lineno" href="#{lineid}" id="{lineid}">{linenumber}</a>{line|escape}</span>'
diffline = '<a class="lineno" href="#{lineid}" id="{lineid}">{linenumber}</a>{line|escape}'
+changesetlink = '<a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>'
changelogparent = '
<tr>
<th class="parent">parent {rev}:</th>
<td class="parent">
- <a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a>
+ {changesetlink}
</td>
</tr>'
changesetparent = '
<tr>
<th class="parent">parent {rev}:</th>
- <td class="parent"><a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a></td>
+ <td class="parent">{changesetlink}</td>
</tr>'
+changesetparentdiff = '
+ <tr>
+ <th class="parent">parent {rev}:</th>
+ <td class="parent">{changesetlink} {ifeq(node, basenode, '(current diff)', '({difffrom})')}</td>
+ </tr>'
+difffrom = '<a href="{url|urlescape}rev/{node|short}:{originalnode|short}{sessionvars%urlparameter}">diff</a>'
filerevparent = '
<tr>
<td class="metatag">parent:</td>