Patchwork [2,of,2] error: add structured exception for EOF at prompt

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 10, 2015, 8:48 a.m.
Message ID <451c59f03bec5133d936.1447145338@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11345/
State Accepted
Commit 5e46123e6c352a01e7adf1785baeb9849e9a2534
Headers show

Comments

Siddharth Agarwal - Nov. 10, 2015, 8:48 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1447145205 28800
#      Tue Nov 10 00:46:45 2015 -0800
# Node ID 451c59f03bec5133d93604df82697fdac6755286
# Parent  5a25f53a58a973404e4de43e0221d076f8c07e27
error: add structured exception for EOF at prompt

We'll catch this exception for promptchoice queries to provide better error
handling.
Martin von Zweigbergk - Nov. 10, 2015, 6:02 p.m.
The natural thing to do if one found the code in the state after these two
patches would be to undo the changes, so I'm reluctant to accept the
patches without seeing where this is going. Could you push the entire
series to some public place?

On Tue, Nov 10, 2015 at 12:50 AM Siddharth Agarwal <sid0@fb.com> wrote:

> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1447145205 28800
> #      Tue Nov 10 00:46:45 2015 -0800
> # Node ID 451c59f03bec5133d93604df82697fdac6755286
> # Parent  5a25f53a58a973404e4de43e0221d076f8c07e27
> error: add structured exception for EOF at prompt
>
> We'll catch this exception for promptchoice queries to provide better error
> handling.
>
> diff --git a/mercurial/error.py b/mercurial/error.py
> --- a/mercurial/error.py
> +++ b/mercurial/error.py
> @@ -72,6 +72,12 @@ class ConfigError(Abort):
>  class UpdateAbort(Abort):
>      """Raised when an update is aborted for destination issue"""
>
> +class ResponseExpected(Abort):
> +    """Raised when an EOF is received for a prompt"""
> +    def __init__(self):
> +        from .i18n import _
> +        Abort.__init__(self, _('response expected'))
> +
>  class OutOfBandError(Exception):
>      """Exception raised when a remote repo reports failure"""
>
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -756,7 +756,7 @@ class ui(object):
>                  self.write(r, "\n")
>              return r
>          except EOFError:
> -            raise error.Abort(_('response expected'))
> +            raise error.ResponseExpected()
>
>      @staticmethod
>      def extractchoices(prompt):
> @@ -803,7 +803,7 @@ class ui(object):
>              else:
>                  return getpass.getpass('')
>          except EOFError:
> -            raise error.Abort(_('response expected'))
> +            raise error.ResponseExpected()
>      def status(self, *msg, **opts):
>          '''write status message to output (if ui.quiet is False)
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>
Martin von Zweigbergk - Nov. 10, 2015, 11:26 p.m.
I talked more to Sid about this and even though I don't understand the
patches, I'll push them so he can make progress. Tests are running now, so
will push within ~10 minutes.

On Tue, Nov 10, 2015 at 10:02 AM Martin von Zweigbergk <
martinvonz@google.com> wrote:

> The natural thing to do if one found the code in the state after these two
> patches would be to undo the changes, so I'm reluctant to accept the
> patches without seeing where this is going. Could you push the entire
> series to some public place?
>
> On Tue, Nov 10, 2015 at 12:50 AM Siddharth Agarwal <sid0@fb.com> wrote:
>
>> # HG changeset patch
>> # User Siddharth Agarwal <sid0@fb.com>
>> # Date 1447145205 28800
>> #      Tue Nov 10 00:46:45 2015 -0800
>> # Node ID 451c59f03bec5133d93604df82697fdac6755286
>> # Parent  5a25f53a58a973404e4de43e0221d076f8c07e27
>> error: add structured exception for EOF at prompt
>>
>> We'll catch this exception for promptchoice queries to provide better
>> error
>> handling.
>>
>> diff --git a/mercurial/error.py b/mercurial/error.py
>> --- a/mercurial/error.py
>> +++ b/mercurial/error.py
>> @@ -72,6 +72,12 @@ class ConfigError(Abort):
>>  class UpdateAbort(Abort):
>>      """Raised when an update is aborted for destination issue"""
>>
>> +class ResponseExpected(Abort):
>> +    """Raised when an EOF is received for a prompt"""
>> +    def __init__(self):
>> +        from .i18n import _
>> +        Abort.__init__(self, _('response expected'))
>> +
>>  class OutOfBandError(Exception):
>>      """Exception raised when a remote repo reports failure"""
>>
>> diff --git a/mercurial/ui.py b/mercurial/ui.py
>> --- a/mercurial/ui.py
>> +++ b/mercurial/ui.py
>> @@ -756,7 +756,7 @@ class ui(object):
>>                  self.write(r, "\n")
>>              return r
>>          except EOFError:
>> -            raise error.Abort(_('response expected'))
>> +            raise error.ResponseExpected()
>>
>>      @staticmethod
>>      def extractchoices(prompt):
>> @@ -803,7 +803,7 @@ class ui(object):
>>              else:
>>                  return getpass.getpass('')
>>          except EOFError:
>> -            raise error.Abort(_('response expected'))
>> +            raise error.ResponseExpected()
>>      def status(self, *msg, **opts):
>>          '''write status message to output (if ui.quiet is False)
>>
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@selenic.com
>> https://selenic.com/mailman/listinfo/mercurial-devel
>>
>

Patch

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -72,6 +72,12 @@  class ConfigError(Abort):
 class UpdateAbort(Abort):
     """Raised when an update is aborted for destination issue"""
 
+class ResponseExpected(Abort):
+    """Raised when an EOF is received for a prompt"""
+    def __init__(self):
+        from .i18n import _
+        Abort.__init__(self, _('response expected'))
+
 class OutOfBandError(Exception):
     """Exception raised when a remote repo reports failure"""
 
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -756,7 +756,7 @@  class ui(object):
                 self.write(r, "\n")
             return r
         except EOFError:
-            raise error.Abort(_('response expected'))
+            raise error.ResponseExpected()
 
     @staticmethod
     def extractchoices(prompt):
@@ -803,7 +803,7 @@  class ui(object):
             else:
                 return getpass.getpass('')
         except EOFError:
-            raise error.Abort(_('response expected'))
+            raise error.ResponseExpected()
     def status(self, *msg, **opts):
         '''write status message to output (if ui.quiet is False)