diff hglib/client.py @ 122:e05b0cf920bb

client: implement the 'in' keyword for a client object Check if a revision number or a changeset hex matches a changeset in the client repository. The internal tries to create a ctx object. Returns False If the ctx creation fails. This patch also adds the corresponding tests.
author Paul Tonelli <paul.tonelli@logilab.fr>
date Wed, 30 Apr 2014 16:44:59 +0200
parents 5d3783aebe5f
children cdde1656346f
line wrap: on
line diff
--- a/hglib/client.py	Sat Feb 01 15:30:18 2014 -0600
+++ b/hglib/client.py	Wed Apr 30 16:44:59 2014 +0200
@@ -1531,3 +1531,14 @@
 
     def __getitem__(self, changeid):
         return context.changectx(self, changeid)
+
+    def __contains__(self, changeid):
+        """
+        check if changeid, which can be either a local revision number or a
+        changeset id, matches a changeset in the client.
+        """
+        try:
+            context.changectx(self, changeid)
+            return True
+        except ValueError:
+            return False