<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>
<div><br>
</div>
<div># HG changeset patch</div>
<div># User Weiwen <weiwen@fb.com></div>
<div># Date 1352757939 28800</div>
<div># Node ID 3502c78b6b53ec6ca3e583019e8704014f9357f8</div>
<div># Parent  fb14a5dcdc62987512820531fe60719d650491b6</div>
<div>hgweb: display difference for a changeset against any parents (issue2810)</div>
<div><br>
</div>
<div>During merge of branches, it is useful to compare merge results against</div>
<div>the two parents.  This change adds this support to hgweb.  To specify</div>
<div>which parent to compare to, use rev/12345?base=12300 where 12300 is a</div>
<div>parent changeset number.  Two links are added to changeset web page so</div>
<div>that one can choose which parent to compare to.</div>
<div><br>
</div>
<div>diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py</div>
<div>--- a/mercurial/hgweb/webcommands.py</div>
<div>+++ b/mercurial/hgweb/webcommands.py</div>
<div>@@ -255,6 +255,9 @@</div>
<div> </div>
<div> def changeset(web, req, tmpl):</div>
<div>     ctx = webutil.changectx(web.repo, req)</div>
<div>+    basectx = webutil.changectx(web.repo, req, 'base')</div>
<div>+    if basectx is None:</div>
<div>+        basectx = ctx.p1()</div>
<div>     showtags = webutil.showtag(web.repo, tmpl, 'changesettag', ctx.node())</div>
<div>     showbookmarks = webutil.showbookmark(web.repo, tmpl, 'changesetbookmark',</div>
<div>                                          ctx.node())</div>
<div>@@ -273,10 +276,10 @@</div>
<div>         style = req.form['style'][0]</div>
<div> </div>
<div>     parity = paritygen(web.stripecount)</div>
<div>-    diffs = webutil.diffs(web.repo, tmpl, ctx, None, parity, style)</div>
<div>+    diffs = webutil.diffs(web.repo, tmpl, ctx, basectx, None, parity, style)</div>
<div> </div>
<div>     parity = paritygen(web.stripecount)</div>
<div>-    diffstatgen = webutil.diffstatgen(ctx)</div>
<div>+    diffstatgen = webutil.diffstatgen(ctx, basectx)</div>
<div>     diffstat = webutil.diffstat(tmpl, ctx, diffstatgen, parity)</div>
<div> </div>
<div>     return tmpl('changeset',</div>
<div>@@ -285,6 +288,8 @@</div>
<div>                 node=ctx.hex(),</div>
<div>                 parent=webutil.parents(ctx),</div>
<div>                 child=webutil.children(ctx),</div>
<div>+                baseline=webutil.parents(ctx),</div>
<div>+                currentbaseline=basectx.hex(),</div>
<div>                 changesettag=showtags,</div>
<div>                 changesetbookmark=showbookmarks,</div>
<div>                 changesetbranch=showbranch,</div>
<div>@@ -566,7 +571,7 @@</div>
<div>     if 'style' in req.form:</div>
<div>         style = req.form['style'][0]</div>
<div> </div>
<div>-    diffs = webutil.diffs(web.repo, tmpl, ctx, [path], parity, style)</div>
<div>+    diffs = webutil.diffs(web.repo, tmpl, ctx, None, [path], parity, style)</div>
<div>     rename = fctx and webutil.renamelink(fctx) or []</div>
<div>     ctx = fctx and fctx or ctx</div>
<div>     return tmpl("filediff",</div>
<div>diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py</div>
<div>--- a/mercurial/hgweb/webutil.py</div>
<div>+++ b/mercurial/hgweb/webutil.py</div>
<div>@@ -140,10 +140,13 @@</div>
<div>     path = path.lstrip('/')</div>
<div>     return scmutil.canonpath(repo.root, '', path)</div>
<div> </div>
<div>-def changectx(repo, req):</div>
<div>+def changectx(repo, req, nodename='node'):</div>
<div>     changeid = "tip"</div>
<div>-    if 'node' in req.form:</div>
<div>-        changeid = req.form['node'][0]</div>
<div>+</div>
<div>+    if nodename in req.form:</div>
<div>+        changeid = req.form[nodename][0]</div>
<div>+    elif nodename == 'base':</div>
<div>+        return None</div>
<div>     elif 'manifest' in req.form:</div>
<div>         changeid = req.form['manifest'][0]</div>
<div> </div>
<div>@@ -178,7 +181,7 @@</div>
<div>     if len(files) > max:</div>
<div>         yield tmpl('fileellipses')</div>
<div> </div>
<div>-def diffs(repo, tmpl, ctx, files, parity, style):</div>
<div>+def diffs(repo, tmpl, ctx, basectx, files, parity, style):</div>
<div> </div>
<div>     def countgen():</div>
<div>         start = 1</div>
<div>@@ -209,8 +212,11 @@</div>
<div>         m = match.always(repo.root, repo.getcwd())</div>
<div> </div>
<div>     diffopts = patch.diffopts(repo.ui, untrusted=True)</div>
<div>-    parents = ctx.parents()</div>
<div>-    node1 = parents and parents[0].node() or nullid</div>
<div>+    if basectx is None:</div>
<div>+        parents = ctx.parents()</div>
<div>+        node1 = parents and parents[0].node() or nullid</div>
<div>+    else:</div>
<div>+        node1 = basectx.node()</div>
<div>     node2 = ctx.node()</div>
<div> </div>
<div>     block = []</div>
<div>@@ -274,10 +280,10 @@</div>
<div>         for oc in s.get_grouped_opcodes(n=context):</div>
<div>             yield tmpl('comparisonblock', lines=getblock(oc))</div>
<div> </div>
<div>-def diffstatgen(ctx):</div>
<div>+def diffstatgen(ctx, basectx):</div>
<div>     '''Generator function that provides the diffstat data.'''</div>
<div> </div>
<div>-    stats = patch.diffstatdata(util.iterlines(ctx.diff()))</div>
<div>+    stats = patch.diffstatdata(util.iterlines(ctx.diff(basectx)))</div>
<div>     maxname, maxtotal, addtotal, removetotal, binary = patch.diffstatsum(stats)</div>
<div>     while True:</div>
<div>         yield stats, maxname, maxtotal, addtotal, removetotal, binary</div>
<div>diff --git a/mercurial/templater.py b/mercurial/templater.py</div>
<div>--- a/mercurial/templater.py</div>
<div>+++ b/mercurial/templater.py</div>
<div>@@ -179,6 +179,7 @@</div>
<div>     for i in d:</div>
<div>         if isinstance(i, dict):</div>
<div>             lm.update(i)</div>
<div>+            lm['originalnode'] = mapping.get('node')</div>
<div>             yield runtemplate(context, lm, ctmpl)</div>
<div>         else:</div>
<div>             # v is not an iterable of dicts, this happen when 'key'</div>
<div>diff --git a/mercurial/templates/paper/changeset.tmpl b/mercurial/templates/paper/changeset.tmpl</div>
<div>--- a/mercurial/templates/paper/changeset.tmpl</div>
<div>+++ b/mercurial/templates/paper/changeset.tmpl</div>
<div>@@ -74,6 +74,14 @@</div>
<div>     </div></div>
<div>   </td></div>
<div> </tr></div>
<div>+<tr></div>
<div>+ <th class="author">change baseline</th></div>
<div>+ <td class="author">{baseline%changesetbaseline}</td></div>
<div>+</tr></div>
<div>+<tr></div>
<div>+ <th class="author">current baseline</th></div>
<div>+ <td class="author"><a href="{url}rev/{currentbaseline|short}{sessionvars%urlparameter}">{currentbaseline|short}</a> </td> </div>
<div>+</tr></div>
<div> </table></div>
<div> </div>
<div> <div class="overflow"></div>
<div>diff --git a/mercurial/templates/paper/map b/mercurial/templates/paper/map</div>
<div>--- a/mercurial/templates/paper/map</div>
<div>+++ b/mercurial/templates/paper/map</div>
<div>@@ -101,6 +101,8 @@</div>
<div> </div>
<div> changesetparent = '<a href="{url}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a> '</div>
<div> </div>
<div>+changesetbaseline = '<a href="{url}rev/{originalnode|short}?base={node|short}{sessionvars%urlparameter}">{node|short} </a> '</div>
<div>+</div>
<div> filerevparent = '<a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rename%filerename}{node|short}</a> '</div>
<div> filerevchild = '<a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{node|short}</a> '</div>
<div> </div>
<div>diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t</div>
<div>--- a/tests/test-hgweb-commands.t</div>
<div>+++ b/tests/test-hgweb-commands.t</div>
<div>@@ -441,6 +441,14 @@</div>
<div>       </div></div>
<div>     </td></div>
<div>   </tr></div>
<div>+  <tr></div>
<div>+   <th class="author">change baseline</th></div>
<div>+   <td class="author"></td></div>
<div>+  </tr></div>
<div>+  <tr></div>
<div>+   <th class="author">current baseline</th></div>
<div>+   <td class="author"><a href="/rev/000000000000">000000000000</a> </td> </div>
<div>+  </tr></div>
<div>   </table></div>
<div>   </div>
<div>   <div class="overflow"></div>
<div>diff --git a/tests/test-hgweb-diffs.t b/tests/test-hgweb-diffs.t</div>
<div>--- a/tests/test-hgweb-diffs.t</div>
<div>+++ b/tests/test-hgweb-diffs.t</div>
<div>@@ -139,6 +139,14 @@</div>
<div>       </div></div>
<div>     </td></div>
<div>   </tr></div>
<div>+  <tr></div>
<div>+   <th class="author">change baseline</th></div>
<div>+   <td class="author"></td></div>
<div>+  </tr></div>
<div>+  <tr></div>
<div>+   <th class="author">current baseline</th></div>
<div>+   <td class="author"><a href="/rev/000000000000">000000000000</a> </td> </div>
<div>+  </tr></div>
<div>   </table></div>
<div>   </div>
<div>   <div class="overflow"></div>
<div>@@ -400,6 +408,14 @@</div>
<div>       </div></div>
<div>     </td></div>
<div>   </tr></div>
<div>+  <tr></div>
<div>+   <th class="author">change baseline</th></div>
<div>+   <td class="author"></td></div>
<div>+  </tr></div>
<div>+  <tr></div>
<div>+   <th class="author">current baseline</th></div>
<div>+   <td class="author"><a href="/rev/000000000000">000000000000</a> </td> </div>
<div>+  </tr></div>
<div>   </table></div>
<div>   </div>
<div>   <div class="overflow"></div>
<div>diff --git a/tests/test-hgweb-removed.t b/tests/test-hgweb-removed.t</div>
<div>--- a/tests/test-hgweb-removed.t</div>
<div>+++ b/tests/test-hgweb-removed.t</div>
<div>@@ -112,6 +112,14 @@</div>
<div>       </div></div>
<div>     </td></div>
<div>   </tr></div>
<div>+  <tr></div>
<div>+   <th class="author">change baseline</th></div>
<div>+   <td class="author"><a href="/rev/c78f6c5cbea9?base=cb9a9f314b8b">cb9a9f314b8b </a> </td></div>
<div>+  </tr></div>
<div>+  <tr></div>
<div>+   <th class="author">current baseline</th></div>
<div>+   <td class="author"><a href="/rev/cb9a9f314b8b">cb9a9f314b8b</a> </td> </div>
<div>+  </tr></div>
<div>   </table></div>
<div>   </div>
<div>   <div class="overflow"></div>
<div><br>
</div>
</div>
</body>
</html>