##// END OF EJS Templates
hgweb: extract a generator function of _siblings class...
Yuya Nishihara -
r37717:0e02eb83 default
parent child Browse files
Show More
@@ -181,16 +181,10 b' class filerevnav(revnav):'
181 181 def hex(self, rev):
182 182 return hex(self._changelog.node(self._revlog.linkrev(rev)))
183 183
184 class _siblings(object):
185 def __init__(self, siblings=None, hiderev=None):
186 if siblings is None:
187 siblings = []
188 self.siblings = [s for s in siblings if s.node() != nullid]
189 if len(self.siblings) == 1 and self.siblings[0].rev() == hiderev:
190 self.siblings = []
191
192 def __iter__(self):
193 for s in self.siblings:
184 # TODO: maybe this can be a wrapper class for changectx/filectx list, which
185 # yields {'ctx': ctx}
186 def _ctxsgen(ctxs):
187 for s in ctxs:
194 188 d = {
195 189 'node': s.hex(),
196 190 'rev': s.rev(),
@@ -203,6 +197,17 b' class _siblings(object):'
203 197 d['file'] = s.path()
204 198 yield d
205 199
200 class _siblings(object):
201 def __init__(self, siblings=None, hiderev=None):
202 if siblings is None:
203 siblings = []
204 self.siblings = [s for s in siblings if s.node() != nullid]
205 if len(self.siblings) == 1 and self.siblings[0].rev() == hiderev:
206 self.siblings = []
207
208 def __iter__(self):
209 return _ctxsgen(self.siblings)
210
206 211 def __len__(self):
207 212 return len(self.siblings)
208 213
General Comments 0
You need to be logged in to leave comments. Login now