From patchwork Tue Jan 6 02:23:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 2] webcommands.changeset: add file_{adds, mods, dels} to template call From: Gregory Szorc X-Patchwork-Id: 7321 Message-Id: <0df221dbc14bcac4aed5.1420510997@3.1.168.192.in-addr.arpa> To: mercurial-devel@selenic.com Date: Mon, 05 Jan 2015 18:23:17 -0800 # HG changeset patch # User Gregory Szorc # Date 1420510217 28800 # Mon Jan 05 18:10:17 2015 -0800 # Node ID 0df221dbc14bcac4aed51917672b3a261e5922bd # Parent d944492445fa0d0b9c164336afab68127080a1f3 webcommands.changeset: add file_{adds,mods,dels} to template call As part of introducing a JSON template for hgweb, we wish to differentiate between different file activity on a changeset to maintain feature parity with the CLI output. This patch introduces {file_adds}, {file_mods}, and {file_dels}, which map to the CLI template keywords equivalents. Arguably, the whole status object should be exposed to the templater as one object. However, the template engine doesn't have a mechanism to access attributes on objects (just "get()", which accesses keys on dicts). Rather than bloat scope to implement such a function, I just added these 3 parameters to the templater. This patch also opens the door to more granular display of file changes on hgweb. This patch introduces the computation of status(). This could regress performance. However, the diff code that already executes should decode all relevant manifests and they should be in the manifest cache, facilitating a fast status() call. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -374,8 +374,10 @@ def changeset(web, req, tmpl): parity = paritygen(web.stripecount) diffstatgen = webutil.diffstatgen(ctx, basectx) diffstat = webutil.diffstat(tmpl, ctx, diffstatgen, parity) + status = ctx.status(basectx) + return tmpl('changeset', diff=diffs, rev=ctx.rev(), node=ctx.hex(), @@ -389,8 +391,11 @@ def changeset(web, req, tmpl): desc=ctx.description(), extra=ctx.extra(), date=ctx.date(), files=files, + file_mods=status.modified, + file_adds=status.added, + file_dels=status.deleted, diffsummary=lambda **x: webutil.diffsummary(diffstatgen), diffstat=diffstat, archives=web.archivelist(ctx.hex()), tags=webutil.nodetagsdict(web.repo, ctx.node()),