Пример #1
0
def review_new():
    if (current_user.name == "") or (current_user.name == "None") or (current_user.name is None):
        flash("No username specified. To start a review username is required.", "error")
        return redirect(url_for('user_preferences'))
        
    logger.info("Requested URL /review [POST]")
    refresh_heads()
    revision = repo.revision(request.form['node'])
    rev_status = get_revision_status(repo, revision)
    if rev_status != "new":
        flash("Revision {0} is {1} and cannot be inspected. Refresh list of revisions.".format(revision.node, rev_status), "error")
        logger.info("Revision {0} is {1} and cannot be inspected.".format(revision.node, rev_status))
        return redirect(url_for('changes_new'))
    #TODO: Multiple bookmarks
    review = Review(owner=current_user.name, owner_email=current_user.email, title=revision.title,
                    bookmark=el(revision.bookmarks), status="ACTIVE")
    targets = repo.hg_targets(revision.rev, app.config['PRODUCT_BRANCHES'])
    review.add_targets(targets)
    #TODO: Multiple bookmarks
    changeset = Changeset(revision.name, revision.email, revision.title,
                          revision.node, el(revision.bookmarks),
                          "ACTIVE")
    review.changesets.append(changeset)
    db.session.add(review)
    Head.query.filter(Head.node == revision.node).delete()
    db.session.commit()
    return redirect(url_for('changeset_info', cs_id=changeset.id))
Пример #2
0
def review_rework(review_id):
    logger.info("Requested URL /review/%d [POST]", review_id)
    review = Review.query.filter(Review.id == review_id).first()
    if review is None:
        flash("Review {0} doesn't exist".format(review_id), "error")
        logger.error("Review %d doesn't exist", review_id)
        return redirect(url_for("index"))
    refresh_heads()
    revision = repo.revision(request.form["node"])
    rev_status = get_revision_status(repo, revision)
    if rev_status != "rework":
        flash("Revision {0} is {1} and cannot be inspected. Refresh list of revisions.".format(revision.node, rev_status), "error")
        logger.info("Revision {0} is {1} and cannot be inspected.".format(revision.node, rev_status))
        return redirect(url_for('review_info', review_id=review.id))
    #TODO: Multiple bookmarks
    changeset = Changeset(revision.name, revision.email, revision.title,
                          revision.node, el(revision.bookmarks), "ACTIVE")
    review.status = "ACTIVE"
    changeset.review_id = review.id
    db.session.add(changeset)
    Head.query.filter(Head.node == revision.node).delete()
    Head.query.filter(Head.review_id == review.id).update({'review_id': None})
    db.session.commit()
    flash("Changeset '{title}' (SHA1: {sha1}) has been marked as rework".format(title=changeset.title, sha1=changeset.sha1),
          "notice")
    return redirect(url_for('changeset_info', cs_id=changeset.id))
Пример #3
0
def changelog(start, stop):
    repo.hg_sync()
    rev_start = repo.revision(start)
    rev_stop = repo.revision(stop)

    rev_list = {}
    for rev in repo.revisions([1, rev_stop.node]):
        rev_list[rev.node] = rev
    for rev in repo.revisions([1, rev_start.node]):
        rev_list.pop(rev.node, None)

    jira_re = re.compile("(IWD-\d{3,5})|(EVO-\d+)|(IAP-\d+)", re.IGNORECASE)
    jira_list = {}
    for node, rev in rev_list.items():
        tickets = set(chain(*jira_re.findall(rev.desc))) - set([''])
        for ticket in tickets:
            key = ticket.upper()
            if key not in jira_list:
                jira_list[key] = ''
            jira_list[key] += '\n' + rev.desc

    return render_template("log.html", start=start, stop=stop, jira_list=sorted(jira_list.items()))
Пример #4
0
def revision_abandon(node):
    logger.info("Requested URL /revision/%s/abandon [POST]", node)
    refresh_heads()
    revision = repo.revision(node)
    rev_status = get_revision_status(repo, revision)
    if rev_status != "new" and rev_status != "rework":
        flash("Revision {0} is {1} and cannot be abandoned. Refresh list of revisions.".format(revision.node, rev_status), "error")
        logger.info("Revision {0} is {1} and cannot be abandoned".format(revision.node, rev_status))
        if is_safe_url(request.referrer):
            return redirect(request.referrer)
        return redirect(url_for('index'))
    #TODO: Multiple bookmarks
    changeset = Changeset(revision.name, revision.email, revision.title,
                          revision.node, el(revision.bookmarks),
                          "ABANDONED")
    db.session.add(changeset)
    Head.query.filter(Head.node == revision.node).delete()
    db.session.commit()
    repo.hg_close_branch(revision.node)
    if is_safe_url(request.referrer):
        return redirect(request.referrer)
    return redirect(url_for("index"))