Submitter | Gregory Szorc |
---|---|
Date | Jan. 6, 2015, 2:23 a.m. |
Message ID | <0df221dbc14bcac4aed5.1420510997@3.1.168.192.in-addr.arpa> |
Download | mbox | patch |
Permalink | /patch/7321/ |
State | Changes Requested |
Headers | show |
Comments
On Mon, 2015-01-05 at 18:23 -0800, Gregory Szorc wrote: > # HG changeset patch > # User Gregory Szorc <gregory.szorc@gmail.com> > # 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. The usual trick with passing expensive-might-not-be-used stuff to the templater is to pass a callable.
Patch
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()),