Patchwork [7,of,8] hgweb: don't use dict(key=value) to build a mapping dict in filelog

login
register
mail settings
Submitter Yuya Nishihara
Date May 21, 2018, 12:22 p.m.
Message ID <dc1e2222237534cea84c.1526905364@mimosa>
Download mbox | patch
Permalink /patch/31774/
State Accepted
Headers show

Comments

Yuya Nishihara - May 21, 2018, 12:22 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522841823 -32400
#      Wed Apr 04 20:37:03 2018 +0900
# Node ID dc1e2222237534cea84c4d501d8b0ceb0dd2f4e7
# Parent  11795e08de913fd3285f9052599e32d3dcde0c0d
hgweb: don't use dict(key=value) to build a mapping dict in filelog

It wasn't Py3 compatible because mapping keys must be bytes.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1090,13 +1090,15 @@  def filelog(web):
                 diffs = diff(c, linerange=lr)
             # follow renames accross filtered (not in range) revisions
             path = c.path()
-            entries.append(dict(
-                parity=next(parity),
-                filerev=c.rev(),
-                file=path,
-                diff=diffs,
-                linerange=webutil.formatlinerange(*lr),
-                **pycompat.strkwargs(webutil.commonentry(repo, c))))
+            lm = webutil.commonentry(repo, c)
+            lm.update({
+                'parity': next(parity),
+                'filerev': c.rev(),
+                'file': path,
+                'diff': diffs,
+                'linerange': webutil.formatlinerange(*lr),
+            })
+            entries.append(lm)
             if i == revcount:
                 break
         lessvars['linerange'] = webutil.formatlinerange(*lrange)
@@ -1107,13 +1109,15 @@  def filelog(web):
             diffs = None
             if patch:
                 diffs = diff(iterfctx)
-            entries.append(dict(
-                parity=next(parity),
-                filerev=i,
-                file=f,
-                diff=diffs,
-                rename=webutil.renamelink(iterfctx),
-                **pycompat.strkwargs(webutil.commonentry(repo, iterfctx))))
+            lm = webutil.commonentry(repo, iterfctx)
+            lm.update({
+                'parity': next(parity),
+                'filerev': i,
+                'file': f,
+                'diff': diffs,
+                'rename': webutil.renamelink(iterfctx),
+            })
+            entries.append(lm)
         entries.reverse()
         revnav = webutil.filerevnav(web.repo, fctx.path())
         nav = revnav.gen(end - 1, revcount, count)