[PATCH] client: add revert command

Idan Kamara idankk86 at gmail.com
Thu Aug 18 08:19:41 CDT 2011


# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1313666969 -10800
# Node ID 94d2988e55b755529aa66d48c5853f9b2671a8c4
# Parent  ebcc5d7dd528d570645b7f384fdc05b439d685ea
client: add revert command

diff -r ebcc5d7dd528 -r 94d2988e55b7 hglib/client.py
--- 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()
 


More information about the Mercurial-devel mailing list