##// END OF EJS Templates
webutil: make _siblings into an object with __iter__ and __len__...
av6 -
r27023:0c8ef79b default
parent child Browse files
Show More
@@ -125,20 +125,28 b' class filerevnav(revnav):'
125 def hex(self, rev):
125 def hex(self, rev):
126 return hex(self._changelog.node(self._revlog.linkrev(rev)))
126 return hex(self._changelog.node(self._revlog.linkrev(rev)))
127
127
128 class _siblings(object):
129 def __init__(self, siblings=[], hiderev=None):
130 self.siblings = [s for s in siblings if s.node() != nullid]
131 if len(self.siblings) == 1 and self.siblings[0].rev() == hiderev:
132 self.siblings = []
128
133
129 def _siblings(siblings=[], hiderev=None):
134 def __iter__(self):
130 siblings = [s for s in siblings if s.node() != nullid]
135 for s in self.siblings:
131 if len(siblings) == 1 and siblings[0].rev() == hiderev:
136 d = {
132 return
137 'node': s.hex(),
133 for s in siblings:
138 'rev': s.rev(),
134 d = {'node': s.hex(), 'rev': s.rev()}
139 'user': s.user(),
135 d['user'] = s.user()
140 'date': s.date(),
136 d['date'] = s.date()
141 'description': s.description(),
137 d['description'] = s.description()
142 'branch': s.branch(),
138 d['branch'] = s.branch()
143 }
139 if util.safehasattr(s, 'path'):
144 if util.safehasattr(s, 'path'):
140 d['file'] = s.path()
145 d['file'] = s.path()
141 yield d
146 yield d
147
148 def __len__(self):
149 return len(self.siblings)
142
150
143 def parents(ctx, hide=None):
151 def parents(ctx, hide=None):
144 if isinstance(ctx, context.basefilectx):
152 if isinstance(ctx, context.basefilectx):
@@ -355,7 +363,7 b' def changesetentry(web, req, tmpl, ctx):'
355 rev=ctx.rev(),
363 rev=ctx.rev(),
356 node=ctx.hex(),
364 node=ctx.hex(),
357 symrev=symrevorshortnode(req, ctx),
365 symrev=symrevorshortnode(req, ctx),
358 parent=tuple(parents(ctx)),
366 parent=parents(ctx),
359 child=children(ctx),
367 child=children(ctx),
360 basenode=basectx.hex(),
368 basenode=basectx.hex(),
361 changesettag=showtags,
369 changesettag=showtags,
General Comments 0
You need to be logged in to leave comments. Login now