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

Siddharth Agarwal sid0 at fb.com
Tue Nov 10 02:48:58 CST 2015


# HG changeset patch
# User Siddharth Agarwal <sid0 at 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)
 


More information about the Mercurial-devel mailing list