[PATCH 1 of 3] convert: don't use {} as default argument value

Gregory Szorc gregory.szorc at gmail.com
Fri Dec 23 02:28:46 EST 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1482427607 28800
#      Thu Dec 22 09:26:47 2016 -0800
# Node ID f6fbf3b058b9b39615a21ba88f796f312b47346e
# Parent  b2be4ccaff1d89356cbd9637aa9191e8048012b6
convert: don't use {} as default argument value

This is a common Python gotcha. I'm kinda surprised we don't have a
check-code to detect this :/

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -54,18 +54,18 @@ class NoRepo(Exception):
 SKIPREV = 'SKIP'
 
 class commit(object):
     def __init__(self, author, date, desc, parents, branch=None, rev=None,
-                 extra={}, sortkey=None, saverev=True, phase=phases.draft,
+                 extra=None, sortkey=None, saverev=True, phase=phases.draft,
                  optparents=None):
         self.author = author or 'unknown'
         self.date = date or '0 0'
         self.desc = desc
         self.parents = parents # will be converted and used as parents
         self.optparents = optparents or [] # will be used if already converted
         self.branch = branch
         self.rev = rev
-        self.extra = extra
+        self.extra = extra or {}
         self.sortkey = sortkey
         self.saverev = saverev
         self.phase = phase
 


More information about the Mercurial-devel mailing list