mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-23 05:50:54 +01:00
Update some ancient "set X=Y" environment code for new Windows execution without a shell
Summary: Depends on D21051. Ref T13504. Ref T13209. This very old Mercurial code uses "X=Y hg ..." on Linux and "set X=Y & hg ..." on Windows. The latter construct no longer works because we bypass the shell. The former construct is obsolete. Additionaly, delete some ancient "branch merge" code which has no callers. Test Plan: Created a diff in a Mercurial repository on Linux. I minimally vetted this on Windows since I don't have a "hg + Windows" environment at the moment. Maniphest Tasks: T13504, T13209 Differential Revision: https://secure.phabricator.com/D21052
This commit is contained in:
parent
d4d095dbf6
commit
368aec16a1
4 changed files with 33 additions and 75 deletions
|
@ -1181,26 +1181,6 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
|||
return $parser->parseDiff($diff);
|
||||
}
|
||||
|
||||
public function supportsLocalBranchMerge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function performLocalBranchMerge($branch, $message) {
|
||||
if (!$branch) {
|
||||
throw new ArcanistUsageException(
|
||||
pht('Under git, you must specify the branch you want to merge.'));
|
||||
}
|
||||
$err = phutil_passthru(
|
||||
'(cd %s && git merge --no-ff -m %s %s)',
|
||||
$this->getPath(),
|
||||
$message,
|
||||
$branch);
|
||||
|
||||
if ($err) {
|
||||
throw new ArcanistUsageException(pht('Merge failed!'));
|
||||
}
|
||||
}
|
||||
|
||||
public function getFinalizedRevisionMessage() {
|
||||
return pht(
|
||||
"You may now push this commit upstream, as appropriate (e.g. with ".
|
||||
|
|
|
@ -13,36 +13,29 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
|||
private $supportsPhases;
|
||||
|
||||
protected function buildLocalFuture(array $argv) {
|
||||
// Mercurial has a "defaults" feature which basically breaks automation by
|
||||
// allowing the user to add random flags to any command. This feature is
|
||||
// "deprecated" and "a bad idea" that you should "forget ... existed"
|
||||
// according to project lead Matt Mackall:
|
||||
//
|
||||
// http://markmail.org/message/hl3d6eprubmkkqh5
|
||||
//
|
||||
// There is an HGPLAIN environmental variable which enables "plain mode"
|
||||
// and hopefully disables this stuff.
|
||||
$env = $this->getMercurialEnvironmentVariables();
|
||||
|
||||
if (phutil_is_windows()) {
|
||||
$argv[0] = 'set HGPLAIN=1 & hg '.$argv[0];
|
||||
} else {
|
||||
$argv[0] = 'HGPLAIN=1 hg '.$argv[0];
|
||||
}
|
||||
$argv[0] = 'hg '.$argv[0];
|
||||
|
||||
$future = newv('ExecFuture', $argv)
|
||||
->setEnv($env)
|
||||
->setCWD($this->getPath());
|
||||
|
||||
$future = newv('ExecFuture', $argv);
|
||||
$future->setCWD($this->getPath());
|
||||
return $future;
|
||||
}
|
||||
|
||||
public function execPassthru($pattern /* , ... */) {
|
||||
$args = func_get_args();
|
||||
if (phutil_is_windows()) {
|
||||
$args[0] = 'hg '.$args[0];
|
||||
} else {
|
||||
$args[0] = 'HGPLAIN=1 hg '.$args[0];
|
||||
}
|
||||
|
||||
return call_user_func_array('phutil_passthru', $args);
|
||||
$env = $this->getMercurialEnvironmentVariables();
|
||||
|
||||
$args[0] = 'hg '.$args[0];
|
||||
|
||||
$passthru = newv('PhutilExecPassthru', $args)
|
||||
->setEnv($env)
|
||||
->setCWD($this->getPath());
|
||||
|
||||
return $passthru->resolve();
|
||||
}
|
||||
|
||||
public function getSourceControlSystemName() {
|
||||
|
@ -616,29 +609,6 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
|||
return $parser->parseDiff($diff);
|
||||
}
|
||||
|
||||
public function supportsLocalBranchMerge() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function performLocalBranchMerge($branch, $message) {
|
||||
if ($branch) {
|
||||
$err = phutil_passthru(
|
||||
'(cd %s && HGPLAIN=1 hg merge --rev %s && hg commit -m %s)',
|
||||
$this->getPath(),
|
||||
$branch,
|
||||
$message);
|
||||
} else {
|
||||
$err = phutil_passthru(
|
||||
'(cd %s && HGPLAIN=1 hg merge && hg commit -m %s)',
|
||||
$this->getPath(),
|
||||
$message);
|
||||
}
|
||||
|
||||
if ($err) {
|
||||
throw new ArcanistUsageException(pht('Merge failed!'));
|
||||
}
|
||||
}
|
||||
|
||||
public function getFinalizedRevisionMessage() {
|
||||
return pht(
|
||||
"You may now push this commit upstream, as appropriate (e.g. with ".
|
||||
|
@ -1133,4 +1103,22 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
|||
return null;
|
||||
}
|
||||
|
||||
private function getMercurialEnvironmentVariables() {
|
||||
$env = array();
|
||||
|
||||
// Mercurial has a "defaults" feature which basically breaks automation by
|
||||
// allowing the user to add random flags to any command. This feature is
|
||||
// "deprecated" and "a bad idea" that you should "forget ... existed"
|
||||
// according to project lead Matt Mackall:
|
||||
//
|
||||
// http://markmail.org/message/hl3d6eprubmkkqh5
|
||||
//
|
||||
// There is an HGPLAIN environmental variable which enables "plain mode"
|
||||
// and hopefully disables this stuff.
|
||||
|
||||
$env['HGPLAIN'] = 1;
|
||||
|
||||
return $env;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -394,12 +394,6 @@ abstract class ArcanistRepositoryAPI extends Phobject {
|
|||
throw new ArcanistCapabilityNotSupportedException($this);
|
||||
}
|
||||
|
||||
abstract public function supportsLocalBranchMerge();
|
||||
|
||||
public function performLocalBranchMerge($branch, $message) {
|
||||
throw new ArcanistCapabilityNotSupportedException($this);
|
||||
}
|
||||
|
||||
public function getFinalizedRevisionMessage() {
|
||||
throw new ArcanistCapabilityNotSupportedException($this);
|
||||
}
|
||||
|
|
|
@ -634,10 +634,6 @@ EODIFF;
|
|||
return $this->getSourceControlBaseRevision();
|
||||
}
|
||||
|
||||
public function supportsLocalBranchMerge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFinalizedRevisionMessage() {
|
||||
// In other VCSes we give push instructions here, but it never makes sense
|
||||
// in SVN.
|
||||
|
|
Loading…
Reference in a new issue