Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
db.commit()
else:
confirmation_id = row[0]
message = "Merge %s adds merged-in commits:" % merge.sha1[:8]
for tail_sha1 in tails:
for parent_sha1 in merge.parents:
if parent_sha1 in new_commits:
parent = new_commits.get(parent_sha1)
if tail_sha1 in new_commits.getTailsFrom(parent):
message += "\n %s..%s" % (tail_sha1[:8], parent_sha1[:8])
message += """
Please confirm that this is intended by loading:
%s/confirmmerge?id=%d""" % (dbutils.getURLPrefix(db, user), confirmation_id)
raise index.IndexException(message)
elif row[2] is not None:
if row[2] == merge.getId(db):
cursor.execute("SELECT merged FROM reviewmergecontributions WHERE id=%s",
(row[0],))
for (merged_id,) in cursor:
merged = gitutils.Commit.fromId(db, review.repository, merged_id)
if merged.sha1 in merge.parents:
new_commits = new_commits.without([merged])
break
else:
tail = gitutils.Commit.fromId(db, review.repository, row[2])
cut = [gitutils.Commit.fromSHA1(db, review.repository, sha1)
for sha1 in tail.parents if sha1 in new_commits]
if not candidates:
paths.sort(cmp=lambda a, b: cmp(len(a[1]), len(b[1])))
url = "/%s/%s..%s?file=%s" % (review.repository.name, paths[0][0][:8], review.branch.head_sha1[:8], ",".join(map(str, sorted(files_in_review))))
message = """\
<p>It is not possible to generate a diff of the requested set of
commits that contains only changes from those commits.</p>
<p>The following files would contain unrelated changes:</p><p>
</p><pre style="padding-left: 2em">%s</pre>
<p>You can use the URL below if you want to view this diff anyway,
including the unrelated changes.</p>
<pre style="padding-left: 2em"><a href="%s">%s%s</a></pre>""" % ("\n".join(sorted(overlapping_changes)), url, dbutils.getURLPrefix(db, user), url)
raise page.utils.DisplayMessage(title="Impossible Diff",
body=message,
review=review,
html=True)
else:
candidates.sort(cmp=lambda a, b: cmp(len(b[1]), len(a[1])))
return candidates[0][0], review.branch.head_sha1, all_commits, listed_commits
if tails:
from_sha1 = tails.pop()
else:
# Review starts with the initial commit.
from_sha1 = None
injects.append(role)
elif isinstance(role, ProcessCommitsRole):
processcommits.append(role)
elif isinstance(role, FilterHookRole):
filterhooks.append(role)
elif isinstance(role, ScheduledRole):
scheduled.append(role)
role_table = target.table("roles")
if pages:
role_table.tr().th(colspan=2).text("Pages")
for role in pages:
row = role_table.tr()
url = "%s/%s" % (dbutils.getURLPrefix(db, user), role.pattern)
if is_installed and "*" not in url:
row.td("pattern").a(href=url).text(url)
else:
row.td("pattern").text(url)
td = row.td("description")
td.text(role.description)
if injects:
role_table.tr().th(colspan=2).text("Page Injections")
for role in injects:
row = role_table.tr()
row.td("pattern").text("%s/%s" % (dbutils.getURLPrefix(db, user), role.pattern))
td = row.td("description")
td.text(role.description)
def renderFormatted(db, user, table, lines, toc=False, title_right=None):
re_h1 = re.compile("^=+$")
re_h2 = re.compile("^-+$")
data = { "configuration.URL": dbutils.getURLPrefix(db, user),
"configuration.base.HOSTNAME": configuration.base.HOSTNAME,
"configuration.base.SYSTEM_USER_NAME": configuration.base.SYSTEM_USER_NAME,
"configuration.base.SYSTEM_GROUP_NAME": configuration.base.SYSTEM_GROUP_NAME,
"configuration.paths.CONFIG_DIR": configuration.paths.CONFIG_DIR,
"configuration.paths.INSTALL_DIR": configuration.paths.INSTALL_DIR,
"configuration.paths.DATA_DIR": configuration.paths.DATA_DIR,
"configuration.paths.GIT_DIR": configuration.paths.GIT_DIR }
references = {}
blocks = []
block = []
for line in lines:
match = re.match(r'\[(.*?)\]: (.*?)(?: "(.*?)")?$', line)
if match:
name, url, title = match.groups()
@staticmethod
def constructURL(db, user, path):
path = os.path.relpath(path, configuration.paths.GIT_DIR)
url_type = user.getPreference(db, "repository.urlType")
if url_type == "git":
url_format = "git://%s/%s"
elif url_type in ("ssh", "host"):
if url_type == "ssh":
prefix = "ssh://%s"
else:
prefix = "%s:"
url_format = prefix + os.path.join(configuration.paths.GIT_DIR, "%s")
else:
import dbutils
url_prefix = dbutils.getURLPrefix(db, user)
return "%s/%s" % (url_prefix, path)
return url_format % (configuration.base.HOSTNAME, path)
def renderFormatted(db, user, table, lines, toc=False, title_right=None):
re_h1 = re.compile("^=+$")
re_h2 = re.compile("^-+$")
data = { "configuration.URL": dbutils.getURLPrefix(db),
"configuration.base.HOSTNAME": configuration.base.HOSTNAME,
"configuration.base.SYSTEM_USER_NAME": configuration.base.SYSTEM_USER_NAME,
"configuration.base.SYSTEM_GROUP_NAME": configuration.base.SYSTEM_GROUP_NAME,
"configuration.paths.CONFIG_DIR": configuration.paths.CONFIG_DIR,
"configuration.paths.INSTALL_DIR": configuration.paths.INSTALL_DIR,
"configuration.paths.GIT_DIR": configuration.paths.GIT_DIR }
blocks = []
block = []
for line in lines:
if line.strip():
block.append(line % data)
elif block:
blocks.append(block)
block = []
def getURL(self, db, user=None, indent=0, separator="\n"):
import dbutils
indent = " " * indent
if user:
url_prefixes = user.getCriticURLs(db)
else:
url_prefixes = [dbutils.getURLPrefix(db)]
return separator.join(["%s%s/r/%d" % (indent, url_prefix, self.id) for url_prefix in url_prefixes])