# HG changeset patch # User Denis Laxalde # Date 2017-04-10 14:23:41 # Node ID 604d31507f868d8d98bdcacb7e401950c8129869 # Parent 5e3b49defbff8f82ce8d906147a144e3c678937d 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}:{node|short} {branch%changelogbranchname}{tags%changelogtag}{bookmarks%changelogtag} {if(linerange, -' (following lines {linerange} back to filelog)')} +' (following lines {linerange}{if(descend, ', descending')} back to filelog)')} + + + + + + rss log