Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/webcommands.py @ 29216:ead25aa27a43
py3: convert to next() function
next(..) was introduced in py2.6 and .next() is not available in py3
https://docs.python.org/2/library/functions.html#next
author | timeless <timeless@mozdev.org> |
---|---|
date | Mon, 16 May 2016 21:30:53 +0000 |
parents | 80e922479891 |
children | 4f2f8baba2ff |
comparison
equal
deleted
inserted
replaced
29215:f5983805574e | 29216:ead25aa27a43 |
---|---|
137 def lines(): | 137 def lines(): |
138 for lineno, t in enumerate(text.splitlines(True)): | 138 for lineno, t in enumerate(text.splitlines(True)): |
139 yield {"line": t, | 139 yield {"line": t, |
140 "lineid": "l%d" % (lineno + 1), | 140 "lineid": "l%d" % (lineno + 1), |
141 "linenumber": "% 6d" % (lineno + 1), | 141 "linenumber": "% 6d" % (lineno + 1), |
142 "parity": parity.next()} | 142 "parity": next(parity)} |
143 | 143 |
144 return tmpl("filerevision", | 144 return tmpl("filerevision", |
145 file=f, | 145 file=f, |
146 path=webutil.up(f), | 146 path=webutil.up(f), |
147 text=lines(), | 147 text=lines(), |
276 n = ctx.node() | 276 n = ctx.node() |
277 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) | 277 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) |
278 files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles) | 278 files = webutil.listfilediffs(tmpl, ctx.files(), n, web.maxfiles) |
279 | 279 |
280 yield tmpl('searchentry', | 280 yield tmpl('searchentry', |
281 parity=parity.next(), | 281 parity=next(parity), |
282 changelogtag=showtags, | 282 changelogtag=showtags, |
283 files=files, | 283 files=files, |
284 **webutil.commonentry(web.repo, ctx)) | 284 **webutil.commonentry(web.repo, ctx)) |
285 | 285 |
286 if count >= revcount: | 286 if count >= revcount: |
373 curcount += 1 | 373 curcount += 1 |
374 if curcount > revcount + 1: | 374 if curcount > revcount + 1: |
375 break | 375 break |
376 | 376 |
377 entry = webutil.changelistentry(web, web.repo[rev], tmpl) | 377 entry = webutil.changelistentry(web, web.repo[rev], tmpl) |
378 entry['parity'] = parity.next() | 378 entry['parity'] = next(parity) |
379 yield entry | 379 yield entry |
380 | 380 |
381 if shortlog: | 381 if shortlog: |
382 revcount = web.maxshortchanges | 382 revcount = web.maxshortchanges |
383 else: | 383 else: |
525 for f in sorted(files): | 525 for f in sorted(files): |
526 full = files[f] | 526 full = files[f] |
527 | 527 |
528 fctx = ctx.filectx(full) | 528 fctx = ctx.filectx(full) |
529 yield {"file": full, | 529 yield {"file": full, |
530 "parity": parity.next(), | 530 "parity": next(parity), |
531 "basename": f, | 531 "basename": f, |
532 "date": fctx.date(), | 532 "date": fctx.date(), |
533 "size": fctx.size(), | 533 "size": fctx.size(), |
534 "permissions": mf.flags(full)} | 534 "permissions": mf.flags(full)} |
535 | 535 |
543 if v: | 543 if v: |
544 emptydirs.append(k) | 544 emptydirs.append(k) |
545 h = v | 545 h = v |
546 | 546 |
547 path = "%s%s" % (abspath, d) | 547 path = "%s%s" % (abspath, d) |
548 yield {"parity": parity.next(), | 548 yield {"parity": next(parity), |
549 "path": path, | 549 "path": path, |
550 "emptydirs": "/".join(emptydirs), | 550 "emptydirs": "/".join(emptydirs), |
551 "basename": d} | 551 "basename": d} |
552 | 552 |
553 return tmpl("manifest", | 553 return tmpl("manifest", |
554 symrev=symrev, | 554 symrev=symrev, |
555 path=abspath, | 555 path=abspath, |
556 up=webutil.up(abspath), | 556 up=webutil.up(abspath), |
557 upparity=parity.next(), | 557 upparity=next(parity), |
558 fentries=filelist, | 558 fentries=filelist, |
559 dentries=dirlist, | 559 dentries=dirlist, |
560 archives=web.archivelist(hex(node)), | 560 archives=web.archivelist(hex(node)), |
561 **webutil.commonentry(web.repo, ctx)) | 561 **webutil.commonentry(web.repo, ctx)) |
562 | 562 |
580 if notip: | 580 if notip: |
581 t = [(k, n) for k, n in i if k != "tip"] | 581 t = [(k, n) for k, n in i if k != "tip"] |
582 if latestonly: | 582 if latestonly: |
583 t = t[:1] | 583 t = t[:1] |
584 for k, n in t: | 584 for k, n in t: |
585 yield {"parity": parity.next(), | 585 yield {"parity": next(parity), |
586 "tag": k, | 586 "tag": k, |
587 "date": web.repo[n].date(), | 587 "date": web.repo[n].date(), |
588 "node": hex(n)} | 588 "node": hex(n)} |
589 | 589 |
590 return tmpl("tags", | 590 return tmpl("tags", |
613 def entries(latestonly, **map): | 613 def entries(latestonly, **map): |
614 t = i | 614 t = i |
615 if latestonly: | 615 if latestonly: |
616 t = i[:1] | 616 t = i[:1] |
617 for k, n in t: | 617 for k, n in t: |
618 yield {"parity": parity.next(), | 618 yield {"parity": next(parity), |
619 "bookmark": k, | 619 "bookmark": k, |
620 "date": web.repo[n].date(), | 620 "date": web.repo[n].date(), |
621 "node": hex(n)} | 621 "node": hex(n)} |
622 | 622 |
623 if i: | 623 if i: |
675 count += 1 | 675 count += 1 |
676 if count > 10: # limit to 10 tags | 676 if count > 10: # limit to 10 tags |
677 break | 677 break |
678 | 678 |
679 yield tmpl("tagentry", | 679 yield tmpl("tagentry", |
680 parity=parity.next(), | 680 parity=next(parity), |
681 tag=k, | 681 tag=k, |
682 node=hex(n), | 682 node=hex(n), |
683 date=web.repo[n].date()) | 683 date=web.repo[n].date()) |
684 | 684 |
685 def bookmarks(**map): | 685 def bookmarks(**map): |
686 parity = paritygen(web.stripecount) | 686 parity = paritygen(web.stripecount) |
687 marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo] | 687 marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo] |
688 sortkey = lambda b: (web.repo[b[1]].rev(), b[0]) | 688 sortkey = lambda b: (web.repo[b[1]].rev(), b[0]) |
689 marks = sorted(marks, key=sortkey, reverse=True) | 689 marks = sorted(marks, key=sortkey, reverse=True) |
690 for k, n in marks[:10]: # limit to 10 bookmarks | 690 for k, n in marks[:10]: # limit to 10 bookmarks |
691 yield {'parity': parity.next(), | 691 yield {'parity': next(parity), |
692 'bookmark': k, | 692 'bookmark': k, |
693 'date': web.repo[n].date(), | 693 'date': web.repo[n].date(), |
694 'node': hex(n)} | 694 'node': hex(n)} |
695 | 695 |
696 def changelist(**map): | 696 def changelist(**map): |
702 for i in revs: | 702 for i in revs: |
703 ctx = web.repo[i] | 703 ctx = web.repo[i] |
704 | 704 |
705 l.append(tmpl( | 705 l.append(tmpl( |
706 'shortlogentry', | 706 'shortlogentry', |
707 parity=parity.next(), | 707 parity=next(parity), |
708 **webutil.commonentry(web.repo, ctx))) | 708 **webutil.commonentry(web.repo, ctx))) |
709 | 709 |
710 l.reverse() | 710 l.reverse() |
711 yield l | 711 yield l |
712 | 712 |
877 fnode = f.filenode() | 877 fnode = f.filenode() |
878 | 878 |
879 if last != fnode: | 879 if last != fnode: |
880 last = fnode | 880 last = fnode |
881 | 881 |
882 yield {"parity": parity.next(), | 882 yield {"parity": next(parity), |
883 "node": f.hex(), | 883 "node": f.hex(), |
884 "rev": f.rev(), | 884 "rev": f.rev(), |
885 "author": f.user(), | 885 "author": f.user(), |
886 "desc": f.description(), | 886 "desc": f.description(), |
887 "extra": f.extra(), | 887 "extra": f.extra(), |
961 revs = fctx.filelog().revs(start, end - 1) | 961 revs = fctx.filelog().revs(start, end - 1) |
962 for i in revs: | 962 for i in revs: |
963 iterfctx = fctx.filectx(i) | 963 iterfctx = fctx.filectx(i) |
964 | 964 |
965 l.append(dict( | 965 l.append(dict( |
966 parity=parity.next(), | 966 parity=next(parity), |
967 filerev=i, | 967 filerev=i, |
968 file=f, | 968 file=f, |
969 rename=webutil.renamelink(iterfctx), | 969 rename=webutil.renamelink(iterfctx), |
970 **webutil.commonentry(repo, iterfctx))) | 970 **webutil.commonentry(repo, iterfctx))) |
971 for e in reversed(l): | 971 for e in reversed(l): |