mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-21 22:32:41 +01:00
Make corrections to the "arc amend" workflow in Mercurial repositories to be compatible with PHP 5+
Summary: Refs T13665 In the update to D21716 the `str_starts_with` function was added which is only available in PHP 8. This changes it to use `strncmp()` which is compatible back to PHP 4. Additionally fixed running into an error when trying to run `arc amend` on a commit which already matches the content known in Phabricator. Mercurial throws an error when running `amend` without file changes and using the exact same commit message it already has. Test Plan: I created a commit and revision then used `hg amend -e` to modify the commit message locally. I used `arc amend` to update the commit message back to the appropriate message from Phabricator. I ran `arc amend` again to verify that the command did not fail even though the commit message is unchanged. I ran `arc inspect --explore -- 'commit(674492bb460)'` and verified it matched the appropriate commit, to verify the substring matching works properly. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T13665 Differential Revision: https://secure.phabricator.com/D21723
This commit is contained in:
parent
d246a06562
commit
a028291f8e
2 changed files with 5 additions and 2 deletions
|
@ -159,7 +159,7 @@ final class ArcanistMercurialCommitSymbolCommitHardpointQuery
|
||||||
// a spot which a marker might match.
|
// a spot which a marker might match.
|
||||||
foreach ($node_list as $node) {
|
foreach ($node_list as $node) {
|
||||||
foreach ($symbol_set as $symbol) {
|
foreach ($symbol_set as $symbol) {
|
||||||
if (str_starts_with($node, $symbol)) {
|
if (strncmp($node, $symbol, strlen($symbol)) === 0) {
|
||||||
if (!isset($hash_map[$symbol])) {
|
if (!isset($hash_map[$symbol])) {
|
||||||
$hash_map[$symbol] = $node;
|
$hash_map[$symbol] = $node;
|
||||||
}
|
}
|
||||||
|
|
|
@ -672,7 +672,10 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
public function amendCommit($message = null) {
|
public function amendCommit($message = null) {
|
||||||
$path_statuses = $this->buildUncommittedStatus();
|
$path_statuses = $this->buildUncommittedStatus();
|
||||||
|
|
||||||
if ($message === null) {
|
$existing_message = $this->getCommitMessage(
|
||||||
|
$this->getWorkingCopyRevision());
|
||||||
|
|
||||||
|
if ($message === null || $message == $existing_message) {
|
||||||
if (empty($path_statuses)) {
|
if (empty($path_statuses)) {
|
||||||
// If there are no changes to the working directory and the message is
|
// If there are no changes to the working directory and the message is
|
||||||
// not being changed then there's nothing to amend. Notably Mercurial
|
// not being changed then there's nothing to amend. Notably Mercurial
|
||||||
|
|
Loading…
Reference in a new issue