Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistDiffWorkflow.php
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | $arguments = array( | ||||
), | ), | ||||
'help' => pht( | 'help' => pht( | ||||
'When updating a revision under git, edit revision information '. | 'When updating a revision under git, edit revision information '. | ||||
'before updating.'), | 'before updating.'), | ||||
), | ), | ||||
'raw' => array( | 'raw' => array( | ||||
'help' => pht( | 'help' => pht( | ||||
'Read diff from stdin, not from the working copy. This disables '. | 'Read diff from stdin, not from the working copy. This disables '. | ||||
'many Arcanist/Phabricator features which depend on having access '. | 'many features which depend on having access to the working copy.'), | ||||
'to the working copy.'), | |||||
'conflicts' => array( | 'conflicts' => array( | ||||
'apply-patches' => pht('%s disables lint.', '--raw'), | 'apply-patches' => pht('%s disables lint.', '--raw'), | ||||
'never-apply-patches' => pht('%s disables lint.', '--raw'), | 'never-apply-patches' => pht('%s disables lint.', '--raw'), | ||||
'create' => pht( | 'create' => pht( | ||||
'%s and %s both need stdin. Use %s.', | '%s and %s both need stdin. Use %s.', | ||||
'--raw', | '--raw', | ||||
'--create', | '--create', | ||||
'--raw-command'), | '--raw-command'), | ||||
'edit' => pht( | 'edit' => pht( | ||||
'%s and %s both need stdin. Use %s.', | '%s and %s both need stdin. Use %s.', | ||||
'--raw', | '--raw', | ||||
'--edit', | '--edit', | ||||
'--raw-command'), | '--raw-command'), | ||||
'raw-command' => null, | 'raw-command' => null, | ||||
), | ), | ||||
), | ), | ||||
'raw-command' => array( | 'raw-command' => array( | ||||
'param' => 'command', | 'param' => 'command', | ||||
'help' => pht( | 'help' => pht( | ||||
'Generate diff by executing a specified command, not from the '. | 'Generate diff by executing a specified command, not from the '. | ||||
'working copy. This disables many Arcanist/Phabricator features '. | 'working copy. This disables many features which depend on having '. | ||||
'which depend on having access to the working copy.'), | 'access to the working copy.'), | ||||
'conflicts' => array( | 'conflicts' => array( | ||||
'apply-patches' => pht('%s disables lint.', '--raw-command'), | 'apply-patches' => pht('%s disables lint.', '--raw-command'), | ||||
'never-apply-patches' => pht('%s disables lint.', '--raw-command'), | 'never-apply-patches' => pht('%s disables lint.', '--raw-command'), | ||||
), | ), | ||||
), | ), | ||||
'create' => array( | 'create' => array( | ||||
'help' => pht('Always create a new revision.'), | 'help' => pht('Always create a new revision.'), | ||||
'conflicts' => array( | 'conflicts' => array( | ||||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | $arguments = array( | ||||
'browse' => array( | 'browse' => array( | ||||
'help' => pht( | 'help' => pht( | ||||
'After creating a diff or revision, open it in a web browser.'), | 'After creating a diff or revision, open it in a web browser.'), | ||||
), | ), | ||||
'*' => 'paths', | '*' => 'paths', | ||||
'head' => array( | 'head' => array( | ||||
'param' => 'commit', | 'param' => 'commit', | ||||
'help' => pht( | 'help' => pht( | ||||
'Specify the end of the commit range. This disables many '. | 'Specify the end of the commit range. This disables many features '. | ||||
'Arcanist/Phabricator features which depend on having access to '. | 'which depend on having access to the working copy.'), | ||||
'the working copy.'), | |||||
'supports' => array('git'), | 'supports' => array('git'), | ||||
'nosupport' => array( | 'nosupport' => array( | ||||
'svn' => pht('Subversion does not support commit ranges.'), | 'svn' => pht('Subversion does not support commit ranges.'), | ||||
'hg' => pht('Mercurial does not support %s yet.', '--head'), | 'hg' => pht('Mercurial does not support %s yet.', '--head'), | ||||
), | ), | ||||
), | ), | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | if ($this->shouldOnlyCreateDiff()) { | ||||
// TODO: This is hacky, but we don't currently receive a URI back | // TODO: This is hacky, but we don't currently receive a URI back | ||||
// from "differential.revision.edit". | // from "differential.revision.edit". | ||||
$result_uri = id(new PhutilURI($this->getConduitURI())) | $result_uri = id(new PhutilURI($this->getConduitURI())) | ||||
->setPath('/D'.$result_id); | ->setPath('/D'.$result_id); | ||||
} else { | } else { | ||||
if ($is_draft) { | if ($is_draft) { | ||||
throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
pht( | pht( | ||||
'You have specified "--draft", but the version of Phabricator '. | 'You have specified "--draft", but the software version '. | ||||
'on the server is too old to support draft revisions. Omit '. | 'on the server is too old to support draft revisions. Omit '. | ||||
'the flag or upgrade the server software.')); | 'the flag or upgrade the server software.')); | ||||
} | } | ||||
$revision = $this->dispatchWillCreateRevisionEvent($revision); | $revision = $this->dispatchWillCreateRevisionEvent($revision); | ||||
$result = $conduit->callMethodSynchronous( | $result = $conduit->callMethodSynchronous( | ||||
'differential.createrevision', | 'differential.createrevision', | ||||
▲ Show 20 Lines • Show All 415 Lines • ▼ Show 20 Lines | foreach ($changes as $change) { | ||||
$is_binary = ArcanistDiffUtils::isHeuristicBinaryFile($corpus); | $is_binary = ArcanistDiffUtils::isHeuristicBinaryFile($corpus); | ||||
if (!$is_binary) { | if (!$is_binary) { | ||||
try { | try { | ||||
$try_encoding = $this->getRepositoryEncoding(); | $try_encoding = $this->getRepositoryEncoding(); | ||||
} catch (ConduitClientException $e) { | } catch (ConduitClientException $e) { | ||||
if ($e->getErrorCode() == 'ERR-BAD-ARCANIST-PROJECT') { | if ($e->getErrorCode() == 'ERR-BAD-ARCANIST-PROJECT') { | ||||
echo phutil_console_wrap( | echo phutil_console_wrap( | ||||
pht('Lookup of encoding in arcanist project failed: %s', | pht('Lookup of encoding in project failed: %s', | ||||
$e->getMessage())."\n"); | $e->getMessage())."\n"); | ||||
} else { | } else { | ||||
throw $e; | throw $e; | ||||
} | } | ||||
} | } | ||||
if ($try_encoding) { | if ($try_encoding) { | ||||
$corpus = phutil_utf8_convert($corpus, 'UTF-8', $try_encoding); | $corpus = phutil_utf8_convert($corpus, 'UTF-8', $try_encoding); | ||||
Show All 24 Lines | if ($utf8_problems) { | ||||
"%s\n\n%s\n\n %s\n", | "%s\n\n%s\n\n %s\n", | ||||
pht( | pht( | ||||
'This diff includes %s file(s) which are not valid UTF-8 (they '. | 'This diff includes %s file(s) which are not valid UTF-8 (they '. | ||||
'contain invalid byte sequences). You can either stop this '. | 'contain invalid byte sequences). You can either stop this '. | ||||
'workflow and fix these files, or continue. If you continue, '. | 'workflow and fix these files, or continue. If you continue, '. | ||||
'these files will be marked as binary.', | 'these files will be marked as binary.', | ||||
phutil_count($utf8_problems)), | phutil_count($utf8_problems)), | ||||
pht( | pht( | ||||
"You can learn more about how Phabricator handles character ". | "You can learn more about how this software handles character ". | ||||
"encodings (and how to configure encoding settings and detect and ". | "encodings (and how to configure encoding settings and detect and ". | ||||
"correct encoding problems) by reading 'User Guide: UTF-8 and ". | "correct encoding problems) by reading 'User Guide: UTF-8 and ". | ||||
"Character Encoding' in the Phabricator documentation."), | "Character Encoding' in the documentation."), | ||||
pht( | pht( | ||||
'%s AFFECTED FILE(S)', | '%s AFFECTED FILE(S)', | ||||
phutil_count($utf8_problems))); | phutil_count($utf8_problems))); | ||||
$confirm = pht( | $confirm = pht( | ||||
'Do you want to mark these %s file(s) as binary and continue?', | 'Do you want to mark these %s file(s) as binary and continue?', | ||||
phutil_count($utf8_problems)); | phutil_count($utf8_problems)); | ||||
echo phutil_console_format( | echo phutil_console_format( | ||||
▲ Show 20 Lines • Show All 1,642 Lines • ▼ Show 20 Lines | if ($staging === null) { | ||||
pht('The server does not support staging areas.')); | pht('The server does not support staging areas.')); | ||||
return self::STAGING_REPOSITORY_UNAVAILABLE; | return self::STAGING_REPOSITORY_UNAVAILABLE; | ||||
} | } | ||||
$supported = idx($staging, 'supported'); | $supported = idx($staging, 'supported'); | ||||
if (!$supported) { | if (!$supported) { | ||||
$this->writeInfo( | $this->writeInfo( | ||||
pht('SKIP STAGING'), | pht('SKIP STAGING'), | ||||
pht('Phabricator does not support staging areas for this repository.')); | pht('The server does not support staging areas for this repository.')); | ||||
return self::STAGING_REPOSITORY_UNSUPPORTED; | return self::STAGING_REPOSITORY_UNSUPPORTED; | ||||
} | } | ||||
$staging_uri = idx($staging, 'uri'); | $staging_uri = idx($staging, 'uri'); | ||||
if (!$staging_uri) { | if (!$staging_uri) { | ||||
$this->writeInfo( | $this->writeInfo( | ||||
pht('SKIP STAGING'), | pht('SKIP STAGING'), | ||||
pht('No staging area is configured for this repository.')); | pht('No staging area is configured for this repository.')); | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |