changeset 30608:b52e8a4f4c0f

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.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 12 Dec 2016 13:32:45 +0100
parents 07025bd744a0
children 9bf43a72b49d
files mercurial/registrar.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/registrar.py	Sun Oct 16 17:01:41 2016 +0900
+++ b/mercurial/registrar.py	Mon Dec 12 13:32:45 2016 +0100
@@ -8,6 +8,7 @@
 from __future__ import absolute_import
 
 from . import (
+    error,
     pycompat,
     util,
 )
@@ -50,6 +51,10 @@
     def _doregister(self, func, decl, *args, **kwargs):
         name = self._getname(decl)
 
+        if name in self._table:
+            msg = 'duplicate registration for name: "%s"' % name
+            raise error.ProgrammingError(msg)
+
         if func.__doc__ and not util.safehasattr(func, '_origdoc'):
             doc = func.__doc__.strip()
             func._origdoc = doc