Patchwork obsolete: use ProgrammingError over assert for volatile set registration

login
register
mail settings
Submitter Pierre-Yves David
Date June 16, 2017, 11:41 p.m.
Message ID <71bd57c9bcd3982861ef.1497656480@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21438/
State Accepted
Headers show

Comments

Pierre-Yves David - June 16, 2017, 11:41 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1493611056 -7200
#      Mon May 01 05:57:36 2017 +0200
# Node ID 71bd57c9bcd3982861ef502bde397bcdce9b4abb
# Parent  29558247b00eff8c95c7604032b59cfbab34010d
# EXP-Topic programming-error
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 71bd57c9bcd3
obsolete: use ProgrammingError over assert for volatile set registration

We have ProgrammingError now.
Yuya Nishihara - June 17, 2017, 3:10 a.m.
On Sat, 17 Jun 2017 01:41:20 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1493611056 -7200
> #      Mon May 01 05:57:36 2017 +0200
> # Node ID 71bd57c9bcd3982861ef502bde397bcdce9b4abb
> # Parent  29558247b00eff8c95c7604032b59cfbab34010d
> # EXP-Topic programming-error
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 71bd57c9bcd3
> obsolete: use ProgrammingError over assert for volatile set registration

Sure. Queued, thanks.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -1273,7 +1273,9 @@  cachefuncs = {}
 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