bug 1336090, wrap webutil.commonentry to add push metadata, r?gps draft
authorAxel Hecht <axel@pike.org>
Thu, 02 Feb 2017 15:10:25 +0100
changeset 10296 e8b5864a758c5b36fffbb1e6de9ce3670c24410c
parent 10280 20f8bfa2f2c28300161f33f8d7d92547647a4cd4
push id1507
push useraxel@mozilla.com
push dateThu, 02 Feb 2017 14:17:14 +0000
reviewersgps
bugs1336090
bug 1336090, wrap webutil.commonentry to add push metadata, r?gps Previously, we wrapped both changelistentry and changesetentry, which makes searches on the web not get pushlog data, as that's using commonentry directly. As both changelistentry and changesetentry base off of commonentry, let's just wrap that. commonentry was introduced in hg in https://www.mercurial-scm.org/repo/hg/diff/5aa2afb4f81a/mercurial/hgweb/webutil.py. MozReview-Commit-ID: 22G9ls2zd2O
hgext/pushlog/__init__.py
--- a/hgext/pushlog/__init__.py
+++ b/hgext/pushlog/__init__.py
@@ -165,27 +165,20 @@ def addpushmetadata(repo, ctx, d):
     if push:
         d['pushid'] = push.pushid
         d['pushuser'] = push.user
         d['pushdate'] = util.makedate(push.when)
         d['pushnodes'] = push.nodes
         d['pushhead'] = push.nodes[-1]
 
 
-def changesetentry(orig, web, req, tmpl, ctx):
-    """Wraps webutil.changesetentry to provide pushlog metadata to template."""
-    d = orig(web, req, tmpl, ctx)
-    addpushmetadata(web.repo, ctx, d)
-    return d
-
-
-def changelistentry(orig, web, ctx, tmpl):
-    """Wraps webutil.changelistentry to provide pushlog metadata to template."""
-    d = orig(web, ctx, tmpl)
-    addpushmetadata(web.repo, ctx, d)
+def commonentry(orig, repo, ctx):
+    """Wraps webutil.commonentry to provide pushlog metadata to templates."""
+    d = orig(repo, ctx)
+    addpushmetadata(repo, ctx, d)
     return d
 
 
 Push = collections.namedtuple('Push', ('pushid', 'user', 'when', 'nodes'))
 
 
 class pushlog(object):
     '''An interface to pushlog data.'''
@@ -751,18 +744,17 @@ def extsetup(ui):
     }
 
     templatekw.keywords.update(keywords)
 
     # dockeywords was removed in Mercurial 3.6.
     if hasattr(templatekw, 'dockeywords'):
         templatekw.dockeywords.update(keywords)
 
-    extensions.wrapfunction(webutil, 'changesetentry', changesetentry)
-    extensions.wrapfunction(webutil, 'changelistentry', changelistentry)
+    extensions.wrapfunction(webutil, 'commonentry', commonentry)
 
 
 def reposetup(ui, repo):
     if not repo.local():
         return
 
     ui.setconfig('hooks', 'pretxnchangegroup.pushlog', pretxnchangegrouphook, 'pushlog')