Patchwork [5,of,6,V3] util.system: remove unused handling of onerr=ui

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 12, 2014, 2:38 p.m.
Message ID <b6944cd4197b1bb1d1fd.1415803084@mimosa>
Download mbox | patch
Permalink /patch/6690/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 12, 2014, 2:38 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1415420059 -32400
#      Sat Nov 08 13:14:19 2014 +0900
# Node ID b6944cd4197b1bb1d1fd9e2d6f94453d297c3f03
# Parent  d0361d0711b30aecfdc14b702411bebc693c170f
util.system: remove unused handling of onerr=ui

In our code, onerr is None or util.Abort.  It smells bad to overload ui and
exception class.
Pierre-Yves David - Nov. 12, 2014, 5:51 p.m.
On 11/12/2014 02:38 PM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1415420059 -32400
> #      Sat Nov 08 13:14:19 2014 +0900
> # Node ID b6944cd4197b1bb1d1fd9e2d6f94453d297c3f03
> # Parent  d0361d0711b30aecfdc14b702411bebc693c170f
> util.system: remove unused handling of onerr=ui

The first 5 are pushed on the clowncopter.

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -619,9 +619,8 @@  def system(cmd, environ={}, cwd=None, on
     '''enhanced shell command execution.
     run with environment maybe modified, maybe in different dir.
 
-    if command fails and onerr is None, return status.  if ui object,
-    print error message and return status, else raise onerr object as
-    exception.
+    if command fails and onerr is None, return status, else raise onerr
+    object as exception.
 
     if out is specified, it is assumed to be a file-like object that has a
     write() method. stdout and stderr will be redirected to out.'''
@@ -670,10 +669,7 @@  def system(cmd, environ={}, cwd=None, on
                             explainexit(rc)[0])
         if errprefix:
             errmsg = '%s: %s' % (errprefix, errmsg)
-        try:
-            onerr.warn(errmsg + '\n')
-        except AttributeError:
-            raise onerr(errmsg)
+        raise onerr(errmsg)
     return rc
 
 def checksignature(func):