pushlog: create pushes entry before adding node (
bug 1286426); r=glandium
An upcoming commit will change behavior to discard filtered nodes
but retain the push entry. To make the code simpler to read, create
the pushes entry first.
MozReview-Commit-ID: KaGHn862Pqg
--- a/hgext/pushlog-legacy/pushlog-feed.py
+++ b/hgext/pushlog-legacy/pushlog-feed.py
@@ -467,34 +467,40 @@ def pushlogHTML(web, req, tmpl):
archives=web.archivelist("tip"))
def pushes_worker(query, repo, full):
"""Given a PushlogQuery, return a data structure mapping push IDs
to a map of data about the push."""
pushes = {}
for id, user, date, node in query.entries:
id = str(id)
+
+ # Create the pushes entry first. It is OK to have empty
+ # pushes if nodes from the pushlog no longer exist.
+ if id not in pushes:
+ pushes[id] = {
+ 'user': user,
+ 'date': date,
+ 'changesets': [],
+ }
+
if full:
ctx = repo[node]
node = {
'node': ctx.hex(),
'author': ctx.user(),
'desc': ctx.description(),
'branch': ctx.branch(),
'parents': [c.hex() for c in ctx.parents()],
'tags': ctx.tags(),
'files': ctx.files()
}
- if id in pushes:
- # we get the pushes in reverse order
- pushes[id]['changesets'].insert(0, node)
- else:
- pushes[id] = {'user': user,
- 'date': date,
- 'changesets': [node]}
+
+ # we get the pushes in reverse order
+ pushes[id]['changesets'].insert(0, node)
return {'pushes': pushes, 'lastpushid': query.lastpushid}
def pushes(web, req, tmpl):
"""WebCommand to return a data structure containing pushes."""
query = pushlogSetup(web.repo, req)
data = pushes_worker(query, web.repo, 'full' in req.form)