コード例 #1
0
ファイル: routes.py プロジェクト: pasliwa/code_review
def changeset_abandon(cs_id):
    logger.info("Requested URL /changeset/%d/abandon [POST]", cs_id)
    changeset = Changeset.query.filter(Changeset.id == cs_id).first()
    if changeset is None:
        flash("Changeset {0} doesn't exist".format(cs_id), "error")
        logger.error("Changeset %d doesn't exist", cs_id)
        return redirect(url_for('index'))
    if not changeset.is_active():
        flash("Not active changeset cannot be abandoned", "error")
        logger.error("Changeset %d is not active and cannot be abandoned", cs_id)
        return redirect(url_for('changeset_info', cs_id=cs_id))
    if not (changeset.diff is None):
        flash("Changeset with diff attached to it cannot be abandoned", "error")
        logger.error("Changeset %d has a diff attached to it and cannot be abandoned", cs_id)
        return redirect(url_for('changeset_info', cs_id=cs_id))
    
    review = Review.query.filter(Review.id == changeset.review_id).first()
      
    changeset.status = "ABANDONED"
    db.session.commit()
    repo.hg_sync()
    repo.hg_bookmark(bookmark=changeset.bookmark, delete=True)
    if review.active_changeset is None:
        review_abandon(review.id)
    else:
        repo.hg_update(review.active_changeset.sha1)
        repo.hg_command("bookmark", changeset.bookmark)
    
    if changeset.sha1 in repo.hg_heads():
        repo.hg_close_branch(changeset.sha1)
    flash("Changeset '{title}' (SHA1: {sha1}) has been abandoned".format(title=changeset.title,
                                                                         sha1=changeset.sha1), "notice")
    repo.hg_push()                                                                     
    return redirect(url_for("review_info", review_id=changeset.review_id))
コード例 #2
0
ファイル: routes.py プロジェクト: pasliwa/code_review
def review_abandon(review_id):
    logger.info("Requested URL /review/%d/abandon [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"))
    review.status = "ABANDONED"
    review.abandoned_date = datetime.datetime.utcnow()
    Head.query.filter(Head.review_id == review.id).update({'review_id': None})
    db.session.commit()
    repo.hg_sync()
    #repo.hg_bookmark(bookmark=review.bookmark, delete=True)
    #repo.hg_push()
    heads = repo.hg_heads()
    for c in review.changesets:
        if c.sha1 in heads:
            repo.hg_close_branch(c.sha1)
    flash("Review has been abandoned", "notice")
    return redirect(url_for('changes_active'))
コード例 #3
0
ファイル: routes.py プロジェクト: pasliwa/code_review
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"))