[PATCH] _addset: add a __len__ method
pierre-yves.david at ens-lyon.org
pierre-yves.david at ens-lyon.org
Fri Mar 21 13:34:06 CDT 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1395366928 25200
# Thu Mar 20 18:55:28 2014 -0700
# Node ID a9cd7e13fd9d5e1a9d5b03f39788a701551a2b29
# Parent 6ca61d24858992759652e869e1b7437402f6f512
_addset: add a __len__ method
Back in the time where repo.revs(...) returned a list, calling `len(...)` on the
result was quite common. We reinstall this on _addset.
There is absolutely no easy way to test this from the command line. The commands
using this in the evolve extension will eventually land into core.
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2464,10 +2464,13 @@ class _addset(_orderedsetmixin):
self._r2 = revs2
self._iter = None
self._ascending = ascending
self._genlist = None
+ def __len__(self):
+ return len(self._list)
+
@util.propertycache
def _list(self):
if not self._genlist:
self._genlist = baseset(self._iterator())
return self._genlist
More information about the Mercurial-devel
mailing list