Changeset View
Changeset View
Standalone View
Standalone View
src/repository/api/ArcanistMercurialAPI.php
Context not available. | |||||
"{date|rfc822date}\1{branch}\1{tag}\1{parents}\1{desc}\2", | "{date|rfc822date}\1{branch}\1{tag}\1{parents}\1{desc}\2", | ||||
hgsprintf('(%s::. - %s)', $base_commit, $base_commit), | hgsprintf('(%s::. - %s)', $base_commit, $base_commit), | ||||
$this->getBranchName()); | $this->getBranchName()); | ||||
$logs = array_filter(explode("\2", $info)); | $logs = array_filter(@explode("\2", $info)); | ||||
$last_node = null; | $last_node = null; | ||||
Context not available. | |||||
$commits = array(); | $commits = array(); | ||||
foreach ($logs as $log) { | foreach ($logs as $log) { | ||||
list($node, $rev, $full_author, $date, $branch, $tag, | list($node, $rev, $full_author, $date, $branch, $tag, | ||||
$parents, $desc) = explode("\1", $log, 9); | $parents, $desc) = @explode("\1", $log, 9); | ||||
list($author, $author_email) = $this->parseFullAuthor($full_author); | list($author, $author_email) = $this->parseFullAuthor($full_author); | ||||
Context not available. | |||||
'rev' => $node, // TODO: Remove eventually. | 'rev' => $node, // TODO: Remove eventually. | ||||
'local' => $rev, | 'local' => $rev, | ||||
'parents' => $commit_parents, | 'parents' => $commit_parents, | ||||
'summary' => head(explode("\n", $desc)), | 'summary' => head(@explode("\n", $desc)), | ||||
'message' => $desc, | 'message' => $desc, | ||||
'authorEmail' => $author_email, | 'authorEmail' => $author_email, | ||||
); | ); | ||||
Context not available. | |||||
->limit(4); | ->limit(4); | ||||
foreach ($futures as $node => $future) { | foreach ($futures as $node => $future) { | ||||
list($parents) = $future->resolvex(); | list($parents) = $future->resolvex(); | ||||
$parents = array_filter(explode("\n", $parents)); | $parents = array_filter(@explode("\n", $parents)); | ||||
$commits[$node]['parents'] = $parents; | $commits[$node]['parents'] = $parents; | ||||
} | } | ||||
Context not available. | |||||
$blame = array(); | $blame = array(); | ||||
foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
if (!strlen($line)) { | if (!@strlen($line)) { | ||||
continue; | continue; | ||||
} | } | ||||
$matches = null; | $matches = null; | ||||
$ok = preg_match('/^\s*([^:]+?) ([a-f0-9]{12}):/', $line, $matches); | $ok = @preg_match('/^\s*([^:]+?) ([a-f0-9]{12}):/', $line, $matches); | ||||
if (!$ok) { | if (!$ok) { | ||||
throw new Exception( | throw new Exception( | ||||
Context not available. | |||||
if ($err) { | if ($err) { | ||||
return false; | return false; | ||||
} else { | } else { | ||||
return (strpos($stdout, 'amend') !== false); | return (@strpos($stdout, 'amend') !== false); | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
public function getAllLocalChanges() { | public function getAllLocalChanges() { | ||||
$diff = $this->getFullMercurialDiff(); | $diff = $this->getFullMercurialDiff(); | ||||
if (!strlen(trim($diff))) { | if (!@strlen(trim($diff))) { | ||||
return array(); | return array(); | ||||
} | } | ||||
$parser = new ArcanistDiffParser(); | $parser = new ArcanistDiffParser(); | ||||
Context not available. | |||||
$map = array(); | $map = array(); | ||||
$logs = explode("\2", trim($stdout)); | $logs = @explode("\2", trim($stdout)); | ||||
foreach (array_filter($logs) as $log) { | foreach (array_filter($logs) as $log) { | ||||
list($node, $desc) = explode("\1", $log); | list($node, $desc) = @explode("\1", $log); | ||||
$map[$node] = $desc; | $map[$node] = $desc; | ||||
} | } | ||||
Context not available. | |||||
)); | )); | ||||
foreach ($results as $key => $result) { | foreach ($results as $key => $result) { | ||||
$hash = substr($reason_map[$result['id']], 0, 16); | $hash = @substr($reason_map[$result['id']], 0, 16); | ||||
$results[$key]['why'] = | $results[$key]['why'] = | ||||
pht( | pht( | ||||
"Commit message for '%s' has explicit 'Differential Revision'.", | "Commit message for '%s' has explicit 'Differential Revision'.", | ||||
Context not available. | |||||
* @return array | * @return array | ||||
*/ | */ | ||||
protected function parseFullAuthor($full_author) { | protected function parseFullAuthor($full_author) { | ||||
if (strpos($full_author, '@') === false) { | if (@strpos($full_author, '@') === false) { | ||||
$author = $full_author; | $author = $full_author; | ||||
$author_email = null; | $author_email = null; | ||||
} else { | } else { | ||||
Context not available. | |||||
'commit --amend -l %s', | 'commit --amend -l %s', | ||||
$tmp_file); | $tmp_file); | ||||
} catch (CommandException $ex) { | } catch (CommandException $ex) { | ||||
if (preg_match('/nothing changed/', $ex->getStdout())) { | if (@preg_match('/nothing changed/', $ex->getStdout())) { | ||||
// NOTE: Mercurial considers it an error to make a no-op amend. Although | // NOTE: Mercurial considers it an error to make a no-op amend. Although | ||||
// we generally defer to the underlying VCS to dictate behavior, this | // we generally defer to the underlying VCS to dictate behavior, this | ||||
// one seems a little goofy, and we use amend as part of various | // one seems a little goofy, and we use amend as part of various | ||||
Context not available. | |||||
'log --template {desc} --limit 1 --rev %s', | 'log --template {desc} --limit 1 --rev %s', | ||||
$commit); | $commit); | ||||
$summary = head(explode("\n", $summary)); | $summary = head(@explode("\n", $summary)); | ||||
return trim($summary); | return trim($summary); | ||||
} | } | ||||
public function resolveBaseCommitRule($rule, $source) { | public function resolveBaseCommitRule($rule, $source) { | ||||
list($type, $name) = explode(':', $rule, 2); | list($type, $name) = @explode(':', $rule, 2); | ||||
// NOTE: This function MUST return node hashes or symbolic commits (like | // NOTE: This function MUST return node hashes or symbolic commits (like | ||||
// branch names or the word "tip"), not revsets. This includes ".^" and | // branch names or the word "tip"), not revsets. This includes ".^" and | ||||
Context not available. | |||||
switch ($type) { | switch ($type) { | ||||
case 'hg': | case 'hg': | ||||
$matches = null; | $matches = null; | ||||
if (preg_match('/^gca\((.+)\)$/', $name, $matches)) { | if (@preg_match('/^gca\((.+)\)$/', $name, $matches)) { | ||||
list($err, $merge_base) = $this->execManualLocal( | list($err, $merge_base) = $this->execManualLocal( | ||||
'log --template={node} --rev %s', | 'log --template={node} --rev %s', | ||||
sprintf('ancestor(., %s)', $matches[1])); | sprintf('ancestor(., %s)', $matches[1])); | ||||
Context not available. | |||||
$source)); | $source)); | ||||
return $this->getCanonicalRevisionName('.^'); | return $this->getCanonicalRevisionName('.^'); | ||||
default: | default: | ||||
if (preg_match('/^nodiff\((.+)\)$/', $name, $matches)) { | if (@preg_match('/^nodiff\((.+)\)$/', $name, $matches)) { | ||||
list($results) = $this->execxLocal( | list($results) = $this->execxLocal( | ||||
'log --template %s --rev %s', | 'log --template %s --rev %s', | ||||
"{node}\1{desc}\2", | "{node}\1{desc}\2", | ||||
sprintf('ancestor(.,%s)::.^', $matches[1])); | sprintf('ancestor(.,%s)::.^', $matches[1])); | ||||
$results = array_reverse(explode("\2", trim($results))); | $results = array_reverse(@explode("\2", trim($results))); | ||||
foreach ($results as $result) { | foreach ($results as $result) { | ||||
if (empty($result)) { | if (empty($result)) { | ||||
continue; | continue; | ||||
} | } | ||||
list($node, $desc) = explode("\1", $result, 2); | list($node, $desc) = @explode("\1", $result, 2); | ||||
$message = ArcanistDifferentialCommitMessage::newFromRawCorpus( | $message = ArcanistDifferentialCommitMessage::newFromRawCorpus( | ||||
$desc); | $desc); | ||||
Context not available. | |||||
$revision = null; | $revision = null; | ||||
list($err, $raw_info) = $this->execManualLocal('svn info'); | list($err, $raw_info) = $this->execManualLocal('svn info'); | ||||
if (!$err) { | if (!$err) { | ||||
foreach (explode("\n", trim($raw_info)) as $line) { | foreach (@explode("\n", trim($raw_info)) as $line) { | ||||
list($key, $value) = explode(': ', $line, 2); | list($key, $value) = @explode(': ', $line, 2); | ||||
switch ($key) { | switch ($key) { | ||||
case 'URL': | case 'URL': | ||||
$info['base_path'] = $value; | $info['base_path'] = $value; | ||||
Context not available. | |||||
list($stdout) = $this->execxLocal('paths default'); | list($stdout) = $this->execxLocal('paths default'); | ||||
$stdout = trim($stdout); | $stdout = trim($stdout); | ||||
if (strlen($stdout)) { | if (@strlen($stdout)) { | ||||
return $stdout; | return $stdout; | ||||
} | } | ||||
Context not available. | |||||
$hashes = array(); | $hashes = array(); | ||||
foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
if (!strlen(trim($line))) { | if (!@strlen(trim($line))) { | ||||
continue; | continue; | ||||
} | } | ||||
$hashes[] = $line; | $hashes[] = $line; | ||||
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