def init_repos(self): if os.path.exists(REPO_MASTER): shutil.rmtree(REPO_MASTER) if os.path.exists(config.REPO_PATH): shutil.rmtree(config.REPO_PATH) os.makedirs(REPO_MASTER) self.master = Repo(REPO_MASTER) self.master.hg_init() self.slave = Repo.hg_clone(REPO_MASTER, config.REPO_PATH)
class MercurialBase(unittest.TestCase): def commit_master(self, line_text, file_name=FILE_1, rev=None, line_no=0, bmk=None, tag=None): if rev: self.master.hg_update(rev, clean=True) if bmk: self.master.hg_bookmark(bmk, force=True) modfile(file_name, line_no, line_text) self.master.hg_add(file_name) self.master.hg_commit(line_text) if tag: self.master.hg_tag(tag, "--local") return self.master.hg_id() def commit_slave(self, line_text, file_name=FILE_2, rev=None, line_no=0, bmk=None, tag=None): if rev: self.slave.hg_update(rev, clean=True) if bmk: self.slave.hg_bookmark(bmk, force=True) modfile(file_name, line_no, line_text) self.slave.hg_add(file_name) self.slave.hg_commit(line_text) if tag: self.slave.hg_tag(tag, "--local") return self.slave.hg_id() def init_repos(self): if os.path.exists(REPO_MASTER): shutil.rmtree(REPO_MASTER) if os.path.exists(config.REPO_PATH): shutil.rmtree(config.REPO_PATH) os.makedirs(REPO_MASTER) self.master = Repo(REPO_MASTER) self.master.hg_init() self.slave = Repo.hg_clone(REPO_MASTER, config.REPO_PATH)
from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///testing.db" db = SQLAlchemy(app) db.create_all() from app.mercurial import Repo from app.hgapi.hgapi import HgException repo = Repo("../repository/project_1") from app.model import Changeset, Review, User merged_reviews = Review.query.filter(Review.status == "MERGED").all() bookmarks = repo.hg_bookmarks() print bookmarks for merged_review in merged_reviews: if merged_review.bookmark in bookmarks: repo.hg_bookmark(bookmark=merged_review.bookmark, delete=True) #repo.hg_command("bookmark", "-d", merged_review.bookmark) repo.hg_command("push", "-B", merged_review.bookmark) abandoned_reviews = Review.query.filter(Review.status == "ABANDONED").all()