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

Jun Wu quark at fb.com
Tue Mar 28 11:02:56 EDT 2017


# HG changeset patch
# User Jun Wu <quark at 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.

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


More information about the Mercurial-devel mailing list