Changeset View
Changeset View
Standalone View
Standalone View
src/repository/parser/ArcanistMercurialParser.php
Context not available. | |||||
$result = array(); | $result = array(); | ||||
$stdout = trim($stdout); | $stdout = trim($stdout); | ||||
if (!strlen($stdout)) { | if (!@strlen($stdout)) { | ||||
return $result; | return $result; | ||||
} | } | ||||
$last_path = null; | $last_path = null; | ||||
$lines = explode("\n", $stdout); | $lines = @explode("\n", $stdout); | ||||
foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
$flags = 0; | $flags = 0; | ||||
if ($line[1] !== ' ') { | if ($line[1] !== ' ') { | ||||
Context not available. | |||||
$line)); | $line)); | ||||
} | } | ||||
$code = $line[0]; | $code = $line[0]; | ||||
$path = substr($line, 2); | $path = @substr($line, 2); | ||||
switch ($code) { | switch ($code) { | ||||
case 'A': | case 'A': | ||||
$flags |= ArcanistRepositoryAPI::FLAG_ADDED; | $flags |= ArcanistRepositoryAPI::FLAG_ADDED; | ||||
Context not available. | |||||
$result = array(); | $result = array(); | ||||
$stdout = trim($stdout); | $stdout = trim($stdout); | ||||
if (!strlen($stdout)) { | if (!@strlen($stdout)) { | ||||
return $result; | return $result; | ||||
} | } | ||||
$chunks = explode("\n\n", $stdout); | $chunks = @explode("\n\n", $stdout); | ||||
foreach ($chunks as $chunk) { | foreach ($chunks as $chunk) { | ||||
$commit = array(); | $commit = array(); | ||||
$lines = explode("\n", $chunk); | $lines = @explode("\n", $chunk); | ||||
foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
if (preg_match('/^(comparing with|searching for changes)/', $line)) { | if (@preg_match('/^(comparing with|searching for changes)/', $line)) { | ||||
// These are sent to stdout when you run "hg outgoing" although the | // These are sent to stdout when you run "hg outgoing" although the | ||||
// format is otherwise identical to "hg log". | // format is otherwise identical to "hg log". | ||||
continue; | continue; | ||||
} | } | ||||
if (preg_match('/^remote:/', $line)) { | if (@preg_match('/^remote:/', $line)) { | ||||
// This indicates remote error in "hg outgoing". | // This indicates remote error in "hg outgoing". | ||||
continue; | continue; | ||||
} | } | ||||
list($name, $value) = explode(':', $line, 2); | list($name, $value) = @explode(':', $line, 2); | ||||
$value = trim($value); | $value = trim($value); | ||||
switch ($name) { | switch ($name) { | ||||
case 'user': | case 'user': | ||||
Context not available. | |||||
$commit['summary'] = $value; | $commit['summary'] = $value; | ||||
break; | break; | ||||
case 'changeset': | case 'changeset': | ||||
list($local, $rev) = explode(':', $value, 2); | list($local, $rev) = @explode(':', $value, 2); | ||||
$commit['local'] = $local; | $commit['local'] = $local; | ||||
$commit['rev'] = $rev; | $commit['rev'] = $rev; | ||||
break; | break; | ||||
Context not available. | |||||
if (empty($commit['parents'])) { | if (empty($commit['parents'])) { | ||||
$commit['parents'] = array(); | $commit['parents'] = array(); | ||||
} | } | ||||
list($local, $rev) = explode(':', $value, 2); | list($local, $rev) = @explode(':', $value, 2); | ||||
$commit['parents'][] = array( | $commit['parents'][] = array( | ||||
'local' => $local, | 'local' => $local, | ||||
'rev' => $rev, | 'rev' => $rev, | ||||
Context not available. | |||||
*/ | */ | ||||
public static function parseMercurialBranches($stdout) { | public static function parseMercurialBranches($stdout) { | ||||
$stdout = rtrim($stdout, "\n"); | $stdout = rtrim($stdout, "\n"); | ||||
if (!strlen($stdout)) { | if (!@strlen($stdout)) { | ||||
// No branches; commonly, this occurs in a newly initialized repository. | // No branches; commonly, this occurs in a newly initialized repository. | ||||
return array(); | return array(); | ||||
} | } | ||||
$lines = explode("\n", $stdout); | $lines = @explode("\n", $stdout); | ||||
$branches = array(); | $branches = array(); | ||||
foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
Context not available. | |||||
// See the unit tests for more examples. | // See the unit tests for more examples. | ||||
$regexp = '/^(\S+(?:\s+\S+)*)\s+(\d+):([a-f0-9]+)(\s+\\(inactive\\))?$/'; | $regexp = '/^(\S+(?:\s+\S+)*)\s+(\d+):([a-f0-9]+)(\s+\\(inactive\\))?$/'; | ||||
if (!preg_match($regexp, $line, $matches)) { | if (!@preg_match($regexp, $line, $matches)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
"Failed to parse '%s' output: %s", | "Failed to parse '%s' output: %s", | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0