Patchwork [3,of,3] util.system: remove unused handling of onerr=ui

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 8, 2014, 5:42 a.m.
Message ID <0315dcc7fe622f59874e.1415425335@mimosa>
Download mbox | patch
Permalink /patch/6653/
State Superseded
Commit 76302f5ceba4449389af6d64a15181515433e63f
Headers show

Comments

Yuya Nishihara - Nov. 8, 2014, 5:42 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1415420059 -32400
#      Sat Nov 08 13:14:19 2014 +0900
# Node ID 0315dcc7fe622f59874e434fe498ce3a9a85abef
# Parent  670e7adaca7fe1b727268dad6ba3e377a8760ff5
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.

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -613,9 +613,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.'''
@@ -664,10 +663,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):