[PATCH 2 of 2 hglib] client: use util.reterrorhandler
Idan Kamara
idankk86 at gmail.com
Thu Aug 18 08:22:44 CDT 2011
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1313673623 -10800
# Node ID bd7dfd94b0d9be7dca312c354b56d2026a5f1e28
# Parent 3d7e0325ba1c9ba57639b92baf36063e9a9e91ae
client: use util.reterrorhandler
diff -r 3d7e0325ba1c -r bd7dfd94b0d9 hglib/client.py
--- a/hglib/client.py Thu Aug 18 16:20:22 2011 +0300
+++ b/hglib/client.py Thu Aug 18 16:20:23 2011 +0300
@@ -155,17 +155,10 @@
args = cmdbuilder('add', *files, n=dryrun, S=subrepos, I=include, X=exclude)
- # we could use Python 3 nonlocal here...
- warnings = [False]
+ eh = util.reterrorhandler(args)
+ self.rawcommand(args, eh=eh)
- def eh(ret, out, err):
- if ret == 1:
- warnings[0] = True
- else:
- raise error.CommandError(args, ret, out, err)
-
- self.rawcommand(args, eh=eh)
- return not warnings[0]
+ return bool(eh)
def addremove(self, files=[], similarity=None, dryrun=False, include=None,
exclude=None):
@@ -175,17 +168,10 @@
args = cmdbuilder('addremove', *files, s=similarity, n=dryrun, I=include,
X=exclude)
- # we could use Python 3 nonlocal here...
- warnings = [False]
+ eh = util.reterrorhandler(args)
+ self.rawcommand(args, eh=eh)
- def eh(ret, out, err):
- if ret == 1:
- warnings[0] = True
- else:
- raise error.CommandError(args, ret, out, err)
-
- self.rawcommand(args, eh=eh)
- return not warnings[0]
+ return bool(eh)
def backout(self, rev, merge=False, parent=None, tool=None, message=None,
logfile=None, date=None, user=None):
@@ -332,17 +318,10 @@
args = cmdbuilder('copy', *source, A=after, f=force, n=dryrun,
I=include, X=exclude)
- # we could use Python 3 nonlocal here...
- warnings = [False]
+ eh = util.reterrorhandler(args)
+ self.rawcommand(args, eh=eh)
- def eh(ret, out, err):
- if ret == 1:
- warnings[0] = True
- else:
- raise error.CommandError(args, ret, out, err)
-
- self.rawcommand(args, eh=eh)
- return not warnings[0]
+ return bool(eh)
def forget(self, files, include=None, exclude=None):
if not isinstance(files, list):
@@ -350,17 +329,10 @@
args = cmdbuilder('forget', *files, I=include, X=exclude)
- # we could use Python 3 nonlocal here...
- warnings = [False]
+ eh = util.reterrorhandler(args)
+ self.rawcommand(args, eh=eh)
- def eh(ret, out, err):
- if ret == 1:
- warnings[0] = True
- else:
- raise error.CommandError(args, ret, out, err)
-
- out = self.rawcommand(args, eh=eh)
- return not warnings[0]
+ return bool(eh)
def diff(self, files=[], revs=[], change=None, text=False,
git=False, nodates=False, showfunction=False, reverse=False,
@@ -492,17 +464,10 @@
args = cmdbuilder('move', *source, A=after, f=force, n=dryrun,
I=include, X=exclude)
- # we could use Python 3 nonlocal here...
- warnings = [False]
+ eh = util.reterrorhandler(args)
+ self.rawcommand(args, eh=eh)
- def eh(ret, out, err):
- if ret == 1:
- warnings[0] = True
- else:
- raise error.CommandError(args, ret, out, err)
-
- self.rawcommand(args, eh=eh)
- return not warnings[0]
+ return bool(eh)
def outgoing(self, revrange=None, path=None, force=False, newest=False,
bookmarks=False, branch=None, limit=None, nomerges=False,
@@ -567,17 +532,10 @@
b=branch, e=ssh, remotecmd=remotecmd, insecure=insecure,
t=tool)
- # we could use Python 3 nonlocal here...
- success = [True]
+ eh = util.reterrorhandler(args)
+ self.rawcommand(args, eh=eh)
- def eh(ret, out, err):
- if ret == 1:
- success[0] = False
- else:
- raise error.CommandError(args, ret, out, err)
-
- self.rawcommand(args, eh=eh)
- return success[0]
+ return bool(eh)
def push(self, dest=None, rev=None, force=False, bookmark=None, branch=None,
newbranch=False, ssh=None, remotecmd=None, insecure=False):
@@ -585,17 +543,10 @@
new_branch=newbranch, e=ssh, remotecmd=remotecmd,
insecure=insecure)
- # we could use Python 3 nonlocal here...
- pushed = [True]
+ eh = util.reterrorhandler(args)
+ self.rawcommand(args, eh=eh)
- def eh(ret, out, err):
- if ret == 1:
- pushed[0] = False
- else:
- raise error.CommandError(args, ret, out, err)
-
- self.rawcommand(args, eh=eh)
- return pushed[0]
+ return bool(eh)
def remove(self, files, after=False, force=False, include=None, exclude=None):
if not isinstance(files, list):
@@ -603,17 +554,10 @@
args = cmdbuilder('remove', *files, A=after, f=force, I=include, X=exclude)
- # we could use Python 3 nonlocal here...
- warnings = [False]
+ eh = util.reterrorhandler(args)
+ self.rawcommand(args, eh=eh)
- def eh(ret, out, err):
- if ret == 1:
- warnings[0] = True
- else:
- raise error.CommandError(args, ret, out, err)
-
- out = self.rawcommand(args, eh=eh)
- return not warnings[0]
+ return bool(eh)
def revert(self, files, rev=None, all=False, date=None, nobackup=False,
dryrun=False, include=None, exclude=None):
@@ -623,17 +567,10 @@
args = cmdbuilder('revert', *files, r=rev, a=all, d=date,
no_backup=nobackup, n=dryrun, I=include, X=exclude)
- # we could use Python 3 nonlocal here...
- warnings = [False]
+ eh = util.reterrorhandler(args)
+ self.rawcommand(args, eh=eh)
- def eh(ret, out, err):
- if ret == 1:
- warnings[0] = True
- else:
- raise error.CommandError(args, ret, out, err)
-
- out = self.rawcommand(args, eh=eh)
- return not warnings[0]
+ return bool(eh)
def root(self):
return self.rawcommand(['root']).rstrip()
More information about the Mercurial-devel
mailing list