mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-01 19:22:41 +01:00
Improve compatibility of "arc patch" on Windows
Summary: Can't use (cd ...) on windows. Test Plan: Ran "arc patch" successfully. Reviewers: Makinde, btrahan Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T124, T1034 Differential Revision: https://secure.phabricator.com/D1987
This commit is contained in:
parent
1acbe76cbf
commit
4ca58d1129
2 changed files with 26 additions and 25 deletions
|
@ -97,9 +97,10 @@ abstract class ArcanistRepositoryAPI {
|
||||||
|
|
||||||
public function getPath($to_file = null) {
|
public function getPath($to_file = null) {
|
||||||
if ($to_file !== null) {
|
if ($to_file !== null) {
|
||||||
return $this->path.'/'.ltrim($to_file, '/');
|
return $this->path.DIRECTORY_SEPARATOR.
|
||||||
|
ltrim($to_file, DIRECTORY_SEPARATOR);
|
||||||
} else {
|
} else {
|
||||||
return $this->path.'/';
|
return $this->path.DIRECTORY_SEPARATOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,6 +202,11 @@ abstract class ArcanistRepositoryAPI {
|
||||||
return $this->buildLocalFuture($args)->resolve();
|
return $this->buildLocalFuture($args)->resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function execFutureLocal($pattern /*, ... */) {
|
||||||
|
$args = func_get_args();
|
||||||
|
return $this->buildLocalFuture($args);
|
||||||
|
}
|
||||||
|
|
||||||
abstract protected function buildLocalFuture(array $argv);
|
abstract protected function buildLocalFuture(array $argv);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,11 +233,9 @@ EOTEXT
|
||||||
foreach ($suffixes as $suffix) {
|
foreach ($suffixes as $suffix) {
|
||||||
$proposed_name = $base_name.$suffix;
|
$proposed_name = $base_name.$suffix;
|
||||||
|
|
||||||
list($err) = exec_manual(
|
list($err) = $repository_api->execManualLocal(
|
||||||
'(cd %s; git rev-parse --verify %s)',
|
'rev-parse --verify %s',
|
||||||
$repository_api->getPath(),
|
$proposed_name);
|
||||||
$proposed_name
|
|
||||||
);
|
|
||||||
|
|
||||||
// no error means git rev-parse found a branch
|
// no error means git rev-parse found a branch
|
||||||
if (!$err) {
|
if (!$err) {
|
||||||
|
@ -273,21 +271,18 @@ EOTEXT
|
||||||
// NOTE: Use 'cat-file', not 'rev-parse --verify', because 'rev-parse'
|
// NOTE: Use 'cat-file', not 'rev-parse --verify', because 'rev-parse'
|
||||||
// always "verifies" any properly-formatted commit even if it does not
|
// always "verifies" any properly-formatted commit even if it does not
|
||||||
// exist.
|
// exist.
|
||||||
list($err) = exec_manual(
|
list($err) = $repository_api->execManualLocal(
|
||||||
'(cd %s; git cat-file -t %s)',
|
'cat-file -t %s',
|
||||||
$repository_api->getPath(),
|
|
||||||
$base_revision);
|
$base_revision);
|
||||||
|
|
||||||
if ($base_revision && !$err) {
|
if ($base_revision && !$err) {
|
||||||
execx(
|
$repository_api->execxLocal(
|
||||||
'(cd %s; git checkout -b %s %s)',
|
'checkout -b %s %s',
|
||||||
$repository_api->getPath(),
|
|
||||||
$branch_name,
|
$branch_name,
|
||||||
$base_revision);
|
$base_revision);
|
||||||
} else {
|
} else {
|
||||||
execx(
|
$repository_api->execxLocal(
|
||||||
'(cd %s; git checkout -b %s)',
|
'checkout -b %s',
|
||||||
$repository_api->getPath(),
|
|
||||||
$branch_name);
|
$branch_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,6 +476,9 @@ EOTEXT
|
||||||
$this->createParentDirectoryOf($add);
|
$this->createParentDirectoryOf($add);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: The SVN patch workflow likely does not work on windows because
|
||||||
|
// of the (cd ...) stuff.
|
||||||
|
|
||||||
foreach ($copies as $copy) {
|
foreach ($copies as $copy) {
|
||||||
list($src, $dst) = $copy;
|
list($src, $dst) = $copy;
|
||||||
passthru(
|
passthru(
|
||||||
|
@ -580,17 +578,15 @@ EOTEXT
|
||||||
|
|
||||||
return $patch_err;
|
return $patch_err;
|
||||||
} else if ($repository_api instanceof ArcanistGitAPI) {
|
} else if ($repository_api instanceof ArcanistGitAPI) {
|
||||||
$future = new ExecFuture(
|
$future = $repository_api->execFutureLocal(
|
||||||
'(cd %s; git apply --index --reject)',
|
'apply --index --reject');
|
||||||
$repository_api->getPath());
|
|
||||||
$future->write($bundle->toGitPatch());
|
$future->write($bundle->toGitPatch());
|
||||||
$future->resolvex();
|
$future->resolvex();
|
||||||
|
|
||||||
if ($this->shouldCommit()) {
|
if ($this->shouldCommit()) {
|
||||||
$commit_message = $this->getCommitMessage($bundle);
|
$commit_message = $this->getCommitMessage($bundle);
|
||||||
$future = new ExecFuture(
|
$future = $repository_api->execFutureLocal(
|
||||||
'(cd %s; git commit -a -F -)',
|
'commit -a -F -');
|
||||||
$repository_api->getPath());
|
|
||||||
$future->write($commit_message);
|
$future->write($commit_message);
|
||||||
$future->resolvex();
|
$future->resolvex();
|
||||||
$verb = 'committed';
|
$verb = 'committed';
|
||||||
|
@ -600,9 +596,8 @@ EOTEXT
|
||||||
echo phutil_console_format(
|
echo phutil_console_format(
|
||||||
"<bg:green>** OKAY **</bg> Successfully {$verb} patch.\n");
|
"<bg:green>** OKAY **</bg> Successfully {$verb} patch.\n");
|
||||||
} else if ($repository_api instanceof ArcanistMercurialAPI) {
|
} else if ($repository_api instanceof ArcanistMercurialAPI) {
|
||||||
$future = new ExecFuture(
|
$future = $repository_api->execFutureLocal(
|
||||||
'(cd %s; hg import --no-commit -)',
|
'import --no-commit -');
|
||||||
$repository_api->getPath());
|
|
||||||
$future->write($bundle->toGitPatch());
|
$future->write($bundle->toGitPatch());
|
||||||
$future->resolvex();
|
$future->resolvex();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue