changeset 43755:33cff871d3b9

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.
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Fri, 15 Nov 2019 16:02:01 -0500
parents 5e1b0470cee7
children 6feaee05bac5
files mercurial/hgweb/webutil.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webutil.py	Fri Nov 15 14:50:13 2019 -0800
+++ b/mercurial/hgweb/webutil.py	Fri Nov 15 16:02:01 2019 -0500
@@ -541,8 +541,15 @@
 
 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 @@
                 b'file': f,
                 b'blockno': blockno + 1,
                 b'parity': next(parity),
+                b'status': status,
             },
         )