Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistExportWorkflow.php
| Show All 38 Lines | return phutil_console_format(<<<EOTEXT | ||||
| (__--unified__), or arc bundle (__--arcbundle__ __path__) format. | (__--unified__), or arc bundle (__--arcbundle__ __path__) format. | ||||
| EOTEXT | EOTEXT | ||||
| ); | ); | ||||
| } | } | ||||
| public function getArguments() { | public function getArguments() { | ||||
| return array( | return array( | ||||
| 'git' => array( | 'git' => array( | ||||
| 'help' => | 'help' => pht( | ||||
| "Export change as a git patch. This format is more complete than ". | "Export change as a git patch. This format is more complete than ". | ||||
| "unified, but less complete than arc bundles. These patches can be ". | "unified, but less complete than arc bundles. These patches can be ". | ||||
| "applied with 'git apply' or 'arc patch'.", | "applied with '%s' or '%s'.", | ||||
| 'git apply', | |||||
| 'arc patch'), | |||||
| ), | ), | ||||
| 'unified' => array( | 'unified' => array( | ||||
| 'help' => | 'help' => pht( | ||||
| "Export change as a unified patch. This format is less complete ". | "Export change as a unified patch. This format is less complete ". | ||||
| "than git patches or arc bundles. These patches can be applied with ". | "than git patches or arc bundles. These patches can be applied with ". | ||||
| "'patch' or 'arc patch'.", | "'%s' or '%s'.", | ||||
| 'patch', | |||||
| 'arc patch'), | |||||
| ), | ), | ||||
| 'arcbundle' => array( | 'arcbundle' => array( | ||||
| 'param' => 'file', | 'param' => 'file', | ||||
| 'help' => | 'help' => pht( | ||||
| "Export change as an arc bundle. This format can represent all ". | "Export change as an arc bundle. This format can represent all ". | ||||
| "changes. These bundles can be applied with 'arc patch'.", | "changes. These bundles can be applied with '%s'.", | ||||
| 'arc patch'), | |||||
| ), | ), | ||||
| 'encoding' => array( | 'encoding' => array( | ||||
| 'param' => 'encoding', | 'param' => 'encoding', | ||||
| 'help' => | 'help' => pht( | ||||
| 'Attempt to convert non UTF-8 patch into specified encoding.', | 'Attempt to convert non UTF-8 patch into specified encoding.'), | ||||
| ), | ), | ||||
| 'revision' => array( | 'revision' => array( | ||||
| 'param' => 'revision_id', | 'param' => 'revision_id', | ||||
| 'help' => | 'help' => pht( | ||||
| 'Instead of exporting changes from the working copy, export them '. | 'Instead of exporting changes from the working copy, export them '. | ||||
| 'from a Differential revision.', | 'from a Differential revision.'), | ||||
| ), | ), | ||||
| 'diff' => array( | 'diff' => array( | ||||
| 'param' => 'diff_id', | 'param' => 'diff_id', | ||||
| 'help' => | 'help' => pht( | ||||
| 'Instead of exporting changes from the working copy, export them '. | 'Instead of exporting changes from the working copy, export them '. | ||||
| 'from a Differential diff.', | 'from a Differential diff.'), | ||||
| ), | ), | ||||
| '*' => 'paths', | '*' => 'paths', | ||||
| ); | ); | ||||
| } | } | ||||
| protected function didParseArguments() { | protected function didParseArguments() { | ||||
| $source = self::SOURCE_LOCAL; | $source = self::SOURCE_LOCAL; | ||||
| $requested = 0; | $requested = 0; | ||||
| Show All 9 Lines | if ($this->getArgument('diff')) { | ||||
| $requested++; | $requested++; | ||||
| $this->sourceID = $this->getArgument($source); | $this->sourceID = $this->getArgument($source); | ||||
| } | } | ||||
| $this->source = $source; | $this->source = $source; | ||||
| if ($requested > 1) { | if ($requested > 1) { | ||||
| throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
| "Options '--revision' and '--diff' are not compatible. Choose exactly ". | pht( | ||||
| "one change source."); | "Options '%s' and '%s' are not compatible. Choose exactly ". | ||||
| "one change source.", | |||||
| '--revision', | |||||
| '--diff')); | |||||
| } | } | ||||
| $format = null; | $format = null; | ||||
| $requested = 0; | $requested = 0; | ||||
| if ($this->getArgument('git')) { | if ($this->getArgument('git')) { | ||||
| $format = self::FORMAT_GIT; | $format = self::FORMAT_GIT; | ||||
| $requested++; | $requested++; | ||||
| } | } | ||||
| if ($this->getArgument('unified')) { | if ($this->getArgument('unified')) { | ||||
| $format = self::FORMAT_UNIFIED; | $format = self::FORMAT_UNIFIED; | ||||
| $requested++; | $requested++; | ||||
| } | } | ||||
| if ($this->getArgument('arcbundle')) { | if ($this->getArgument('arcbundle')) { | ||||
| $format = self::FORMAT_BUNDLE; | $format = self::FORMAT_BUNDLE; | ||||
| $requested++; | $requested++; | ||||
| } | } | ||||
| if ($requested === 0) { | if ($requested === 0) { | ||||
| throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
| "Specify one of '--git', '--unified' or '--arcbundle <path>' to ". | pht( | ||||
| "choose an export format."); | "Specify one of '%s', '%s' or '%s' to choose an export format.", | ||||
| '--git', | |||||
| '--unified', | |||||
| '--arcbundle <path>')); | |||||
| } else if ($requested > 1) { | } else if ($requested > 1) { | ||||
| throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
| "Options '--git', '--unified' and '--arcbundle' are not compatible. ". | pht( | ||||
| "Choose exactly one export format."); | "Options '%s', '%s' and '%s' are not compatible. ". | ||||
| "Choose exactly one export format.", | |||||
| '--git', | |||||
| '--unified', | |||||
| '--arcbundle')); | |||||
| } | } | ||||
| $this->format = $format; | $this->format = $format; | ||||
| } | } | ||||
| public function requiresConduit() { | public function requiresConduit() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | switch ($format) { | ||||
| case self::FORMAT_GIT: | case self::FORMAT_GIT: | ||||
| echo $bundle->toGitPatch(); | echo $bundle->toGitPatch(); | ||||
| break; | break; | ||||
| case self::FORMAT_UNIFIED: | case self::FORMAT_UNIFIED: | ||||
| echo $bundle->toUnifiedDiff(); | echo $bundle->toUnifiedDiff(); | ||||
| break; | break; | ||||
| case self::FORMAT_BUNDLE: | case self::FORMAT_BUNDLE: | ||||
| $path = $this->getArgument('arcbundle'); | $path = $this->getArgument('arcbundle'); | ||||
| echo "Writing bundle to '{$path}'...\n"; | echo pht("Writing bundle to '%s'...", $path)."\n"; | ||||
| $bundle->writeToDisk($path); | $bundle->writeToDisk($path); | ||||
| echo "done.\n"; | echo pht('Done.')."\n"; | ||||
| break; | break; | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||