Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/storage/DifferentialRevision.php
Show First 20 Lines • Show All 736 Lines • ▼ Show 20 Lines | /* -( PhabricatorTokenReceiverInterface )---------------------------------- */ | ||||
public function setRemovedLineCount($count) { | public function setRemovedLineCount($count) { | ||||
return $this->setProperty(self::PROPERTY_LINES_REMOVED, $count); | return $this->setProperty(self::PROPERTY_LINES_REMOVED, $count); | ||||
} | } | ||||
public function getRemovedLineCount() { | public function getRemovedLineCount() { | ||||
return $this->getProperty(self::PROPERTY_LINES_REMOVED); | return $this->getProperty(self::PROPERTY_LINES_REMOVED); | ||||
} | } | ||||
public function getRevisionScaleGlyphs() { | |||||
$add = $this->getAddedLineCount(); | |||||
$rem = $this->getRemovedLineCount(); | |||||
$all = ($add + $rem); | |||||
if (!$all) { | |||||
return ' '; | |||||
} | |||||
$map = array( | |||||
20 => 2, | |||||
50 => 3, | |||||
150 => 4, | |||||
375 => 5, | |||||
1000 => 6, | |||||
2500 => 7, | |||||
); | |||||
$n = 1; | |||||
foreach ($map as $size => $count) { | |||||
if ($size <= $all) { | |||||
$n = $count; | |||||
} else { | |||||
break; | |||||
} | |||||
} | |||||
$add_n = (int)ceil(($add / $all) * $n); | |||||
$rem_n = (int)ceil(($rem / $all) * $n); | |||||
while ($add_n + $rem_n > $n) { | |||||
if ($add_n > 1) { | |||||
$add_n--; | |||||
} else { | |||||
$rem_n--; | |||||
} | |||||
} | |||||
return | |||||
str_repeat('+', $add_n). | |||||
str_repeat('-', $rem_n). | |||||
str_repeat(' ', (7 - $n)); | |||||
} | |||||
public function getBuildableStatus($phid) { | public function getBuildableStatus($phid) { | ||||
$buildables = $this->getProperty(self::PROPERTY_BUILDABLES); | $buildables = $this->getProperty(self::PROPERTY_BUILDABLES); | ||||
if (!is_array($buildables)) { | if (!is_array($buildables)) { | ||||
$buildables = array(); | $buildables = array(); | ||||
} | } | ||||
$buildable = idx($buildables, $phid); | $buildable = idx($buildables, $phid); | ||||
if (!is_array($buildable)) { | if (!is_array($buildable)) { | ||||
▲ Show 20 Lines • Show All 386 Lines • Show Last 20 Lines |