mercurial/templatekw.py
changeset 31882 ba5b74f780d5
parent 31881 31dad7a5b4ed
child 31923 68c910fa9ee2
equal deleted inserted replaced
31881:31dad7a5b4ed 31882:ba5b74f780d5
    26     - "{files}" (legacy command-line-specific list hack) and
    26     - "{files}" (legacy command-line-specific list hack) and
    27     - "{files % '{file}\n'}" (hgweb-style with inlining and function support)
    27     - "{files % '{file}\n'}" (hgweb-style with inlining and function support)
    28     and to access raw values:
    28     and to access raw values:
    29     - "{ifcontains(file, files, ...)}", "{ifcontains(key, extras, ...)}"
    29     - "{ifcontains(file, files, ...)}", "{ifcontains(key, extras, ...)}"
    30     - "{get(extras, key)}"
    30     - "{get(extras, key)}"
       
    31     - "{files|json}"
    31     """
    32     """
    32 
    33 
    33     def __init__(self, gen, values, makemap, joinfmt):
    34     def __init__(self, gen, values, makemap, joinfmt):
    34         self.gen = gen
    35         self.gen = gen
    35         self._values = values
    36         self._values = values
    41             yield makemap(x)
    42             yield makemap(x)
    42     def __contains__(self, x):
    43     def __contains__(self, x):
    43         return x in self._values
    44         return x in self._values
    44     def __len__(self):
    45     def __len__(self):
    45         return len(self._values)
    46         return len(self._values)
       
    47     def __iter__(self):
       
    48         return iter(self._values)
    46     def __getattr__(self, name):
    49     def __getattr__(self, name):
    47         if name != 'get':
    50         if name not in ('get', 'items', 'iteritems', 'iterkeys', 'itervalues',
       
    51                         'keys', 'values'):
    48             raise AttributeError(name)
    52             raise AttributeError(name)
    49         return getattr(self._values, name)
    53         return getattr(self._values, name)
    50 
    54 
    51 def unwraphybrid(thing):
    55 def unwraphybrid(thing):
    52     """Return an object which can be stringified possibly by using a legacy
    56     """Return an object which can be stringified possibly by using a legacy