Patchwork [1,of,3,V2] error: add a new exception named WdirUnsupported

login
register
mail settings
Submitter Pulkit Goyal
Date May 21, 2017, 4:18 p.m.
Message ID <2adbd2d46cd7588d7520.1495383523@workspace>
Download mbox | patch
Permalink /patch/20796/
State Accepted
Headers show

Comments

Pulkit Goyal - May 21, 2017, 4:18 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1495201237 -19800
#      Fri May 19 19:10:37 2017 +0530
# Node ID 2adbd2d46cd7588d75201108f6e02b92d1480022
# Parent  4a23cdb32968ab4739cad0c32811b24829c38efa
error: add a new exception named WdirUnsupported

This series intents to support wdir() predicate with different operators
like ~, ^.

Currently the storage class don't support wdir(). This exception is introduced
so that it can be raised from places where wdir() is passed and is not
supported and we can catch this where we want to support the predicate.
Also throwing an error at low level and catching at some higher level is better
than using if-else especially for perf.
Yuya Nishihara - May 22, 2017, 2:55 p.m.
On Sun, 21 May 2017 21:48:43 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1495201237 -19800
> #      Fri May 19 19:10:37 2017 +0530
> # Node ID 2adbd2d46cd7588d75201108f6e02b92d1480022
> # Parent  4a23cdb32968ab4739cad0c32811b24829c38efa
> error: add a new exception named WdirUnsupported
> 
> This series intents to support wdir() predicate with different operators
> like ~, ^.
> 
> Currently the storage class don't support wdir(). This exception is introduced
> so that it can be raised from places where wdir() is passed and is not
> supported and we can catch this where we want to support the predicate.
> Also throwing an error at low level and catching at some higher level is better
> than using if-else especially for perf.
> 
> diff --git a/mercurial/error.py b/mercurial/error.py
> --- a/mercurial/error.py
> +++ b/mercurial/error.py
> @@ -177,6 +177,9 @@
>  class ProgrammingError(Hint, RuntimeError):
>      """Raised if a mercurial (core or extension) developer made a mistake"""
>  
> +class WdirUnsupported(Exception):
> +    """An exception which is raised when 'wdir()' is not supported"""

Although this was suggested by me, I'm not pretty sure if this will work well
in most cases. However, the change is pretty small, so seems good in order to
move things forward.

Queued, thanks.

Patch

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -177,6 +177,9 @@ 
 class ProgrammingError(Hint, RuntimeError):
     """Raised if a mercurial (core or extension) developer made a mistake"""
 
+class WdirUnsupported(Exception):
+    """An exception which is raised when 'wdir()' is not supported"""
+
 # bundle2 related errors
 class BundleValueError(ValueError):
     """error raised when bundle2 cannot be processed"""