comparison mercurial/templatekw.py @ 22393:293930a1fa0a

templater: implement __len__ for _hybrid Objects of class _hybrid are returned by such template keywords as children, bookmarks, tags and others, and also by revset() template function. They are representing "list of strings" (as hg help template says) for use in templates. So it would be logical to implement a handy way to count the number of strings in such list, and that's what __len__ method does.
author Anton Shestakov <engored@ya.ru>
date Mon, 08 Sep 2014 20:12:58 +0900
parents 764adc332f6e
children 40fcf6c05217
comparison
equal deleted inserted replaced
22392:2dd1cbee569d 22393:293930a1fa0a
24 def __iter__(self): 24 def __iter__(self):
25 return self.gen 25 return self.gen
26 def __call__(self): 26 def __call__(self):
27 for x in self.values: 27 for x in self.values:
28 yield x 28 yield x
29 def __len__(self):
30 return len(self.values)
29 31
30 def showlist(name, values, plural=None, element=None, **args): 32 def showlist(name, values, plural=None, element=None, **args):
31 if not element: 33 if not element:
32 element = name 34 element = name
33 f = _showlist(name, values, plural, **args) 35 f = _showlist(name, values, plural, **args)