def pushlog_html(web): """WebCommand for producing the HTML view of the pushlog.""" req = web.req query = pushlog_setup(web.repo, req) data = { 'changenav': templateutil.mappinggenerator(pushlog_changenav, args=(query, )), 'rev': 0, 'entries': templateutil.mappinggenerator(pushlog_changelist, args=(web, query, False)), 'latestentry': templateutil.mappinggenerator(pushlog_changelist, args=(web, query, True)), 'startdate': req.qsparams.get('startdate', '1 week ago'), 'enddate': req.qsparams.get('enddate', 'now'), 'querydescription': query.description(), 'archives': web.archivelist("tip"), } return web.sendtemplate('pushlog', **data)
def pushlog_feed(web): """WebCommand for producing the ATOM feed of the pushlog.""" req = web.req req.qsparams['style'] = 'atom' # Need to reset the templater instance to use the new style. web.tmpl = web.templater(req) query = pushlog_setup(web.repo, req) if query.entries: dt = isotime(query.entries[0][2]) else: dt = datetime.utcnow().isoformat().split('.', 1)[0] + 'Z' url = req.apppath or '/' if not url.endswith('/'): url += '/' queryentries = ( (pushid, user, date, node) for (pushid, user, date, node) in query.entries if scmutil.isrevsymbol(web.repo, node) ) data = { 'urlbase': query.urlbase, 'url': url, 'repo': query.reponame, 'date': dt, 'entries': templateutil.mappinggenerator(feedentrygenerator, args=(queryentries, web.repo, url, query.urlbase)), } web.res.headers['Content-Type'] = ATOM_MIMETYPE return web.sendtemplate('pushlog', **data)
def firefox_releases_web_command(web): """Show information about Firefox releases.""" req = web.req repo = web.repo db = db_for_repo(repo) if not db: error_message = b'Firefox release info not available' return web.sendtemplate(b'error', error=error_message) platform = req.qsparams[ b'platform'] if b'platform' in req.qsparams else None builds = [] for build in release_builds(db, repo): if platform and build[b'platform'] != platform: continue builds.append(build) releases_mapping_generator = templateutil.mappinggenerator( _releases_mapped_generator, args=(builds, )) return web.sendtemplate(b'firefoxreleases', releases=releases_mapping_generator)
def addmetadata(repo, ctx, d, onlycheap=False): """Add changeset metadata for hgweb templates.""" description = encoding.fromlocal(ctx.description()) def bugsgen(_context): '''Generator for bugs list''' for bug in commitparser.parse_bugs(description): bug = pycompat.bytestr(bug) yield { b'no': bug, b'url': b'https://bugzilla.mozilla.org/show_bug.cgi?id=%s' % bug, } def reviewersgen(_context): '''Generator for reviewers list''' for reviewer in commitparser.parse_reviewers(description): yield { b'name': reviewer, b'revset': b'reviewer(%s)' % reviewer, } def backoutsgen(_context): '''Generator for backouts list''' backouts = commitparser.parse_backouts(description) if backouts: for node in backouts[0]: try: bctx = scmutil.revsymbol(repo, node) yield {b'node': bctx.hex()} except error.RepoLookupError: pass d[b'reviewers'] = templateutil.mappinggenerator(reviewersgen) d[b'bugs'] = templateutil.mappinggenerator(bugsgen) d[b'backsoutnodes'] = templateutil.mappinggenerator(backoutsgen) # Repositories can define which TreeHerder repository they are associated # with. treeherder = repo.ui.config(b'mozilla', b'treeherder_repo') if treeherder: d[b'treeherderrepourl'] = b'https://treeherder.mozilla.org/#/jobs?repo=%s' % treeherder d[b'treeherderrepo'] = treeherder push = repo.pushlog.pushfromchangeset(ctx) # Don't print Perfherder link on non-publishing repos (like Try) # because the previous push likely has nothing to do with this # push. # Changeset on autoland are in the phase 'draft' until they get merged # to mozilla-central. if push and push.nodes and (repo.ui.configbool( b'phases', b'publish', True) or treeherder == b'autoland'): lastpushhead = repo[push.nodes[0]].hex() d[b'perfherderurl'] = ( b'https://treeherder.mozilla.org/perf.html#/compare?' b'originalProject=%s&' b'originalRevision=%s&' b'newProject=%s&' b'newRevision=%s') % (treeherder, push.nodes[-1], treeherder, lastpushhead) # If this changeset was converted from another one and we know which repo # it came from, add that metadata. convertrevision = ctx.extra().get(b'convert_revision') if convertrevision: sourcerepo = repo.ui.config(b'hgmo', b'convertsource') if sourcerepo: d[b'convertsourcepath'] = sourcerepo d[b'convertsourcenode'] = convertrevision # Did the push to this repo included extra data about the automated landing # system used? # We omit the key if it has no value so that the 'json' filter function in # the map file will return null for the key's value. Otherwise the filter # will return a JSON empty string, even for False-y values like None. landingsystem = ctx.extra().get(b'moz-landing-system') if landingsystem: d[b'landingsystem'] = landingsystem if onlycheap: return # Obtain the Gecko/app version/milestone. # # We could probably only do this if the repo is a known app repo (by # looking at the initial changeset). But, path based lookup is relatively # fast, so just do it. However, we need this in the "onlycheap" # section because resolving manifests is relatively slow and resolving # several on changelist pages may add seconds to page load times. try: fctx = repo.filectx(b'config/milestone.txt', changeid=ctx.node()) lines = fctx.data().splitlines() lines = [l for l in lines if not l.startswith(b'#') and l.strip()] if lines: d[b'milestone'] = lines[0].strip() except error.LookupError: pass backout_node = get_backoutbynode(b'hgmo', repo, ctx) if backout_node is not None: d[b'backedoutbynode'] = backout_node
def addmetadata(repo, ctx, d, onlycheap=False): """Add changeset metadata for hgweb templates.""" description = encoding.fromlocal(ctx.description()) def bugsgen(_context): '''Generator for bugs list''' for bug in commitparser.parse_bugs(description): yield { 'no': str(bug), 'url': 'https://bugzilla.mozilla.org/show_bug.cgi?id=%s' % bug, } def reviewersgen(_context): '''Generator for reviewers list''' for reviewer in commitparser.parse_reviewers(description): yield { 'name': reviewer, 'revset': 'reviewer(%s)' % reviewer, } def backoutsgen(_context): '''Generator for backouts list''' backouts = commitparser.parse_backouts(description) if backouts: for node in backouts[0]: try: bctx = scmutil.revsymbol(repo, node) yield {'node': bctx.hex()} except error.RepoLookupError: pass d['reviewers'] = templateutil.mappinggenerator(reviewersgen) d['bugs'] = templateutil.mappinggenerator(bugsgen) d['backsoutnodes'] = templateutil.mappinggenerator(backoutsgen) # Repositories can define which TreeHerder repository they are associated # with. treeherder = repo.ui.config('mozilla', 'treeherder_repo') if treeherder: d['treeherderrepourl'] = 'https://treeherder.mozilla.org/#/jobs?repo=%s' % treeherder d['treeherderrepo'] = treeherder push = repo.pushlog.pushfromchangeset(ctx) # Don't print Perfherder link on non-publishing repos (like Try) # because the previous push likely has nothing to do with this # push. if push and push.nodes and repo.ui.configbool('phases', 'publish', True): lastpushhead = repo[push.nodes[0]].hex() d['perfherderurl'] = ( 'https://treeherder.mozilla.org/perf.html#/compare?' 'originalProject=%s&' 'originalRevision=%s&' 'newProject=%s&' 'newRevision=%s') % (treeherder, push.nodes[-1], treeherder, lastpushhead) # If this changeset was converted from another one and we know which repo # it came from, add that metadata. convertrevision = ctx.extra().get('convert_revision') if convertrevision: sourcerepo = repo.ui.config('hgmo', 'convertsource') if sourcerepo: d['convertsourcepath'] = sourcerepo d['convertsourcenode'] = convertrevision # Did the push to this repo included extra data about the automated landing # system used? # We omit the key if it has no value so that the 'json' filter function in # the map file will return null for the key's value. Otherwise the filter # will return a JSON empty string, even for False-y values like None. landingsystem = ctx.extra().get('moz-landing-system') if landingsystem: d['landingsystem'] = landingsystem if onlycheap: return # Obtain the Gecko/app version/milestone. # # We could probably only do this if the repo is a known app repo (by # looking at the initial changeset). But, path based lookup is relatively # fast, so just do it. However, we need this in the "onlycheap" # section because resolving manifests is relatively slow and resolving # several on changelist pages may add seconds to page load times. try: fctx = repo.filectx('config/milestone.txt', changeid=ctx.node()) lines = fctx.data().splitlines() lines = [l for l in lines if not l.startswith('#') and l.strip()] if lines: d['milestone'] = lines[0].strip() except error.LookupError: pass # Look for changesets that back out this one. # # We limit the distance we search for backouts because an exhaustive # search could be very intensive. e.g. you load up the root commit # on a repository with 200,000 changesets and that commit is never # backed out. This finds most backouts because backouts typically happen # shortly after a bad commit is introduced. thisshort = short(ctx.node()) count = 0 searchlimit = repo.ui.configint('hgmo', 'backoutsearchlimit', 100) for bctx in repo.set('%ld::', [ctx.rev()]): count += 1 if count >= searchlimit: break backouts = commitparser.parse_backouts( encoding.fromlocal(bctx.description())) if backouts and thisshort in backouts[0]: d['backedoutbynode'] = bctx.hex() break