mercurial/hgweb/webutil.py
changeset 31660 c2dbd818e884
parent 31476 413b44003462
child 31665 5e6d44511317
equal deleted inserted replaced
31659:0eec36112e58 31660:c2dbd818e884
   386 
   386 
   387     style = web.config('web', 'style', 'paper')
   387     style = web.config('web', 'style', 'paper')
   388     if 'style' in req.form:
   388     if 'style' in req.form:
   389         style = req.form['style'][0]
   389         style = req.form['style'][0]
   390 
   390 
   391     parity = paritygen(web.stripecount)
   391     diff = diffs(web, tmpl, ctx, basectx, None, style)
   392     diff = diffs(web.repo, tmpl, ctx, basectx, None, parity, style)
       
   393 
   392 
   394     parity = paritygen(web.stripecount)
   393     parity = paritygen(web.stripecount)
   395     diffstatsgen = diffstatgen(ctx, basectx)
   394     diffstatsgen = diffstatgen(ctx, basectx)
   396     diffstats = diffstat(tmpl, ctx, diffstatsgen, parity)
   395     diffstats = diffstat(tmpl, ctx, diffstatsgen, parity)
   397 
   396 
   412     for f in files[:max]:
   411     for f in files[:max]:
   413         yield tmpl('filedifflink', node=hex(node), file=f)
   412         yield tmpl('filedifflink', node=hex(node), file=f)
   414     if len(files) > max:
   413     if len(files) > max:
   415         yield tmpl('fileellipses')
   414         yield tmpl('fileellipses')
   416 
   415 
   417 def diffs(repo, tmpl, ctx, basectx, files, parity, style):
   416 def diffs(web, tmpl, ctx, basectx, files, style):
   418 
   417 
   419     def prettyprintlines(lines, blockno):
   418     def prettyprintlines(lines, blockno):
   420         for lineno, l in enumerate(lines, 1):
   419         for lineno, l in enumerate(lines, 1):
   421             difflineno = "%d.%d" % (blockno, lineno)
   420             difflineno = "%d.%d" % (blockno, lineno)
   422             if l.startswith('+'):
   421             if l.startswith('+'):
   431                        line=l,
   430                        line=l,
   432                        lineno=lineno,
   431                        lineno=lineno,
   433                        lineid="l%s" % difflineno,
   432                        lineid="l%s" % difflineno,
   434                        linenumber="% 8s" % difflineno)
   433                        linenumber="% 8s" % difflineno)
   435 
   434 
       
   435     repo = web.repo
   436     if files:
   436     if files:
   437         m = match.exact(repo.root, repo.getcwd(), files)
   437         m = match.exact(repo.root, repo.getcwd(), files)
   438     else:
   438     else:
   439         m = match.always(repo.root, repo.getcwd())
   439         m = match.always(repo.root, repo.getcwd())
   440 
   440 
   441     diffopts = patch.diffopts(repo.ui, untrusted=True)
   441     diffopts = patch.diffopts(repo.ui, untrusted=True)
   442     node1 = basectx.node()
   442     node1 = basectx.node()
   443     node2 = ctx.node()
   443     node2 = ctx.node()
       
   444     parity = paritygen(web.stripecount)
   444 
   445 
   445     diffhunks = patch.diffhunks(repo, node1, node2, m, opts=diffopts)
   446     diffhunks = patch.diffhunks(repo, node1, node2, m, opts=diffopts)
   446     for blockno, (header, hunks) in enumerate(diffhunks, 1):
   447     for blockno, (header, hunks) in enumerate(diffhunks, 1):
   447         if style != 'raw':
   448         if style != 'raw':
   448             header = header[1:]
   449             header = header[1:]