[PATCH] registrar: raise a programming error on duplicated registering

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Dec 16 14:31:29 EST 2016


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1481545965 -3600
#      Mon Dec 12 13:32:45 2016 +0100
# Node ID f3479f74af0d2b21c89e906c503f4cddf4b3c39b
# Parent  182cacaa4c32330c0466b7111a75d060830783e8
registrar: raise a programming error on duplicated registering

Previous, registering different object with the same name would silently
overwrite the first value with the second one. We now detect the situation and
raise an error. No extension in test or core had the issues.

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -8,6 +8,7 @@
 from __future__ import absolute_import
 
 from . import (
+    error,
     pycompat,
     util,
 )
@@ -55,6 +56,9 @@ class _funcregistrarbase(object):
             func._origdoc = doc
             func.__doc__ = self._formatdoc(decl, doc)
 
+        if name in self._table:
+            raise error.ProgrammingError('duplicate registration for name %s',
+                                         name)
         self._table[name] = func
         self._extrasetup(name, func, *args, **kwargs)
 


More information about the Mercurial-devel mailing list