1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00

Rename "getWorkingCopy()" to "getWorkingCopyIdentity()" in Arcanist

Summary:
Depends on D21074. Ref T13490. Ref T11968. Before toolsets, Arcanist has a "WorkingCopyIdentity" object. After toolsets, it has a "WorkingCopy" object.

Most workflows don't access either one, so make a slightly-breaking API change to simplify the transition.

  - "getWorkingCopy()" now returns a modern object (a "WorkingCopy").
  - "getWorkingCopyIdentity()" now returns an older object (a "WorkingCopyIdentity").

This isn't backward-compatible, but out-of-date code should get an explicit failure with clear resolution steps.

Test Plan: Ran "arc lint", "arc branch", and a few other commands. Grepped for "getWorkingCopy()".

Maniphest Tasks: T13490, T11968

Differential Revision: https://secure.phabricator.com/D21075
This commit is contained in:
epriestley 2020-04-08 12:34:19 -07:00
parent 391c164313
commit 92b29f53f3
5 changed files with 25 additions and 10 deletions

View file

@ -46,8 +46,6 @@ EOHELP
} }
public function runWorkflow() { public function runWorkflow() {
$working_copy = $this->getWorkingCopy();
$repository_api = $this->getRepositoryAPI(); $repository_api = $this->getRepositoryAPI();
if (!$repository_api) { if (!$repository_api) {
throw new PhutilArgumentUsageException( throw new PhutilArgumentUsageException(

View file

@ -52,7 +52,7 @@ EOTEXT
ArcanistConfigurationManager::CONFIG_SOURCE_LOCAL => ArcanistConfigurationManager::CONFIG_SOURCE_LOCAL =>
$configuration_manager->readLocalArcConfig(), $configuration_manager->readLocalArcConfig(),
ArcanistConfigurationManager::CONFIG_SOURCE_PROJECT => ArcanistConfigurationManager::CONFIG_SOURCE_PROJECT =>
$this->getWorkingCopy()->readProjectConfig(), $this->getWorkingCopyIdentity()->readProjectConfig(),
ArcanistConfigurationManager::CONFIG_SOURCE_USER => ArcanistConfigurationManager::CONFIG_SOURCE_USER =>
$configuration_manager->readUserArcConfig(), $configuration_manager->readUserArcConfig(),
ArcanistConfigurationManager::CONFIG_SOURCE_SYSTEM => ArcanistConfigurationManager::CONFIG_SOURCE_SYSTEM =>

View file

@ -146,7 +146,7 @@ EOTEXT
public function run() { public function run() {
$console = PhutilConsole::getConsole(); $console = PhutilConsole::getConsole();
$working_copy = $this->getWorkingCopy(); $working_copy = $this->getWorkingCopyIdentity();
$configuration_manager = $this->getConfigurationManager(); $configuration_manager = $this->getConfigurationManager();
$engine = $this->newLintEngine($this->getArgument('engine')); $engine = $this->newLintEngine($this->getArgument('engine'));

View file

@ -128,7 +128,7 @@ EOTEXT
} }
public function run() { public function run() {
$working_copy = $this->getWorkingCopy(); $working_copy = $this->getWorkingCopyIdentity();
$paths = $this->getArgument('paths'); $paths = $this->getArgument('paths');
$rev = $this->getArgument('rev'); $rev = $this->getArgument('rev');

View file

@ -895,6 +895,23 @@ abstract class ArcanistWorkflow extends Phobject {
final public function getWorkingCopy() { final public function getWorkingCopy() {
$configuration_engine = $this->getConfigurationEngine(); $configuration_engine = $this->getConfigurationEngine();
// TOOLSETS: Remove this once all workflows are toolset workflows.
if (!$configuration_engine) {
throw new Exception(
pht(
'This workflow has not yet been updated to Toolsets and can '.
'not retrieve a modern WorkingCopy object. Use '.
'"getWorkingCopyIdentity()" to retrieve a previous-generation '.
'object.'));
}
return $configuration_engine->getWorkingCopy();
}
final public function getWorkingCopyIdentity() {
$configuration_engine = $this->getConfigurationEngine();
if ($configuration_engine) { if ($configuration_engine) {
$working_copy = $configuration_engine->getWorkingCopy(); $working_copy = $configuration_engine->getWorkingCopy();
$working_path = $working_copy->getWorkingDirectory(); $working_path = $working_copy->getWorkingDirectory();
@ -1573,7 +1590,7 @@ abstract class ArcanistWorkflow extends Phobject {
} }
if ($paths) { if ($paths) {
$working_copy = $this->getWorkingCopy(); $working_copy = $this->getWorkingCopyIdentity();
foreach ($paths as $key => $path) { foreach ($paths as $key => $path) {
$full_path = Filesystem::resolvePath($path); $full_path = Filesystem::resolvePath($path);
if (!Filesystem::pathExists($full_path)) { if (!Filesystem::pathExists($full_path)) {
@ -2012,7 +2029,7 @@ abstract class ArcanistWorkflow extends Phobject {
* @return ArcanistLintEngine Constructed engine. * @return ArcanistLintEngine Constructed engine.
*/ */
protected function newLintEngine($engine_class = null) { protected function newLintEngine($engine_class = null) {
$working_copy = $this->getWorkingCopy(); $working_copy = $this->getWorkingCopyIdentity();
$config = $this->getConfigurationManager(); $config = $this->getConfigurationManager();
if (!$engine_class) { if (!$engine_class) {
@ -2063,7 +2080,7 @@ abstract class ArcanistWorkflow extends Phobject {
* @return ArcanistUnitTestEngine Constructed engine. * @return ArcanistUnitTestEngine Constructed engine.
*/ */
protected function newUnitTestEngine($engine_class = null) { protected function newUnitTestEngine($engine_class = null) {
$working_copy = $this->getWorkingCopy(); $working_copy = $this->getWorkingCopyIdentity();
$config = $this->getConfigurationManager(); $config = $this->getConfigurationManager();
if (!$engine_class) { if (!$engine_class) {
@ -2234,7 +2251,7 @@ abstract class ArcanistWorkflow extends Phobject {
final protected function newWorkingCopyStateRef() { final protected function newWorkingCopyStateRef() {
$ref = new ArcanistWorkingCopyStateRef(); $ref = new ArcanistWorkingCopyStateRef();
$working_copy = $this->getWorkingCopy(); $working_copy = $this->getWorkingCopyIdentity();
$ref->setRootDirectory($working_copy->getProjectRoot()); $ref->setRootDirectory($working_copy->getProjectRoot());
return $ref; return $ref;
@ -2256,7 +2273,7 @@ abstract class ArcanistWorkflow extends Phobject {
$query->setRepositoryRef($repository_ref); $query->setRepositoryRef($repository_ref);
} }
$working_copy = $this->getWorkingCopy(); $working_copy = $this->getWorkingCopyIdentity();
if ($working_copy) { if ($working_copy) {
$working_ref = $this->newWorkingCopyStateRef(); $working_ref = $this->newWorkingCopyStateRef();
$query->setWorkingCopyRef($working_ref); $query->setWorkingCopyRef($working_ref);