##// END OF EJS Templates
hgweb: simplify parents/children generation code
Dirkjan Ochtman -
r7671:06cf09c8 default
parent child Browse files
Show More
@@ -81,8 +81,8 b' def _filerevision(web, tmpl, fctx):'
81 date=fctx.date(),
81 date=fctx.date(),
82 desc=fctx.description(),
82 desc=fctx.description(),
83 branch=webutil.nodebranchnodefault(fctx),
83 branch=webutil.nodebranchnodefault(fctx),
84 parent=webutil.siblings(fctx.parents()),
84 parent=webutil.parents(fctx),
85 child=webutil.siblings(fctx.children()),
85 child=webutil.children(fctx),
86 rename=webutil.renamelink(fctx),
86 rename=webutil.renamelink(fctx),
87 permissions=fctx.manifest().flags(f))
87 permissions=fctx.manifest().flags(f))
88
88
@@ -134,8 +134,8 b' def _search(web, tmpl, query):'
134 yield tmpl('searchentry',
134 yield tmpl('searchentry',
135 parity=parity.next(),
135 parity=parity.next(),
136 author=ctx.user(),
136 author=ctx.user(),
137 parent=webutil.siblings(ctx.parents()),
137 parent=webutil.parents(ctx),
138 child=webutil.siblings(ctx.children()),
138 child=webutil.children(ctx),
139 changelogtag=showtags,
139 changelogtag=showtags,
140 desc=ctx.description(),
140 desc=ctx.description(),
141 date=ctx.date(),
141 date=ctx.date(),
@@ -182,8 +182,8 b' def changelog(web, req, tmpl, shortlog ='
182
182
183 l.insert(0, {"parity": parity.next(),
183 l.insert(0, {"parity": parity.next(),
184 "author": ctx.user(),
184 "author": ctx.user(),
185 "parent": webutil.siblings(ctx.parents(), i - 1),
185 "parent": webutil.parents(ctx, i - 1),
186 "child": webutil.siblings(ctx.children(), i + 1),
186 "child": webutil.children(ctx, i + 1),
187 "changelogtag": showtags,
187 "changelogtag": showtags,
188 "desc": ctx.description(),
188 "desc": ctx.description(),
189 "date": ctx.date(),
189 "date": ctx.date(),
@@ -227,7 +227,6 b' def changeset(web, req, tmpl):'
227 ctx = webutil.changectx(web.repo, req)
227 ctx = webutil.changectx(web.repo, req)
228 showtags = webutil.showtag(web.repo, tmpl, 'changesettag', ctx.node())
228 showtags = webutil.showtag(web.repo, tmpl, 'changesettag', ctx.node())
229 showbranch = webutil.nodebranchnodefault(ctx)
229 showbranch = webutil.nodebranchnodefault(ctx)
230 parents = ctx.parents()
231
230
232 files = []
231 files = []
233 parity = paritygen(web.stripecount)
232 parity = paritygen(web.stripecount)
@@ -243,8 +242,8 b' def changeset(web, req, tmpl):'
243 diff=diffs,
242 diff=diffs,
244 rev=ctx.rev(),
243 rev=ctx.rev(),
245 node=ctx.hex(),
244 node=ctx.hex(),
246 parent=webutil.siblings(parents),
245 parent=webutil.parents(ctx),
247 child=webutil.siblings(ctx.children()),
246 child=webutil.children(ctx),
248 changesettag=showtags,
247 changesettag=showtags,
249 changesetbranch=showbranch,
248 changesetbranch=showbranch,
250 author=ctx.user(),
249 author=ctx.user(),
@@ -442,12 +441,9 b' def filediff(web, req, tmpl):'
442 if fctx is not None:
441 if fctx is not None:
443 n = fctx.node()
442 n = fctx.node()
444 path = fctx.path()
443 path = fctx.path()
445 parents = fctx.parents()
446 p1 = parents and parents[0].node() or nullid
447 else:
444 else:
448 n = ctx.node()
445 n = ctx.node()
449 # path already defined in except clause
446 # path already defined in except clause
450 parents = ctx.parents()
451
447
452 parity = paritygen(web.stripecount)
448 parity = paritygen(web.stripecount)
453 diffs = webutil.diffs(web.repo, tmpl, fctx or ctx, [path], parity)
449 diffs = webutil.diffs(web.repo, tmpl, fctx or ctx, [path], parity)
@@ -462,8 +458,8 b' def filediff(web, req, tmpl):'
462 author=ctx.user(),
458 author=ctx.user(),
463 rename=rename,
459 rename=rename,
464 branch=webutil.nodebranchnodefault(ctx),
460 branch=webutil.nodebranchnodefault(ctx),
465 parent=webutil.siblings(parents),
461 parent=webutil.parents(ctx),
466 child=webutil.siblings(ctx.children()),
462 child=webutil.children(ctx),
467 diff=diffs)
463 diff=diffs)
468
464
469 diff = filediff
465 diff = filediff
@@ -510,8 +506,8 b' def annotate(web, req, tmpl):'
510 desc=fctx.description(),
506 desc=fctx.description(),
511 rename=webutil.renamelink(fctx),
507 rename=webutil.renamelink(fctx),
512 branch=webutil.nodebranchnodefault(fctx),
508 branch=webutil.nodebranchnodefault(fctx),
513 parent=webutil.siblings(fctx.parents()),
509 parent=webutil.parents(fctx),
514 child=webutil.siblings(fctx.children()),
510 child=webutil.children(fctx),
515 permissions=fctx.manifest().flags(f))
511 permissions=fctx.manifest().flags(f))
516
512
517 def filelog(web, req, tmpl):
513 def filelog(web, req, tmpl):
@@ -555,8 +551,8 b' def filelog(web, req, tmpl):'
555 "author": iterfctx.user(),
551 "author": iterfctx.user(),
556 "date": iterfctx.date(),
552 "date": iterfctx.date(),
557 "rename": webutil.renamelink(iterfctx),
553 "rename": webutil.renamelink(iterfctx),
558 "parent": webutil.siblings(iterfctx.parents()),
554 "parent": webutil.parents(iterfctx),
559 "child": webutil.siblings(iterfctx.children()),
555 "child": webutil.children(iterfctx),
560 "desc": iterfctx.description(),
556 "desc": iterfctx.description(),
561 "tags": webutil.nodetagsdict(repo, iterfctx.node()),
557 "tags": webutil.nodetagsdict(repo, iterfctx.node()),
562 "branch": webutil.nodebranchnodefault(iterfctx),
558 "branch": webutil.nodebranchnodefault(iterfctx),
@@ -58,7 +58,7 b' def revnavgen(pos, pagelen, limit, nodef'
58
58
59 return nav
59 return nav
60
60
61 def siblings(siblings=[], hiderev=None, **args):
61 def _siblings(siblings=[], hiderev=None):
62 siblings = [s for s in siblings if s.node() != nullid]
62 siblings = [s for s in siblings if s.node() != nullid]
63 if len(siblings) == 1 and siblings[0].rev() == hiderev:
63 if len(siblings) == 1 and siblings[0].rev() == hiderev:
64 return
64 return
@@ -69,9 +69,14 b' def siblings(siblings=[], hiderev=None, '
69 d['description'] = s.description()
69 d['description'] = s.description()
70 if hasattr(s, 'path'):
70 if hasattr(s, 'path'):
71 d['file'] = s.path()
71 d['file'] = s.path()
72 d.update(args)
73 yield d
72 yield d
74
73
74 def parents(ctx, hide=None):
75 return _siblings(ctx.parents(), hide)
76
77 def children(ctx, hide=None):
78 return _siblings(ctx.children(), hide)
79
75 def renamelink(fctx):
80 def renamelink(fctx):
76 r = fctx.renamed()
81 r = fctx.renamed()
77 if r:
82 if r:
General Comments 0
You need to be logged in to leave comments. Login now