# HG changeset patch # User Jun Wu # Date 1481043999 0 # Node ID f8c9a7d2bbbf5e290d7d4e3a3efe70bb90a7bd47 # Parent b0ebab239f906b9648afbdadf8a9251c6da59ee7 localrepo: use ProgrammingError This is an example usage of ProgrammingError. Let's start migrating RuntimeError to ProgrammingError. The code only runs when devel.all-warnings or devel.check-locks is set, so it does not affect the end-user experience. diff -r b0ebab239f90 -r f8c9a7d2bbbf mercurial/localrepo.py --- a/mercurial/localrepo.py Tue Dec 06 14:57:47 2016 +0000 +++ b/mercurial/localrepo.py Tue Dec 06 17:06:39 2016 +0000 @@ -1016,8 +1016,7 @@ if (self.ui.configbool('devel', 'all-warnings') or self.ui.configbool('devel', 'check-locks')): if self._currentlock(self._lockref) is None: - raise RuntimeError('programming error: transaction requires ' - 'locking') + raise error.ProgrammingError('transaction requires locking') tr = self.currenttransaction() if tr is not None: return tr.nest() diff -r b0ebab239f90 -r f8c9a7d2bbbf tests/test-devel-warnings.t --- a/tests/test-devel-warnings.t Tue Dec 06 14:57:47 2016 +0000 +++ b/tests/test-devel-warnings.t Tue Dec 06 17:06:39 2016 +0000 @@ -174,6 +174,6 @@ ** Mercurial Distributed SCM (*) (glob) ** Extensions loaded: * (glob) Traceback (most recent call last): - RuntimeError: programming error: transaction requires locking + mercurial.error.ProgrammingError: transaction requires locking $ cd ..