Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/webutil.py @ 26129:a103ecb8a04a
hgweb: move branchentries code from webcommands to webutil
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Tue, 01 Sep 2015 22:28:45 +0800 |
parents | 1c75249e159b |
children | 268b39770c28 |
comparison
equal
deleted
inserted
replaced
26128:51f6940d3b4f | 26129:a103ecb8a04a |
---|---|
196 yield tmpl(t1, tag=t, **args) | 196 yield tmpl(t1, tag=t, **args) |
197 | 197 |
198 def showbookmark(repo, tmpl, t1, node=nullid, **args): | 198 def showbookmark(repo, tmpl, t1, node=nullid, **args): |
199 for t in repo.nodebookmarks(node): | 199 for t in repo.nodebookmarks(node): |
200 yield tmpl(t1, bookmark=t, **args) | 200 yield tmpl(t1, bookmark=t, **args) |
201 | |
202 def branchentries(repo, stripecount, limit=0): | |
203 tips = [] | |
204 heads = repo.heads() | |
205 parity = paritygen(stripecount) | |
206 sortkey = lambda item: (not item[1], item[0].rev()) | |
207 | |
208 def entries(**map): | |
209 count = 0 | |
210 if not tips: | |
211 for tag, hs, tip, closed in repo.branchmap().iterbranches(): | |
212 tips.append((repo[tip], closed)) | |
213 for ctx, closed in sorted(tips, key=sortkey, reverse=True): | |
214 if limit > 0 and count >= limit: | |
215 return | |
216 count += 1 | |
217 if closed: | |
218 status = 'closed' | |
219 elif ctx.node() not in heads: | |
220 status = 'inactive' | |
221 else: | |
222 status = 'open' | |
223 yield { | |
224 'parity': parity.next(), | |
225 'branch': ctx.branch(), | |
226 'status': status, | |
227 'node': ctx.hex(), | |
228 'date': ctx.date() | |
229 } | |
230 | |
231 return entries | |
201 | 232 |
202 def cleanpath(repo, path): | 233 def cleanpath(repo, path): |
203 path = path.lstrip('/') | 234 path = path.lstrip('/') |
204 return pathutil.canonpath(repo.root, '', path) | 235 return pathutil.canonpath(repo.root, '', path) |
205 | 236 |