Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
progress.write(" reachable contains missing commits")
except KeyboardInterrupt: sys.exit(1)
except:
progress.write("WARNING[%s]: %s missing!" % (repository.name, branch_name))
if branch_type == "normal":
cursor.execute("SELECT id FROM branches WHERE base=%s", (branch_id,))
sub_branches = cursor.fetchall()
if sub_branches:
progress.write(" branch has sub-branches")
base_branch = dbutils.Branch.fromId(db, branch_base_id)
for (sub_branch_id,) in sub_branches:
sub_branch = dbutils.Branch.fromId(db, sub_branch_id)
sub_branch.rebase(db, base_branch)
progress.write(" rebased sub-branch %s" % sub_branch.name)
try:
if force:
cursor.execute("DELETE FROM branches WHERE id=%s", (branch_id,))
db.commit()
progress.write(" deleted from database")
except KeyboardInterrupt: sys.exit(1)
except:
progress.write(" failed to delete from database")
db.rollback()
else:
try: review_id = getReview(branch_id)
except KeyboardInterrupt: sys.exit(1)
except:
if profiler: profiler.check("Branch.fromId: basic")
repository = gitutils.Repository.fromId(db, repository_id)
if profiler: profiler.check("Branch.fromId: repository")
if load_commits:
try: head_commit = gitutils.Commit.fromId(db, repository, head_commit_id)
except: head_commit = None
if profiler: profiler.check("Branch.fromId: head")
else:
head_commit = None
if load_commits:
base_branch = Branch.fromId(db, base_branch_id) if base_branch_id is not None else None
if profiler: profiler.check("Branch.fromId: base")
tail_commit = gitutils.Commit.fromId(db, repository, tail_commit_id) if tail_commit_id is not None else None
if profiler: profiler.check("Branch.fromId: tail")
else:
base_branch = None
tail_commit = None
branch = Branch(branch_id, repository, branch_name, head_commit, base_branch, tail_commit, type, review_id)
if has_review and load_review:
branch.review = Review.fromBranch(db, branch)
if profiler: profiler.check("Branch.fromId: review")