Patchwork [3,of,3] rcutil: extract duplicated logic to a lambda

login
register
mail settings
Submitter Jun Wu
Date March 28, 2017, 3:02 p.m.
Message ID <01cb4d7bd67aca078f3c.1490713376@localhost.localdomain>
Download mbox | patch
Permalink /patch/19788/
State Accepted
Headers show

Comments

Jun Wu - March 28, 2017, 3:02 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1490713076 25200
#      Tue Mar 28 07:57:56 2017 -0700
# Node ID 01cb4d7bd67aca078f3ca74fdbffd5685a17defe
# Parent  3990935c7f25e9e42309cbad92e888a1201ac751
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 01cb4d7bd67a
rcutil: extract duplicated logic to a lambda

This simplifies the code a bit.

Patch

diff --git a/mercurial/rcutil.py b/mercurial/rcutil.py
--- a/mercurial/rcutil.py
+++ b/mercurial/rcutil.py
@@ -86,8 +86,7 @@  def rccomponents():
             _rccomponents.extend(('path', p) for p in _expandrcpath(p))
     else:
-        paths = defaultrcpath() + systemrcpath()
-        _rccomponents = [('path', os.path.normpath(p)) for p in paths]
+        normpaths = lambda paths: [('path', os.path.normpath(p)) for p in paths]
+        _rccomponents = normpaths(defaultrcpath() + systemrcpath())
         _rccomponents.append(envrc)
-        paths = userrcpath()
-        _rccomponents.extend(('path', os.path.normpath(p)) for p in paths)
+        _rccomponents.extend(normpaths(userrcpath()))
     return _rccomponents