Mercurial > hg
comparison mercurial/hgweb/webcommands.py @ 31939:604d31507f86
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".
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Mon, 10 Apr 2017 16:23:41 +0200 |
parents | 6be6e4becaaf |
children | a298f5c61b34 |
comparison
equal
deleted
inserted
replaced
31938:5e3b49defbff | 31939:604d31507f86 |
---|---|
977 morevars['revcount'] = revcount * 2 | 977 morevars['revcount'] = revcount * 2 |
978 | 978 |
979 patch = 'patch' in req.form | 979 patch = 'patch' in req.form |
980 if patch: | 980 if patch: |
981 lessvars['patch'] = morevars['patch'] = req.form['patch'][0] | 981 lessvars['patch'] = morevars['patch'] = req.form['patch'][0] |
982 descend = 'descend' in req.form | |
983 if descend: | |
984 lessvars['descend'] = morevars['descend'] = req.form['descend'][0] | |
982 | 985 |
983 count = fctx.filerev() + 1 | 986 count = fctx.filerev() + 1 |
984 start = max(0, count - revcount) # first rev on this page | 987 start = max(0, count - revcount) # first rev on this page |
985 end = min(count, start + revcount) # last rev on this page | 988 end = min(count, start + revcount) # last rev on this page |
986 parity = paritygen(web.stripecount, offset=start - end) | 989 parity = paritygen(web.stripecount, offset=start - end) |
1005 if lrange is not None: | 1008 if lrange is not None: |
1006 linerange = webutil.formatlinerange(*lrange) | 1009 linerange = webutil.formatlinerange(*lrange) |
1007 # deactivate numeric nav links when linerange is specified as this | 1010 # deactivate numeric nav links when linerange is specified as this |
1008 # would required a dedicated "revnav" class | 1011 # would required a dedicated "revnav" class |
1009 nav = None | 1012 nav = None |
1010 ancestors = context.blockancestors(fctx, *lrange) | 1013 if descend: |
1011 for i, (c, lr) in enumerate(ancestors, 1): | 1014 it = context.blockdescendants(fctx, *lrange) |
1015 else: | |
1016 it = context.blockancestors(fctx, *lrange) | |
1017 for i, (c, lr) in enumerate(it, 1): | |
1012 diffs = None | 1018 diffs = None |
1013 if patch: | 1019 if patch: |
1014 diffs = diff(c, linerange=lr) | 1020 diffs = diff(c, linerange=lr) |
1015 # follow renames accross filtered (not in range) revisions | 1021 # follow renames accross filtered (not in range) revisions |
1016 path = c.path() | 1022 path = c.path() |
1047 return tmpl("filelog", | 1053 return tmpl("filelog", |
1048 file=f, | 1054 file=f, |
1049 nav=nav, | 1055 nav=nav, |
1050 symrev=webutil.symrevorshortnode(req, fctx), | 1056 symrev=webutil.symrevorshortnode(req, fctx), |
1051 entries=entries, | 1057 entries=entries, |
1058 descend=descend, | |
1052 patch=patch, | 1059 patch=patch, |
1053 latestentry=latestentry, | 1060 latestentry=latestentry, |
1054 linerange=linerange, | 1061 linerange=linerange, |
1055 revcount=revcount, | 1062 revcount=revcount, |
1056 morevars=morevars, | 1063 morevars=morevars, |