Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/herald/HeraldCommitAdapter.php
Show First 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | if (!$diff_file) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Failed to load diff ("%s") for this change.', | 'Failed to load diff ("%s") for this change.', | ||||
$file_phid)); | $file_phid)); | ||||
} | } | ||||
$raw = $diff_file->loadFileData(); | $raw = $diff_file->loadFileData(); | ||||
// See T13667. This happens when a commit is empty and affects no files. | |||||
if (!strlen($raw)) { | |||||
return false; | |||||
} | |||||
$parser = new ArcanistDiffParser(); | $parser = new ArcanistDiffParser(); | ||||
$changes = $parser->parseDiff($raw); | $changes = $parser->parseDiff($raw); | ||||
$diff = DifferentialDiff::newEphemeralFromRawChanges( | $diff = DifferentialDiff::newEphemeralFromRawChanges( | ||||
$changes); | $changes); | ||||
return $diff; | return $diff; | ||||
} | } | ||||
public function isDiffEnormous() { | public function isDiffEnormous() { | ||||
$this->loadDiffContent('*'); | $this->loadDiffContent('*'); | ||||
return ($this->commitDiff instanceof Exception); | return ($this->commitDiff instanceof Exception); | ||||
} | } | ||||
public function loadDiffContent($type) { | public function loadDiffContent($type) { | ||||
if ($this->commitDiff === null) { | if ($this->commitDiff === null) { | ||||
try { | try { | ||||
$this->commitDiff = $this->loadCommitDiff(); | $this->commitDiff = $this->loadCommitDiff(); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
$this->commitDiff = $ex; | $this->commitDiff = $ex; | ||||
phlog($ex); | phlog($ex); | ||||
} | } | ||||
} | } | ||||
if ($this->commitDiff === false) { | |||||
return array(); | |||||
} | |||||
if ($this->commitDiff instanceof Exception) { | if ($this->commitDiff instanceof Exception) { | ||||
$ex = $this->commitDiff; | $ex = $this->commitDiff; | ||||
$ex_class = get_class($ex); | $ex_class = get_class($ex); | ||||
$ex_message = pht('Failed to load changes: %s', $ex->getMessage()); | $ex_message = pht('Failed to load changes: %s', $ex->getMessage()); | ||||
return array( | return array( | ||||
'<'.$ex_class.'>' => $ex_message, | '<'.$ex_class.'>' => $ex_message, | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |