Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistDiffWorkflow.php
Context not available. | |||||
$this->revisionID = $revision_id; | $this->revisionID = $revision_id; | ||||
$revision['message'] = $this->getArgument('message'); | $revision['message'] = $this->getArgument('message'); | ||||
if (!strlen($revision['message'])) { | if (!@strlen($revision['message'])) { | ||||
$update_messages = $this->readScratchJSONFile('update-messages.json'); | $update_messages = $this->readScratchJSONFile('update-messages.json'); | ||||
$update_messages[$revision_id] = $this->getUpdateMessage( | $update_messages[$revision_id] = $this->getUpdateMessage( | ||||
Context not available. | |||||
$revision['message'] = ArcanistCommentRemover::removeComments( | $revision['message'] = ArcanistCommentRemover::removeComments( | ||||
$update_messages[$revision_id]); | $update_messages[$revision_id]); | ||||
if (!strlen(trim($revision['message']))) { | if (!@strlen(trim($revision['message']))) { | ||||
throw new ArcanistUserAbortException(); | throw new ArcanistUserAbortException(); | ||||
} | } | ||||
Context not available. | |||||
$diff = $repository_api->getFullGitDiff( | $diff = $repository_api->getFullGitDiff( | ||||
$repository_api->getBaseCommit(), | $repository_api->getBaseCommit(), | ||||
$repository_api->getHeadCommit()); | $repository_api->getHeadCommit()); | ||||
if (!strlen($diff)) { | if (!@strlen($diff)) { | ||||
throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
pht('No changes found. (Did you specify the wrong commit range?)')); | pht('No changes found. (Did you specify the wrong commit range?)')); | ||||
} | } | ||||
$changes = $parser->parseDiff($diff); | $changes = $parser->parseDiff($diff); | ||||
} else if ($repository_api instanceof ArcanistMercurialAPI) { | } else if ($repository_api instanceof ArcanistMercurialAPI) { | ||||
$diff = $repository_api->getFullMercurialDiff(); | $diff = $repository_api->getFullMercurialDiff(); | ||||
if (!strlen($diff)) { | if (!@strlen($diff)) { | ||||
throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
pht('No changes found. (Did you specify the wrong commit range?)')); | pht('No changes found. (Did you specify the wrong commit range?)')); | ||||
} | } | ||||
Context not available. | |||||
foreach ($changes as $change) { | foreach ($changes as $change) { | ||||
$size = 0; | $size = 0; | ||||
foreach ($change->getHunks() as $hunk) { | foreach ($change->getHunks() as $hunk) { | ||||
$size += strlen($hunk->getCorpus()); | $size += @strlen($hunk->getCorpus()); | ||||
} | } | ||||
if ($size > $limit) { | if ($size > $limit) { | ||||
$byte_warning = pht( | $byte_warning = pht( | ||||
Context not available. | |||||
if ($saved) { | if ($saved) { | ||||
$where = $this->getReadableScratchFilePath('create-message'); | $where = $this->getReadableScratchFilePath('create-message'); | ||||
$preview = explode("\n", $saved); | $preview = @explode("\n", $saved); | ||||
$preview = array_shift($preview); | $preview = array_shift($preview); | ||||
$preview = trim($preview); | $preview = trim($preview); | ||||
$preview = id(new PhutilUTF8StringTruncator()) | $preview = id(new PhutilUTF8StringTruncator()) | ||||
Context not available. | |||||
$username = $user['userName']; | $username = $user['userName']; | ||||
$real_name = $user['realName']; | $real_name = $user['realName']; | ||||
if (strlen($real_name)) { | if (@strlen($real_name)) { | ||||
$name = pht('%s (%s)', $username, $real_name); | $name = pht('%s (%s)', $username, $real_name); | ||||
} else { | } else { | ||||
$name = pht('%s', $username); | $name = pht('%s', $username); | ||||
Context not available. | |||||
// commits are included in the diff. | // commits are included in the diff. | ||||
$included = array(); | $included = array(); | ||||
foreach ($local as $hash => $info) { | foreach ($local as $hash => $info) { | ||||
$included[] = substr($hash, 0, 12).' '.$info['summary']; | $included[] = @substr($hash, 0, 12).' '.$info['summary']; | ||||
} | } | ||||
// Parse all of the messages into fields. | // Parse all of the messages into fields. | ||||
Context not available. | |||||
} | } | ||||
$fields[$hash] = $message->getFields(); | $fields[$hash] = $message->getFields(); | ||||
$frev = substr($hash, 0, 12); | $frev = @substr($hash, 0, 12); | ||||
$notes[] = pht( | $notes[] = pht( | ||||
'NOTE: commit %s could not be completely parsed:', | 'NOTE: commit %s could not be completely parsed:', | ||||
$frev); | $frev); | ||||
Context not available. | |||||
foreach ($fields as $hash => $dict) { | foreach ($fields as $hash => $dict) { | ||||
$title = idx($dict, 'title'); | $title = idx($dict, 'title'); | ||||
if (!strlen($title)) { | if (!@strlen($title)) { | ||||
continue; | continue; | ||||
} | } | ||||
Context not available. | |||||
$result[$key] = $new; | $result[$key] = $new; | ||||
continue; | continue; | ||||
} else { | } else { | ||||
if (!strlen(trim($value))) { | if (!@strlen(trim($value))) { | ||||
// Ignore empty fields. | // Ignore empty fields. | ||||
continue; | continue; | ||||
} | } | ||||
Context not available. | |||||
// a blank line separating them. Examples are "Test Plan" and | // a blank line separating them. Examples are "Test Plan" and | ||||
// "Summary". | // "Summary". | ||||
$cur = idx($result, $key, ''); | $cur = idx($result, $key, ''); | ||||
if (strlen($cur)) { | if (@strlen($cur)) { | ||||
$new = $cur."\n\n".$value; | $new = $cur."\n\n".$value; | ||||
} else { | } else { | ||||
$new = $value; | $new = $value; | ||||
Context not available. | |||||
foreach ($usable as $message) { | foreach ($usable as $message) { | ||||
// Pick the first line out of each message. | // Pick the first line out of each message. | ||||
$text = trim($message); | $text = trim($message); | ||||
$text = head(explode("\n", $text)); | $text = head(@explode("\n", $text)); | ||||
$default[] = ' - '.$text."\n"; | $default[] = ' - '.$text."\n"; | ||||
} | } | ||||
Context not available. | |||||
// If we track an upstream branch either directly or indirectly, use that. | // If we track an upstream branch either directly or indirectly, use that. | ||||
$branch = $api->getBranchName(); | $branch = $api->getBranchName(); | ||||
if (strlen($branch)) { | if (@strlen($branch)) { | ||||
$upstream_path = $api->getPathToUpstream($branch); | $upstream_path = $api->getPathToUpstream($branch); | ||||
$remote_branch = $upstream_path->getRemoteBranchName(); | $remote_branch = $upstream_path->getRemoteBranchName(); | ||||
if (strlen($remote_branch)) { | if (@strlen($remote_branch)) { | ||||
return array( | return array( | ||||
array( | array( | ||||
'type' => 'branch', | 'type' => 'branch', | ||||
Context not available. | |||||
// If "arc.land.onto.default" is configured, use that. | // If "arc.land.onto.default" is configured, use that. | ||||
$config_key = 'arc.land.onto.default'; | $config_key = 'arc.land.onto.default'; | ||||
$onto = $this->getConfigFromAnySource($config_key); | $onto = $this->getConfigFromAnySource($config_key); | ||||
if (strlen($onto)) { | if (@strlen($onto)) { | ||||
return array( | return array( | ||||
array( | array( | ||||
'type' => 'branch', | 'type' => 'branch', | ||||
Context not available. | |||||
} | } | ||||
$type = $spec['type']; | $type = $spec['type']; | ||||
$size = strlen($spec['data']); | $size = @strlen($spec['data']); | ||||
$change->setMetadata("{$type}:file:size", $size); | $change->setMetadata("{$type}:file:size", $size); | ||||
$mime = $this->getFileMimeType($spec['data']); | $mime = $this->getFileMimeType($spec['data']); | ||||
if (preg_match('@^image/@', $mime)) { | if (@preg_match('@^image/@', $mime)) { | ||||
$change->setFileType($type_image); | $change->setFileType($type_image); | ||||
} | } | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0