Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/webcommands.py @ 38138:8e9ce73ceb15
hgweb: wrap {parents} of {annotate} with mappinggenerator
It's a generator of at most two mappings, which has to be wrapped.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 04 Apr 2018 20:29:58 +0900 |
parents | 3e6253438bf9 |
children | d32f07069dd1 |
comparison
equal
deleted
inserted
replaced
38137:3e6253438bf9 | 38138:8e9ce73ceb15 |
---|---|
927 # parents() is called once per line and several lines likely belong to | 927 # parents() is called once per line and several lines likely belong to |
928 # same revision. So it is worth caching. | 928 # same revision. So it is worth caching. |
929 # TODO there are still redundant operations within basefilectx.parents() | 929 # TODO there are still redundant operations within basefilectx.parents() |
930 # and from the fctx.annotate() call itself that could be cached. | 930 # and from the fctx.annotate() call itself that could be cached. |
931 parentscache = {} | 931 parentscache = {} |
932 def parents(f): | 932 def parents(context, f): |
933 rev = f.rev() | 933 rev = f.rev() |
934 if rev not in parentscache: | 934 if rev not in parentscache: |
935 parentscache[rev] = [] | 935 parentscache[rev] = [] |
936 for p in f.parents(): | 936 for p in f.parents(): |
937 entry = { | 937 entry = { |
965 previousrev = rev | 965 previousrev = rev |
966 yield {"parity": next(parity), | 966 yield {"parity": next(parity), |
967 "node": f.hex(), | 967 "node": f.hex(), |
968 "rev": rev, | 968 "rev": rev, |
969 "author": f.user(), | 969 "author": f.user(), |
970 "parents": parents(f), | 970 "parents": templateutil.mappinggenerator(parents, args=(f,)), |
971 "desc": f.description(), | 971 "desc": f.description(), |
972 "extra": f.extra(), | 972 "extra": f.extra(), |
973 "file": f.path(), | 973 "file": f.path(), |
974 "blockhead": blockhead, | 974 "blockhead": blockhead, |
975 "blockparity": blockparity, | 975 "blockparity": blockparity, |