diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
index 0a41902879d3235d3e2124618e486a697d5b6a3e_bWVyY3VyaWFsL29ic29sZXRlLnB5..9d472b219fb07e011c7a6255c5be47e6fc66229c_bWVyY3VyaWFsL29ic29sZXRlLnB5 100644
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -1273,7 +1273,9 @@
 def cachefor(name):
     """Decorator to register a function as computing the cache for a set"""
     def decorator(func):
-        assert name not in cachefuncs
+        if name in cachefuncs:
+            msg = "duplicated registration for volatileset '%s' (existing: %r)"
+            raise error.ProgrammingError(msg % (name, cachefuncs[name]))
         cachefuncs[name] = func
         return func
     return decorator