Changeset View
Changeset View
Standalone View
Standalone View
src/land/engine/ArcanistGitLandEngine.php
| Show First 20 Lines • Show All 268 Lines • ▼ Show 20 Lines | protected function executeMerge(ArcanistLandCommitSet $set, $into_commit) { | ||||
| $max_hash = $max_commit->getHash(); | $max_hash = $max_commit->getHash(); | ||||
| // NOTE: See T11435 for some history. See PHI1727 for a case where a user | // NOTE: See T11435 for some history. See PHI1727 for a case where a user | ||||
| // modified their working copy while running "arc land". This attempts to | // modified their working copy while running "arc land". This attempts to | ||||
| // resist incorrectly detecting simultaneous working copy modifications | // resist incorrectly detecting simultaneous working copy modifications | ||||
| // as changes. | // as changes. | ||||
| list($changes) = $api->execxLocal( | list($changes) = $api->execxLocal( | ||||
| 'diff --no-ext-diff %s..%s --', | 'diff --no-ext-diff %s --', | ||||
| gitsprintf( | |||||
| '%s..%s', | |||||
| $into_commit, | $into_commit, | ||||
| $max_hash); | $max_hash)); | ||||
| $changes = trim($changes); | $changes = trim($changes); | ||||
| if (!strlen($changes)) { | if (!strlen($changes)) { | ||||
| // TODO: We could make a more significant effort to identify the | // TODO: We could make a more significant effort to identify the | ||||
| // human-readable symbol which led us to try to land this ref. | // human-readable symbol which led us to try to land this ref. | ||||
| throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
| pht( | pht( | ||||
| ▲ Show 20 Lines • Show All 469 Lines • ▼ Show 20 Lines | protected function reconcileLocalState( | ||||
| $state->discardLocalState(); | $state->discardLocalState(); | ||||
| } | } | ||||
| private function isAncestorOf($branch, $commit) { | private function isAncestorOf($branch, $commit) { | ||||
| $api = $this->getRepositoryAPI(); | $api = $this->getRepositoryAPI(); | ||||
| list($stdout) = $api->execxLocal( | list($stdout) = $api->execxLocal( | ||||
| 'merge-base %s %s', | 'merge-base -- %s %s', | ||||
| $branch, | $branch, | ||||
| $commit); | $commit); | ||||
| $merge_base = trim($stdout); | $merge_base = trim($stdout); | ||||
| list($stdout) = $api->execxLocal( | list($stdout) = $api->execxLocal( | ||||
| 'rev-parse --verify %s', | 'rev-parse --verify %s', | ||||
| $branch); | $branch); | ||||
| $branch_hash = trim($stdout); | $branch_hash = trim($stdout); | ||||
| return ($merge_base === $branch_hash); | return ($merge_base === $branch_hash); | ||||
| } | } | ||||
| private function getAuthorAndDate($commit) { | private function getAuthorAndDate($commit) { | ||||
| $api = $this->getRepositoryAPI(); | $api = $this->getRepositoryAPI(); | ||||
| list($info) = $api->execxLocal( | list($info) = $api->execxLocal( | ||||
| 'log -n1 --format=%s %s --', | 'log -n1 --format=%s %s --', | ||||
| '%aD%n%an%n%ae', | '%aD%n%an%n%ae', | ||||
| $commit); | gitsprintf('%s', $commit)); | ||||
| $info = trim($info); | $info = trim($info); | ||||
| list($date, $author, $email) = explode("\n", $info, 3); | list($date, $author, $email) = explode("\n", $info, 3); | ||||
| return array( | return array( | ||||
| "$author <{$email}>", | "$author <{$email}>", | ||||
| $date, | $date, | ||||
| ); | ); | ||||
| ▲ Show 20 Lines • Show All 654 Lines • ▼ Show 20 Lines | |||||
| protected function selectCommits($into_commit, array $symbols) { | protected function selectCommits($into_commit, array $symbols) { | ||||
| assert_instances_of($symbols, 'ArcanistLandSymbol'); | assert_instances_of($symbols, 'ArcanistLandSymbol'); | ||||
| $api = $this->getRepositoryAPI(); | $api = $this->getRepositoryAPI(); | ||||
| $commit_map = array(); | $commit_map = array(); | ||||
| foreach ($symbols as $symbol) { | foreach ($symbols as $symbol) { | ||||
| $symbol_commit = $symbol->getCommit(); | $symbol_commit = $symbol->getCommit(); | ||||
| $format = '%H%x00%P%x00%s%x00'; | $format = '--format=%H%x00%P%x00%s%x00'; | ||||
| if ($into_commit === null) { | if ($into_commit === null) { | ||||
| list($commits) = $api->execxLocal( | list($commits) = $api->execxLocal( | ||||
| 'log %s --format=%s', | 'log %s %s --', | ||||
| $symbol_commit, | $format, | ||||
| $format); | gitsprintf('%s', $symbol_commit)); | ||||
| } else { | } else { | ||||
| list($commits) = $api->execxLocal( | list($commits) = $api->execxLocal( | ||||
| 'log %s --not %s --format=%s', | 'log %s %s --not %s --', | ||||
| $symbol_commit, | $format, | ||||
| $into_commit, | gitsprintf('%s', $symbol_commit), | ||||
| $format); | gitsprintf('%s', $into_commit)); | ||||
| } | } | ||||
| $commits = phutil_split_lines($commits, false); | $commits = phutil_split_lines($commits, false); | ||||
| $is_first = true; | $is_first = true; | ||||
| foreach ($commits as $line) { | foreach ($commits as $line) { | ||||
| if (!strlen($line)) { | if (!strlen($line)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines | |||||