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

Boris Feld boris.feld at octobus.net
Thu Sep 27 13:08:38 EDT 2018


# HG changeset patch
# User Boris Feld <boris.feld at 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.

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):


More information about the Mercurial-devel mailing list