Mercurial > python-hglib
changeset 47:94d2988e55b7
client: add revert command
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Thu, 18 Aug 2011 14:29:29 +0300 |
parents | ebcc5d7dd528 |
children | 82d927ac1329 |
files | hglib/client.py |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hglib/client.py Tue Aug 16 23:58:24 2011 +0300 +++ b/hglib/client.py Thu Aug 18 14:29:29 2011 +0300 @@ -595,6 +595,26 @@ out = self.rawcommand(args, eh=eh) return not warnings[0] + def revert(self, files, rev=None, all=False, date=None, nobackup=False, + dryrun=False, include=None, exclude=None): + if not isinstance(files, list): + files = [files] + + 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] + + 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] + def root(self): return self.rawcommand(['root']).rstrip()