Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistDiffWorkflow.php
Context not available. | |||||
'before updating.'), | 'before updating.'), | ||||
), | ), | ||||
'raw' => array( | 'raw' => array( | ||||
'param' => 'source', | |||||
'help' => pht( | 'help' => pht( | ||||
'Read diff from stdin, not from the working copy. This disables '. | 'Read diff from specified source, not from the working copy. '. | ||||
'many Arcanist/Phabricator features which depend on having access '. | 'Use "-" to read from stdin. '. | ||||
'to the working copy.'), | 'This disables many features which depend on having access to '. | ||||
'conflicts' => array( | 'the working copy.'), | ||||
'create' => pht( | |||||
'%s and %s both need stdin. Use %s.', | |||||
'--raw', | |||||
'--create', | |||||
'--raw-command'), | |||||
'edit' => pht( | |||||
'%s and %s both need stdin. Use %s.', | |||||
'--raw', | |||||
'--edit', | |||||
'--raw-command'), | |||||
'raw-command' => null, | |||||
), | |||||
), | |||||
'raw-command' => array( | |||||
'param' => 'command', | |||||
'help' => pht( | |||||
'Generate diff by executing a specified command, not from the '. | |||||
'working copy. This disables many Arcanist/Phabricator features '. | |||||
'which depend on having access to the working copy.'), | |||||
), | ), | ||||
'create' => array( | 'create' => array( | ||||
'help' => pht('Always create a new revision.'), | 'help' => pht('Always create a new revision.'), | ||||
Context not available. | |||||
'update' => true, | 'update' => true, | ||||
'only' => true, | 'only' => true, | ||||
'raw' => true, | 'raw' => true, | ||||
'raw-command' => true, | |||||
'message-file' => true, | 'message-file' => true, | ||||
), | ), | ||||
), | ), | ||||
Context not available. | |||||
} | } | ||||
public function isRawDiffSource() { | public function isRawDiffSource() { | ||||
return $this->getArgument('raw') || $this->getArgument('raw-command'); | return $this->getArgument('raw'); | ||||
} | } | ||||
public function run() { | public function run() { | ||||
Context not available. | |||||
$is_raw = $this->isRawDiffSource(); | $is_raw = $this->isRawDiffSource(); | ||||
if ($is_raw) { | if ($is_raw) { | ||||
if ($this->getArgument('raw')) { | $raw_path = $this->getArgument('raw'); | ||||
fwrite(STDERR, pht('Reading diff from stdin...')."\n"); | if ($raw_path === '-') { | ||||
$raw_diff = file_get_contents('php://stdin'); | $raw_diff = $this->readStdin(); | ||||
} else if ($this->getArgument('raw-command')) { | |||||
list($raw_diff) = execx('%C', $this->getArgument('raw-command')); | |||||
} else { | } else { | ||||
throw new Exception(pht('Unknown raw diff source.')); | $raw_diff = Filesystem::readFile($raw_path); | ||||
} | } | ||||
$changes = $parser->parseDiff($raw_diff); | $changes = $parser->parseDiff($raw_diff); | ||||
Context not available. | |||||
return false; | return false; | ||||
} | } | ||||
// Run this last: with --raw or --raw-command, we won't have a repository | // Run this last: with "--raw", we won't have a repository API. | ||||
// API. | |||||
if ($this->isHistoryImmutable()) { | if ($this->isHistoryImmutable()) { | ||||
return false; | return false; | ||||
} | } | ||||
Context not available. | |||||
$template = ArcanistCommentRemover::removeComments($new_template); | $template = ArcanistCommentRemover::removeComments($new_template); | ||||
// With --raw-command, we may not have a repository API. | // With "--raw", we may not have a repository API. | ||||
if ($this->hasRepositoryAPI()) { | if ($this->hasRepositoryAPI()) { | ||||
$repository_api = $this->getRepositoryAPI(); | $repository_api = $this->getRepositoryAPI(); | ||||
// special check for whether to amend here. optimizes a common git | // special check for whether to amend here. optimizes a common git | ||||
Context not available. |