mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-18 01:38:38 +01:00
Arc patch - upgrade "same base rev" check to "does this commit exist in the working copy?" check
Summary: good title Test Plan: ran "arc patch DX" a bunch Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Maniphest Tasks: T892 Differential Revision: https://secure.phabricator.com/D1789
This commit is contained in:
parent
2c26304dd2
commit
276b013d87
5 changed files with 37 additions and 19 deletions
|
@ -161,6 +161,10 @@ abstract class ArcanistRepositoryAPI {
|
||||||
ConduitClient $conduit,
|
ConduitClient $conduit,
|
||||||
array $query);
|
array $query);
|
||||||
|
|
||||||
|
public function hasLocalCommit($commit) {
|
||||||
|
throw new ArcanistCapabilityNotSupportedException($this);
|
||||||
|
}
|
||||||
|
|
||||||
public function getCommitMessageForRevision($revision) {
|
public function getCommitMessageForRevision($revision) {
|
||||||
throw new ArcanistCapabilityNotSupportedException($this);
|
throw new ArcanistCapabilityNotSupportedException($this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,6 +551,13 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasLocalCommit($commit) {
|
||||||
|
list($err) = $this->execManualLocal(
|
||||||
|
'merge-base %s HEAD',
|
||||||
|
$commit);
|
||||||
|
return !$err;
|
||||||
|
}
|
||||||
|
|
||||||
public function parseRelativeLocalCommit(array $argv) {
|
public function parseRelativeLocalCommit(array $argv) {
|
||||||
if (count($argv) == 0) {
|
if (count($argv) == 0) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -71,12 +71,10 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRelativeCommit($commit) {
|
public function setRelativeCommit($commit) {
|
||||||
list($err) = $this->execManualLocal('id -ir %s', $commit);
|
if (!$this->hasLocalCommit($commit)) {
|
||||||
if ($err) {
|
|
||||||
throw new ArcanistUsageException(
|
throw new ArcanistUsageException(
|
||||||
"Commit '{$commit}' is not a valid Mercurial commit identifier.");
|
"Commit '{$commit}' is not a valid Mercurial commit identifier.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->relativeCommit = $commit;
|
$this->relativeCommit = $commit;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -338,6 +336,11 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasLocalCommit($commit) {
|
||||||
|
list($err) = $this->execManualLocal('id -ir %s', $commit);
|
||||||
|
return !$err;
|
||||||
|
}
|
||||||
|
|
||||||
public function parseRelativeLocalCommit(array $argv) {
|
public function parseRelativeLocalCommit(array $argv) {
|
||||||
if (count($argv) == 0) {
|
if (count($argv) == 0) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -502,6 +502,10 @@ EODIFF;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasLocalCommit($commit) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function getWorkingCopyRevision() {
|
public function getWorkingCopyRevision() {
|
||||||
return $this->getSourceControlBaseRevision();
|
return $this->getSourceControlBaseRevision();
|
||||||
}
|
}
|
||||||
|
|
|
@ -687,26 +687,26 @@ EOTEXT
|
||||||
|
|
||||||
// Check to see if the bundle's base revision matches the working copy
|
// Check to see if the bundle's base revision matches the working copy
|
||||||
// base revision
|
// base revision
|
||||||
$bundle_base_rev = $bundle->getBaseRevision();
|
$repository_api = $this->getRepositoryAPI();
|
||||||
if (empty($bundle_base_rev)) {
|
if ($repository_api->supportsRelativeLocalCommits()) {
|
||||||
// this means $source is SOURCE_PATCH || SOURCE_BUNDLE w/ $version < 2
|
$bundle_base_rev = $bundle->getBaseRevision();
|
||||||
// they don't have a base rev so just do nothing
|
if (empty($bundle_base_rev)) {
|
||||||
} else {
|
// this means $source is SOURCE_PATCH || SOURCE_BUNDLE w/ $version < 2
|
||||||
$repository_api = $this->getRepositoryAPI();
|
// they don't have a base rev so just do nothing
|
||||||
$source_base_rev = $repository_api->getWorkingCopyRevision();
|
$commit_exists = true;
|
||||||
|
} else {
|
||||||
if ($source_base_rev != $bundle_base_rev) {
|
$commit_exists =
|
||||||
|
$repository_api->hasLocalCommit($bundle_base_rev);
|
||||||
|
}
|
||||||
|
if (!$commit_exists) {
|
||||||
// we have a problem...! lots of work because we need to ask
|
// we have a problem...! lots of work because we need to ask
|
||||||
// differential for revision information for these base revisions
|
// differential for revision information for these base revisions
|
||||||
// to improve our error message.
|
// to improve our error message.
|
||||||
$bundle_base_rev_str = null;
|
$bundle_base_rev_str = null;
|
||||||
|
$source_base_rev = $repository_api->getWorkingCopyRevision();
|
||||||
$source_base_rev_str = null;
|
$source_base_rev_str = null;
|
||||||
|
|
||||||
// SVN doesn't store these hashes, so we're basically done already
|
if ($repository_api instanceof ArcanistGitAPI) {
|
||||||
// and will have a relatively "lame" error message
|
|
||||||
if ($repository_api instanceof ArcanistSubversionAPI) {
|
|
||||||
$hash_type = null;
|
|
||||||
} else if ($repository_api instanceof ArcanistGitAPI) {
|
|
||||||
$hash_type = ArcanistDifferentialRevisionHash::HASH_GIT_COMMIT;
|
$hash_type = ArcanistDifferentialRevisionHash::HASH_GIT_COMMIT;
|
||||||
} else if ($repository_api instanceof ArcanistMercurialAPI) {
|
} else if ($repository_api instanceof ArcanistMercurialAPI) {
|
||||||
$hash_type = ArcanistDifferentialRevisionHash::HASH_MERCURIAL_COMMIT;
|
$hash_type = ArcanistDifferentialRevisionHash::HASH_MERCURIAL_COMMIT;
|
||||||
|
@ -738,8 +738,8 @@ EOTEXT
|
||||||
|
|
||||||
$ok = phutil_console_confirm(
|
$ok = phutil_console_confirm(
|
||||||
"This diff is against commit {$bundle_base_rev_str}, but the ".
|
"This diff is against commit {$bundle_base_rev_str}, but the ".
|
||||||
"working copy is at {$source_base_rev_str}. ".
|
"commit is nowhere in the working copy. Try to apply it against ".
|
||||||
"Still try to apply it?",
|
"the current working copy state? ({$source_base_rev_str})",
|
||||||
$default_no = false
|
$default_no = false
|
||||||
);
|
);
|
||||||
if (!$ok) {
|
if (!$ok) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue