# HG changeset patch # User Denis Laxalde <denis.laxa...@logilab.fr> # Date 1491834221 -7200 # Mon Apr 10 16:23:41 2017 +0200 # Node ID a24bf350ea723273831d6531a1345ed458312126 # Parent 182fa6fb647dcfac8ebcc6a3a6646be43122b2b9 # Available At http://hg.logilab.org/users/dlaxalde/hg # hg pull http://hg.logilab.org/users/dlaxalde/hg -r a24bf350ea72 hgweb: handle a "descend" query parameter in filelog command
When this "descend" query parameter is present along with "linerange" parameter, we get revisions following line range in descending order. The parameter has no effect without "linerange". diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -979,6 +979,9 @@ def filelog(web, req, tmpl): patch = 'patch' in req.form if patch: lessvars['patch'] = morevars['patch'] = req.form['patch'][0] + descend = 'descend' in req.form + if descend: + lessvars['descend'] = morevars['descend'] = req.form['descend'][0] count = fctx.filerev() + 1 start = max(0, count - revcount) # first rev on this page @@ -1007,8 +1010,11 @@ def filelog(web, req, tmpl): # deactivate numeric nav links when linerange is specified as this # would required a dedicated "revnav" class nav = None - ancestors = context.blockancestors(fctx, *lrange) - for i, (c, lr) in enumerate(ancestors, 1): + if descend: + it = context.blockdescendants(fctx, *lrange) + else: + it = context.blockancestors(fctx, *lrange) + for i, (c, lr) in enumerate(it, 1): diffs = None if patch: diffs = diff(c, linerange=lr) @@ -1049,6 +1055,7 @@ def filelog(web, req, tmpl): nav=nav, symrev=webutil.symrevorshortnode(req, fctx), entries=entries, + descend=descend, patch=patch, latestentry=latestentry, linerange=linerange, diff --git a/mercurial/templates/paper/filelog.tmpl b/mercurial/templates/paper/filelog.tmpl --- a/mercurial/templates/paper/filelog.tmpl +++ b/mercurial/templates/paper/filelog.tmpl @@ -48,7 +48,7 @@ log {file|escape} @ {rev}:<a href="{url|urlescape}rev/{node|short}{sessionvars%urlparameter}">{node|short}</a> {branch%changelogbranchname}{tags%changelogtag}{bookmarks%changelogtag} {if(linerange, -' (following lines {linerange} <a href="{url|urlescape}log/{symrev}/{file|urlescape}{sessionvars%urlparameter}">back to filelog</a>)')} +' (following lines {linerange}{if(descend, ', descending')} <a href="{url|urlescape}log/{symrev}/{file|urlescape}{sessionvars%urlparameter}">back to filelog</a>)')} </h3> <form class="search" action="{url|urlescape}log"> diff --git a/tests/test-hgweb-filelog.t b/tests/test-hgweb-filelog.t --- a/tests/test-hgweb-filelog.t +++ b/tests/test-hgweb-filelog.t @@ -1501,6 +1501,170 @@ filelog with 'linerange' and 'patch' </body> </html> + $ hg log -r 'followlines(c, 3:4, startrev=8, descend=True) and follow(c)' -p + changeset: 10:e95928d60479 + branch: a-branch + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: touch beginning of c + + diff -r e1d3e9c5a23f -r e95928d60479 c + --- a/c Thu Jan 01 00:00:00 1970 +0000 + +++ b/c Thu Jan 01 00:00:00 1970 +0000 + @@ -1,7 +1,7 @@ + 0 + 0 + b + -c+ + +c++ + + a + a + + changeset: 11:fb9bc322513a + branch: a-branch + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: touching beginning and end of c + + diff -r e95928d60479 -r fb9bc322513a c + --- a/c Thu Jan 01 00:00:00 1970 +0000 + +++ b/c Thu Jan 01 00:00:00 1970 +0000 + @@ -1,6 +1,6 @@ + 0 + 0 + -b + +b- + c++ + + a + @@ -8,4 +8,4 @@ + + d + e+ + -f + +f+ + + $ (get-with-headers.py localhost:$HGPORT 'log/8/c?linerange=3:4&descend=') + 200 Script output follows + + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> + <head> + <link rel="icon" href="/static/hgicon.png" type="image/png" /> + <meta name="robots" content="index, nofollow" /> + <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> + <script type="text/javascript" src="/static/mercurial.js"></script> + + <title>test: c history</title> + <link rel="alternate" type="application/atom+xml" + href="/atom-log/tip/c" title="Atom feed for test:c" /> + <link rel="alternate" type="application/rss+xml" + href="/rss-log/tip/c" title="RSS feed for test:c" /> + </head> + <body> + + <div class="container"> + <div class="menu"> + <div class="logo"> + <a href="https://mercurial-scm.org/"> + <img src="/static/hglogo.png" alt="mercurial" /></a> + </div> + <ul> + <li><a href="/shortlog/8">log</a></li> + <li><a href="/graph/8">graph</a></li> + <li><a href="/tags">tags</a></li> + <li><a href="/bookmarks">bookmarks</a></li> + <li><a href="/branches">branches</a></li> + </ul> + <ul> + <li><a href="/rev/8">changeset</a></li> + <li><a href="/file/8">browse</a></li> + </ul> + <ul> + <li><a href="/file/8/c">file</a></li> + <li><a href="/diff/8/c">diff</a></li> + <li><a href="/comparison/8/c">comparison</a></li> + <li><a href="/annotate/8/c">annotate</a></li> + <li class="active">file log</li> + <li><a href="/raw-file/8/c">raw</a></li> + </ul> + <ul> + <li><a href="/help">help</a></li> + </ul> + <div class="atom-logo"> + <a href="/atom-log/tip/c" title="subscribe to atom feed"> + <img class="atom-logo" src="/static/feed-icon-14x14.png" alt="atom feed" /> + </a> + </div> + </div> + + <div class="main"> + <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2> + <h3> + log c @ 8:<a href="/rev/5c6574614c37">5c6574614c37</a> + <span class="branchname">a-branch</span> + (following lines 3:4, descending <a href="/log/8/c">back to filelog</a>) + </h3> + + <form class="search" action="/log"> + + <p><input name="rev" id="search1" type="text" size="30" /></p> + <div id="hint">Find changesets by keywords (author, files, the commit message), revision + number or hash, or <a href="/help/revsets">revset expression</a>.</div> + </form> + + <div class="navigate"> + <a href="/log/8/c?descend=&linerange=3%3A4&revcount=30">less</a> + <a href="/log/8/c?descend=&linerange=3%3A4&revcount=120">more</a> + | </div> + + <table class="bigtable"> + <thead> + <tr> + <th class="age">age</th> + <th class="author">author</th> + <th class="description">description</th> + </tr> + </thead> + <tbody class="stripes2"> + <tr> + <td class="age">Thu, 01 Jan 1970 00:00:00 +0000</td> + <td class="author">test</td> + <td class="description"> + <a href="/rev/e95928d60479">touch beginning of c</a> + <span class="branchname">a-branch</span> + </td> + </tr> + + <tr> + <td class="age">Thu, 01 Jan 1970 00:00:00 +0000</td> + <td class="author">test</td> + <td class="description"> + <a href="/rev/fb9bc322513a">touching beginning and end of c</a> + <span class="branchhead">a-branch</span> <span class="tag">tip</span> + </td> + </tr> + + + </tbody> + </table> + + <div class="navigate"> + <a href="/log/8/c?descend=&linerange=3%3A4&revcount=30">less</a> + <a href="/log/8/c?descend=&linerange=3%3A4&revcount=120">more</a> + | + </div> + + </div> + </div> + + + + </body> + </html> + rss log _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel