[PATCH 2 of 2] obsstore: add a __len__ method

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Wed Feb 26 21:28:23 CST 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1393353174 28800
#      Tue Feb 25 10:32:54 2014 -0800
# Node ID 493182544d3d1f5699c5e3e5e74c7e3b3001fc9d
# Parent  2553363489703ae22fbdb3b979be0bd34d9370c5
obsstore: add a __len__ method

We can already use "for mark in store:" it make sense to allow
"len(store)" too.

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -245,10 +245,13 @@ class obsstore(object):
             self._load(_readmarkers(data))
 
     def __iter__(self):
         return iter(self._all)
 
+    def __len__(self):
+        return len(self._all)
+
     def __nonzero__(self):
         return bool(self._all)
 
     def create(self, transaction, prec, succs=(), flag=0, metadata=None):
         """obsolete: add a new obsolete marker


More information about the Mercurial-devel mailing list