Changeset View
Changeset View
Standalone View
Standalone View
src/repository/state/ArcanistGitLocalState.php
Show All 20 Lines | protected function executeSaveLocalState() { | ||||
$commit = $api->getWorkingCopyRevision(); | $commit = $api->getWorkingCopyRevision(); | ||||
list($ref) = $api->execxLocal('rev-parse --abbrev-ref HEAD'); | list($ref) = $api->execxLocal('rev-parse --abbrev-ref HEAD'); | ||||
$ref = trim($ref); | $ref = trim($ref); | ||||
if ($ref === 'HEAD') { | if ($ref === 'HEAD') { | ||||
$ref = null; | $ref = null; | ||||
$where = pht( | $where = pht( | ||||
'Saving local state (at detached commit "%s").', | 'Saving local state (at detached commit "%s").', | ||||
$this->getDisplayHash($commit)); | $api->getDisplayHash($commit)); | ||||
} else { | } else { | ||||
$where = pht( | $where = pht( | ||||
'Saving local state (on ref "%s" at commit "%s").', | 'Saving local state (on ref "%s" at commit "%s").', | ||||
$ref, | $ref, | ||||
$this->getDisplayHash($commit)); | $api->getDisplayHash($commit)); | ||||
} | } | ||||
$this->localRef = $ref; | $this->localRef = $ref; | ||||
$this->localCommit = $commit; | $this->localCommit = $commit; | ||||
if ($ref !== null) { | if ($ref !== null) { | ||||
$this->localPath = $api->getPathToUpstream($ref); | $this->localPath = $api->getPathToUpstream($ref); | ||||
} | } | ||||
$log = $this->getWorkflow()->getLogEngine(); | $log = $this->getWorkflow()->getLogEngine(); | ||||
$log->writeTrace(pht('SAVE STATE'), $where); | $log->writeTrace(pht('SAVE STATE'), $where); | ||||
} | } | ||||
protected function executeRestoreLocalState() { | protected function executeRestoreLocalState() { | ||||
$api = $this->getRepositoryAPI(); | $api = $this->getRepositoryAPI(); | ||||
$log = $this->getWorkflow()->getLogEngine(); | $log = $this->getWorkflow()->getLogEngine(); | ||||
$ref = $this->localRef; | $ref = $this->localRef; | ||||
$commit = $this->localCommit; | $commit = $this->localCommit; | ||||
if ($ref !== null) { | if ($ref !== null) { | ||||
$where = pht( | $where = pht( | ||||
'Restoring local state (to ref "%s" at commit "%s").', | 'Restoring local state (to ref "%s" at commit "%s").', | ||||
$ref, | $ref, | ||||
$this->getDisplayHash($commit)); | $api->getDisplayHash($commit)); | ||||
} else { | } else { | ||||
$where = pht( | $where = pht( | ||||
'Restoring local state (to detached commit "%s").', | 'Restoring local state (to detached commit "%s").', | ||||
$this->getDisplayHash($commit)); | $api->getDisplayHash($commit)); | ||||
} | } | ||||
$log->writeStatus(pht('LOAD STATE'), $where); | $log->writeStatus(pht('LOAD STATE'), $where); | ||||
if ($ref !== null) { | if ($ref !== null) { | ||||
$api->execxLocal('checkout -B %s %s --', $ref, $commit); | $api->execxLocal('checkout -B %s %s --', $ref, $commit); | ||||
// TODO: We save, but do not restore, the upstream configuration of | // TODO: We save, but do not restore, the upstream configuration of | ||||
// this branch. | // this branch. | ||||
} else { | } else { | ||||
$api->execxLocal('checkout %s --', $commit); | $api->execxLocal('checkout %s --', $commit); | ||||
} | } | ||||
$api->execxLocal('submodule update --init --recursive'); | $api->execxLocal('submodule update --init --recursive'); | ||||
} | } | ||||
protected function executeDiscardLocalState() { | protected function executeDiscardLocalState() { | ||||
// We don't have anything to clean up in Git. | // We don't have anything to clean up in Git. | ||||
return; | return; | ||||
} | } | ||||
protected function newRestoreCommandsForDisplay() { | protected function newRestoreCommandsForDisplay() { | ||||
$api = $this->getRepositoryAPI(); | |||||
$ref = $this->localRef; | $ref = $this->localRef; | ||||
$commit = $this->localCommit; | $commit = $this->localCommit; | ||||
$commands = array(); | $commands = array(); | ||||
if ($ref !== null) { | if ($ref !== null) { | ||||
$commands[] = csprintf( | $commands[] = csprintf( | ||||
'git checkout -B %s %s --', | 'git checkout -B %s %s --', | ||||
$ref, | $ref, | ||||
$this->getDisplayHash($commit)); | $api->getDisplayHash($commit)); | ||||
} else { | } else { | ||||
$commands[] = csprintf( | $commands[] = csprintf( | ||||
'git checkout %s --', | 'git checkout %s --', | ||||
$this->getDisplayHash($commit)); | $api->getDisplayHash($commit)); | ||||
} | } | ||||
// NOTE: We run "submodule update" in the real restore workflow, but | // NOTE: We run "submodule update" in the real restore workflow, but | ||||
// assume users can reasonably figure that out on their own. | // assume users can reasonably figure that out on their own. | ||||
return $commands; | return $commands; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |