Patchwork [1,of,3,py3] error: convert the error into strings to pass into ui.warn()

login
register
mail settings
Submitter Pulkit Goyal
Date March 16, 2017, 7:53 a.m.
Message ID <47dae3bbf85608247432.1489650803@pulkit-goyal>
Download mbox | patch
Permalink /patch/19381/
State Accepted
Headers show

Comments

Pulkit Goyal - March 16, 2017, 7:53 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1489638672 -19800
#      Thu Mar 16 10:01:12 2017 +0530
# Node ID 47dae3bbf8560824743293870aab601da2d1ed6c
# Parent  63aeb39b5802644ae99eaa5cf0666f3bf5cc4e90
error: convert the error into strings to pass into ui.warn()
Yuya Nishihara - March 16, 2017, 2:44 p.m.
On Thu, 16 Mar 2017 13:23:23 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1489638672 -19800
> #      Thu Mar 16 10:01:12 2017 +0530
> # Node ID 47dae3bbf8560824743293870aab601da2d1ed6c
> # Parent  63aeb39b5802644ae99eaa5cf0666f3bf5cc4e90
> error: convert the error into strings to pass into ui.warn()
> 
> diff -r 63aeb39b5802 -r 47dae3bbf856 mercurial/scmutil.py
> --- a/mercurial/scmutil.py	Thu Mar 16 09:13:13 2017 +0530
> +++ b/mercurial/scmutil.py	Thu Mar 16 10:01:12 2017 +0530
> @@ -168,7 +168,8 @@
>          if inst.hint:
>              ui.warn('(%s)\n' % inst.hint)
>      except error.RepoError as inst:
> -        ui.warn(_("abort: %s!\n") % inst)
> +        if inst.args:
> +            ui.warn(_("abort: %s!\n") % ''.join(inst.args))

Maybe we'll need to implement __bytes__() in our exception classes?

Patch

diff -r 63aeb39b5802 -r 47dae3bbf856 mercurial/scmutil.py
--- a/mercurial/scmutil.py	Thu Mar 16 09:13:13 2017 +0530
+++ b/mercurial/scmutil.py	Thu Mar 16 10:01:12 2017 +0530
@@ -168,7 +168,8 @@ 
         if inst.hint:
             ui.warn('(%s)\n' % inst.hint)
     except error.RepoError as inst:
-        ui.warn(_("abort: %s!\n") % inst)
+        if inst.args:
+            ui.warn(_("abort: %s!\n") % ''.join(inst.args))
         if inst.hint:
             ui.warn(_("(%s)\n") % inst.hint)
     except error.ResponseError as inst: