Patchwork [1,of,5] error: allow a 'hint' to OutOfBandError

login
register
mail settings
Submitter Pierre-Yves David
Date May 20, 2015, 11:53 p.m.
Message ID <480ce3cb4b817dddf155.1432166000@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9206/
State Accepted
Headers show

Comments

Pierre-Yves David - May 20, 2015, 11:53 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1432163860 18000
#      Wed May 20 18:17:40 2015 -0500
# Node ID 480ce3cb4b817dddf155c71cfd95dcb4e57baca1
# Parent  451df92cec4912aefac57a4cf82e9268192c867b
error: allow a 'hint' to OutOfBandError

This will be useful when changing the behavior of OutOfBandError for ssh in the
next changeset.

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -191,12 +191,19 @@  def _runcatch(req):
             commands.help_(ui, inst.args[0], full=False, command=True)
         else:
             ui.warn(_("hg: %s\n") % inst.args[1])
             commands.help_(ui, 'shortlist')
     except error.OutOfBandError, inst:
-        ui.warn(_("abort: remote error:\n"))
-        ui.warn(''.join(inst.args))
+        if inst.args:
+            msg = _("abort: remote error:\n")
+        else:
+            msg = _("abort: remote error\n")
+        ui.warn(msg)
+        if inst.args:
+            ui.warn(''.join(inst.args))
+        if inst.hint:
+            ui.warn('(%s)\n' % inst.hint)
     except error.RepoError, inst:
         ui.warn(_("abort: %s!\n") % inst)
         if inst.hint:
             ui.warn(_("(%s)\n") % inst.hint)
     except error.ResponseError, inst:
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -62,10 +62,14 @@  class ConfigError(Abort):
     """Exception raised when parsing config files"""
 
 class OutOfBandError(Exception):
     """Exception raised when a remote repo reports failure"""
 
+    def __init__(self, *args, **kw):
+        Exception.__init__(self, *args)
+        self.hint = kw.get('hint')
+
 class ParseError(Exception):
     """Raised when parsing config files and {rev,file}sets (msg[, pos])"""
 
 class UnknownIdentifier(ParseError):
     """Exception raised when a {rev,file}set references an unknown identifier"""