Patchwork [1,of,3] hgweb: add a status property to file list context

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date Nov. 15, 2019, 9:02 p.m.
Message ID <66854dfbde7f2191ff3d.1573851756@chloe>
Download mbox | patch
Permalink /patch/43285/
State Accepted
Headers show

Comments

Jordi Gutiérrez Hermoso - Nov. 15, 2019, 9:02 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1573851721 18000
#      Fri Nov 15 16:02:01 2019 -0500
# Node ID 66854dfbde7f2191ff3da155872ac15f1b8e6934
# Parent  303bf312d5edfab57ee03dd7f645b44d105b8bd3
hgweb: add a status property to file list context

The web templates merely indicate if files touched by this revision
are in the commit or not, i.e. if they are removed. It would be
helpful to have more context and also indicate whether the files are
added, modified, or removed.

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -541,8 +541,15 @@  def symrevorshortnode(req, ctx):
 
 def _listfilesgen(context, ctx, stripecount):
     parity = paritygen(stripecount)
+    filesadded = ctx.filesadded()
     for blockno, f in enumerate(ctx.files()):
-        template = b'filenodelink' if f in ctx else b'filenolink'
+        if f not in ctx:
+            status = b'removed'
+        elif f in filesadded:
+            status = b'added'
+        else:
+            status = b'modified'
+        template = b'filenolink' if status == b'removed' else b'filenodelink'
         yield context.process(
             template,
             {
@@ -550,6 +557,7 @@  def _listfilesgen(context, ctx, stripeco
                 b'file': f,
                 b'blockno': blockno + 1,
                 b'parity': next(parity),
+                b'status': status,
             },
         )