Patchwork [2,of,2] localrepo: use ProgrammingError

login
register
mail settings
Submitter Jun Wu
Date Dec. 6, 2016, 5:13 p.m.
Message ID <5197933cb8b90a976be3.1481044436@x1c>
Download mbox | patch
Permalink /patch/17841/
State Accepted
Headers show

Comments

Jun Wu - Dec. 6, 2016, 5:13 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1481043999 0
#      Tue Dec 06 17:06:39 2016 +0000
# Node ID 5197933cb8b90a976be3d298b5f51b154fd8e733
# Parent  67bcd43e64ca03f486a817fccf38e83020b06793
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 5197933cb8b9
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.
Kostia Balytskyi - Dec. 6, 2016, 8:02 p.m.
Both patches look good to me.

On 12/6/16 5:13 PM, Jun Wu wrote:
> # HG changeset patch

> # User Jun Wu <quark@fb.com>

> # Date 1481043999 0

> #      Tue Dec 06 17:06:39 2016 +0000

> # Node ID 5197933cb8b90a976be3d298b5f51b154fd8e733

> # Parent  67bcd43e64ca03f486a817fccf38e83020b06793

> # Available At https://bitbucket.org/quark-zju/hg-draft

> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 5197933cb8b9

> 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 --git a/mercurial/localrepo.py b/mercurial/localrepo.py

> --- a/mercurial/localrepo.py

> +++ b/mercurial/localrepo.py

> @@ -1017,6 +1017,5 @@ class localrepository(object):

>                   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:

> diff --git a/tests/test-devel-warnings.t b/tests/test-devel-warnings.t

> --- a/tests/test-devel-warnings.t

> +++ b/tests/test-devel-warnings.t

> @@ -175,5 +175,5 @@ Test programming error failure:

>     ** Extensions loaded: * (glob)

>     Traceback (most recent call last):

> -  RuntimeError: programming error: transaction requires locking

> +  mercurial.error.ProgrammingError: transaction requires locking

>   

>     $ cd ..

> _______________________________________________

> Mercurial-devel mailing list

> Mercurial-devel@mercurial-scm.org

> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Augie Fackler - Dec. 6, 2016, 9:18 p.m.
On Tue, Dec 06, 2016 at 08:02:11PM +0000, Kostia Balytskyi wrote:
> Both patches look good to me.

Agreed. Queued, thanks.

>
> On 12/6/16 5:13 PM, Jun Wu wrote:
> > # HG changeset patch
> > # User Jun Wu <quark@fb.com>
> > # Date 1481043999 0
> > #      Tue Dec 06 17:06:39 2016 +0000
> > # Node ID 5197933cb8b90a976be3d298b5f51b154fd8e733
> > # Parent  67bcd43e64ca03f486a817fccf38e83020b06793
> > # Available At https://bitbucket.org/quark-zju/hg-draft
> > #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 5197933cb8b9
> > 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 --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> > --- a/mercurial/localrepo.py
> > +++ b/mercurial/localrepo.py
> > @@ -1017,6 +1017,5 @@ class localrepository(object):
> >                   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:
> > diff --git a/tests/test-devel-warnings.t b/tests/test-devel-warnings.t
> > --- a/tests/test-devel-warnings.t
> > +++ b/tests/test-devel-warnings.t
> > @@ -175,5 +175,5 @@ Test programming error failure:
> >     ** Extensions loaded: * (glob)
> >     Traceback (most recent call last):
> > -  RuntimeError: programming error: transaction requires locking
> > +  mercurial.error.ProgrammingError: transaction requires locking
> >
> >     $ cd ..
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel@mercurial-scm.org
> > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1017,6 +1017,5 @@  class localrepository(object):
                 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:
diff --git a/tests/test-devel-warnings.t b/tests/test-devel-warnings.t
--- a/tests/test-devel-warnings.t
+++ b/tests/test-devel-warnings.t
@@ -175,5 +175,5 @@  Test programming error failure:
   ** Extensions loaded: * (glob)
   Traceback (most recent call last):
-  RuntimeError: programming error: transaction requires locking
+  mercurial.error.ProgrammingError: transaction requires locking
 
   $ cd ..