Patchwork [1,of,5] revset: make __len__ part of the offical API

mail settings
Submitter Pierre-Yves David
Date Oct. 15, 2014, 7:57 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/6283/
State Accepted
Headers show


Pierre-Yves David - Oct. 15, 2014, 7:57 p.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1413372383 25200
#      Wed Oct 15 04:26:23 2014 -0700
# Node ID e642e0ab2f8f535f7afc828e0af8fb50deeee6b6
# Parent  48c0b101a9de1fdbd638daa858da845cd05a6be7
revset: make __len__ part of the offical API

This is common for code to ask for the length of a revset. And in fact, all but
generatorset already implement it.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -2253,10 +2253,16 @@  class abstractsmartset(object):
         """return the last element in the set (user iteration perspective)
         Return None if the set is empty"""
         raise NotImplementedError()
+    def __len__(self):
+        """return the length of the smartsets
+        This can be expensive on smartset that could be lazy otherwise."""
+        raise NotImplementedError()
     def reverse(self):
         """reverse the expected iteration order"""
         raise NotImplementedError()
     def sort(self, reverse=True):