# HG changeset patch # User Idan Kamara # Date 1313272099 -10800 # Node ID 221eeb3693f4910bf047b7cfc0d00bea854934a5 # Parent 46908f4b87d555d587bdbb9188b3bbb3dbda1041 client: add add command diff -r 46908f4b87d5 -r 221eeb3693f4 hglib/client.py --- a/hglib/client.py Thu Aug 11 22:59:05 2011 +0300 +++ b/hglib/client.py Sun Aug 14 00:48:19 2011 +0300 @@ -140,6 +140,31 @@ self.server = None return ret + def add(self, files=[], dryrun=False, subrepos=False, include=None, + exclude=None): + """ + Add the specified files on the next commit. + If no files are given, add all files to the repository. + + Return whether all given files were added. + """ + if not isinstance(files, list): + files = [files] + + args = cmdbuilder('add', *files, n=dryrun, S=subrepos, I=include, X=exclude) + + # we could use Python 3 nonlocal here... + warnings = [False] + + 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] + def backout(self, rev, merge=False, parent=None, tool=None, message=None, logfile=None, date=None, user=None): if message and logfile: