Changeset View
Changeset View
Standalone View
Standalone View
src/repository/marker/ArcanistMercurialRepositoryMarkerQuery.php
Show All 13 Lines | final class ArcanistMercurialRepositoryMarkerQuery | ||||
private function newMarkers(ArcanistRemoteRef $remote = null) { | private function newMarkers(ArcanistRemoteRef $remote = null) { | ||||
$api = $this->getRepositoryAPI(); | $api = $this->getRepositoryAPI(); | ||||
// In native Mercurial it is difficult to identify remote markers, and | // In native Mercurial it is difficult to identify remote markers, and | ||||
// complicated to identify local markers efficiently. We use an extension | // complicated to identify local markers efficiently. We use an extension | ||||
// to provide a command which works like "git for-each-ref" locally and | // to provide a command which works like "git for-each-ref" locally and | ||||
// "git ls-remote" when given a remote. | // "git ls-remote" when given a remote. | ||||
$argv = array(); | |||||
foreach ($api->getMercurialExtensionArguments() as $arg) { | |||||
$argv[] = $arg; | |||||
} | |||||
$argv[] = 'arc-ls-markers'; | |||||
// NOTE: In remote mode, we're using passthru and a tempfile on this | // NOTE: In remote mode, we're using passthru and a tempfile on this | ||||
// because it's a remote command and may prompt the user to provide | // because it's a remote command and may prompt the user to provide | ||||
// credentials interactively. In local mode, we can just read stdout. | // credentials interactively. In local mode, we can just read stdout. | ||||
if ($remote !== null) { | if ($remote !== null) { | ||||
$tmpfile = new TempFile(); | $tmpfile = new TempFile(); | ||||
Filesystem::remove($tmpfile); | Filesystem::remove($tmpfile); | ||||
$argv = array(); | |||||
$argv[] = '--output'; | $argv[] = '--output'; | ||||
$argv[] = phutil_string_cast($tmpfile); | $argv[] = phutil_string_cast($tmpfile); | ||||
} | |||||
$argv[] = '--'; | $argv[] = '--'; | ||||
if ($remote !== null) { | |||||
$argv[] = $remote->getRemoteName(); | $argv[] = $remote->getRemoteName(); | ||||
} | |||||
if ($remote !== null) { | $err = $api->execPassthruWithExtension( | ||||
$passthru = $api->newPassthru('%Ls', $argv); | 'arc-hg', | ||||
'arc-ls-markers %Ls', | |||||
$argv); | |||||
$err = $passthru->execute(); | |||||
if ($err) { | if ($err) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Call to "hg arc-ls-markers" failed with error "%s".', | 'Call to "hg arc-ls-markers" failed with error "%s".', | ||||
$err)); | $err)); | ||||
} | } | ||||
$raw_data = Filesystem::readFile($tmpfile); | $raw_data = Filesystem::readFile($tmpfile); | ||||
unset($tmpfile); | unset($tmpfile); | ||||
} else { | } else { | ||||
$future = $api->newFuture('%Ls', $argv); | $future = $api->execFutureLocalWithExtension( | ||||
list($raw_data) = $future->resolve(); | 'arc-hg', | ||||
'arc-ls-markers --'); | |||||
list($err, $raw_data) = $future->resolve(); | |||||
} | } | ||||
$items = phutil_json_decode($raw_data); | $items = phutil_json_decode($raw_data); | ||||
$markers = array(); | $markers = array(); | ||||
foreach ($items as $item) { | foreach ($items as $item) { | ||||
if (!empty($item['isClosed'])) { | if (!empty($item['isClosed'])) { | ||||
// NOTE: For now, we ignore closed branch heads. | // NOTE: For now, we ignore closed branch heads. | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |