Patchwork [06,of,13] rebase: expand a long "one-liner"

login
register
mail settings
Submitter Boris Feld
Date Sept. 27, 2018, 5:08 p.m.
Message ID <77b0a61c3cc5be70c368.1538068118@localhost.localdomain>
Download mbox | patch
Permalink /patch/35144/
State Accepted
Headers show

Comments

Boris Feld - Sept. 27, 2018, 5:08 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1538000121 -7200
#      Thu Sep 27 00:15:21 2018 +0200
# Node ID 77b0a61c3cc5be70c3686f9b7217e59fbf98f5c7
# Parent  4c65b3d61c4505f4d719d657a087b3a254ddb5c5
# EXP-Topic trackfold
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 77b0a61c3cc5
rebase: expand a long "one-liner"

When a one-liner gets 3 lines longs, it lose its expressivity benefits. We
expand it into a simple for loop. This makes future changes of the code in
that area clearer.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1783,9 +1783,10 @@  def clearrebased(ui, repo, destmap, stat
         hf = fm.hexfunc
         fl = fm.formatlist
         fd = fm.formatdict
-        nodechanges = fd({hf(oldn): fl([hf(n) for n in newn], name='node')
-                          for oldn, newn in replacements.iteritems()},
-                         key="oldnode", value="newnodes")
+        changes = {}
+        for oldn, newn in replacements.iteritems():
+            changes[hf(oldn)] = fl([hf(n) for n in newn], name='node')
+        nodechanges = fd(changes, key="oldnode", value="newnodes")
         fm.data(nodechanges=nodechanges)
 
 def pullrebase(orig, ui, repo, *args, **opts):