Patchwork [7,of,8] filemerge: explicitly tests for None

login
register
mail settings
Submitter Pierre-Yves David
Date March 16, 2017, 11:28 a.m.
Message ID <414372f08c44186c8dad.1489663691@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/19390/
State Accepted
Headers show

Comments

Pierre-Yves David - March 16, 2017, 11:28 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1489615912 25200
#      Wed Mar 15 15:11:52 2017 -0700
# Node ID 414372f08c44186c8dad9dea46d617ab61412503
# Parent  28093cead8791382a984b4c80dcedbe529ea7c41
# EXP-Topic mutable-default
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 414372f08c44
filemerge: explicitly tests for None

Changeset 758526333dec removed the mutable default value, but did not explicitly
tested for None. Such implicit testing can introduce semantic and performance
issue. We move to an explicit testing for None as recommended by PEP8:

https://www.python.org/dev/peps/pep-0008/#programming-recommendations

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -36,7 +36,9 @@  def _toolbool(ui, tool, part, default=Fa
     return ui.configbool("merge-tools", tool + "." + part, default)
 
 def _toollist(ui, tool, part, default=None):
-    return ui.configlist("merge-tools", tool + "." + part, default or [])
+    if default is None:
+        default = []
+    return ui.configlist("merge-tools", tool + "." + part, default)
 
 internals = {}
 # Merge tools to document.