in libmozevent/mercurial.py [0:0]
def add_try_commit(self, build):
"""
Build and commit the file configuring try
* always try_task_config.json
* MC payload in json mode
* custom simpler payload on syntax mode
"""
path = os.path.join(self.dir, "try_task_config.json")
if self.try_mode == TryMode.json:
config = {
"version": 2,
"parameters": {
"target_tasks_method": "codereview",
"optimize_target_tasks": True,
"phabricator_diff": build.target_phid,
},
}
diff_phid = build.stack[-1].phid
if build.revision_url:
message = f"try_task_config for {build.revision_url}"
else:
message = "try_task_config for code-review"
message += f"\nDifferential Diff: {diff_phid}"
elif self.try_mode == TryMode.syntax:
config = {
"version": 2,
"parameters": {
"code-review": {"phabricator-build-target": build.target_phid}
},
}
message = "try: {}".format(self.try_syntax)
if build.revision_url is not None:
message += f"\nPhabricator Revision: {build.revision_url}"
else:
raise Exception("Unsupported try mode")
# Write content as json and commit it
with open(path, "w") as f:
json.dump(config, f, sort_keys=True, indent=4)
self.repo.add(path.encode("utf-8"))
self.repo.commit(message=message, user=DEFAULT_AUTHOR)