Example #1
0
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))
Example #2
0
def refresh_heads():
    repo.hg_sync()
    Head.query.delete()
    for repo_head in get_heads(repo):
        head = Head(repo_head)
        logger.debug("Adding head: %s", head.title)
        db.session.add(head)
    db.session.commit()
Example #3
0
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'))
Example #4
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()))
Example #5
0
def update_mercurial():
    repo.hg_sync()