private $includeDirectoryStateInDiffs;
private $rawDiffCache = array();
+ private $supportsRebase;
+ private $supportsPhases;
+
protected function buildLocalFuture(array $argv) {
// Mercurial has a "defaults" feature which basically breaks automation by
// Mercurial 2.1 and up have phases which indicate if something is
// published or not. To find which revs are outgoing, it's much
// faster to check the phase instead of actually checking the server.
- list($err) = $this->execManualLocal('help phase');
- if (!$err) {
+ if (!$this->supportsPhases()) {
list($err, $stdout) = $this->execManualLocal(
'log --branch %s -r %s --style default',
$this->getBranchName(),
}
}
+ public function supportsRebase() {
+ if ($this->supportsRebase === null) {
+ list ($err) = $this->execManualLocal("help rebase");
+ $this->supportsRebase = $err === 0;
+ }
+
+ return $this->supportsRebase;
+ }
+
+ public function supportsPhases() {
+ if ($this->supportsPhases === null) {
+ list ($err) = $this->execManualLocal("help phase");
+ $this->supportsPhases = $err === 0;
+ }
+
+ return $this->supportsPhases;
+ }
+
public function supportsCommitRanges() {
return true;
}
}
+ public function isHgSubversionRepo() {
+ return file_exists($this->getPath('.hg/svn'));
+ }
+
public function getSubversionInfo() {
$info = array();
$base_path = null;
}
if ($this->isHg) {
- list ($err) = $repository_api->execManualLocal('svn info');
- $this->isHgSvn = !$err;
+ $this->isHgSvn = $repository_api->isHgSubversionRepo();
}
$branch = $this->getArgument('branch');
if ($this->isHg) {
if ($this->useSquash) {
- list ($err) = $repository_api->execManualLocal("rebase --help");
- if ($err) {
+ if (!$repository_api->supportsRebase()) {
throw new ArcanistUsageException(
"You must enable the rebase extension to use ".
"the --squash strategy.");
private function checkoutBranch() {
$repository_api = $this->getRepositoryAPI();
- $repository_api->execxLocal(
- 'checkout %s',
- $this->branch);
+ if ($this->getBranchOrBookmark() != $this->branch) {
+ $repository_api->execxLocal(
+ 'checkout %s',
+ $this->branch);
+ }
echo phutil_console_format(
"Switched to branch **%s**. Identifying and merging...\n",
private function pullFromRemote() {
$repository_api = $this->getRepositoryAPI();
- $repository_api->execxLocal('checkout %s', $this->onto);
-
- echo phutil_console_format(
- "Switched to branch **%s**. Updating branch...\n",
- $this->onto);
$local_ahead_of_remote = false;
if ($this->isGit) {
+ $repository_api->execxLocal('checkout %s', $this->onto);
+
+ echo phutil_console_format(
+ "Switched to branch **%s**. Updating branch...\n",
+ $this->onto);
+
try {
$repository_api->execxLocal('pull --ff-only --no-stat');
} catch (CommandException $ex) {
}
} else if ($this->isHg) {
- // execManual instead of execx because outgoing returns
- // code 1 when there is nothing outgoing
- list($err, $out) = $repository_api->execManualLocal(
- 'outgoing -r %s',
+ echo phutil_console_format(
+ "Updating **%s**...\n",
$this->onto);
- // $err === 0 means something is outgoing
- if ($err === 0) {
- $local_ahead_of_remote = true;
+ if ($repository_api->supportsPhases()) {
+ list($out) = $repository_api->execxLocal(
+ 'log -r %s --template {phase}', $this->onto);
+ if ($out != 'public') {
+ $local_ahead_of_remote = true;
+ }
} else {
+ // execManual instead of execx because outgoing returns
+ // code 1 when there is nothing outgoing
+ list($err, $out) = $repository_api->execManualLocal(
+ 'outgoing -r %s',
+ $this->onto);
+
+ // $err === 0 means something is outgoing
+ if ($err === 0) {
+ $local_ahead_of_remote = true;
+ }
+ }
+
+ if (!$local_ahead_of_remote) {
try {
- $repository_api->execxLocal('pull -u');
+ $repository_api->execxLocal('pull');
} catch (CommandException $ex) {
$err = $ex->getError();
$stdout = $ex->getStdOut();
private function squash() {
$repository_api = $this->getRepositoryAPI();
- $repository_api->execxLocal('checkout %s', $this->onto);
if ($this->isGit) {
+ $repository_api->execxLocal('checkout %s', $this->onto);
$repository_api->execxLocal(
'merge --squash --ff-only %s',
$this->branch);