Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15428886
D18832.id45184.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D18832.id45184.diff
View Options
diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php
--- a/src/applications/differential/editor/DifferentialTransactionEditor.php
+++ b/src/applications/differential/editor/DifferentialTransactionEditor.php
@@ -132,12 +132,14 @@
$diff = $this->requireDiff($xaction->getNewValue());
- $object->setLineCount($diff->getLineCount());
+ $this->updateRevisionLineCounts($object, $diff);
+
if ($this->repositoryPHIDOverride !== false) {
$object->setRepositoryPHID($this->repositoryPHIDOverride);
} else {
$object->setRepositoryPHID($diff->getRepositoryPHID());
}
+
$object->attachActiveDiff($diff);
$object->setActiveDiffPHID($diff->getPHID());
return;
@@ -1645,5 +1647,25 @@
return true;
}
+ private function updateRevisionLineCounts(
+ DifferentialRevision $revision,
+ DifferentialDiff $diff) {
+
+ $revision->setLineCount($diff->getLineCount());
+
+ $conn = $revision->establishConnection('r');
+
+ $row = queryfx_one(
+ $conn,
+ 'SELECT SUM(addLines) A, SUM(delLines) D FROM %T
+ WHERE diffID = %d',
+ id(new DifferentialChangeset())->getTableName(),
+ $diff->getID());
+
+ if ($row) {
+ $revision->setAddedLineCount((int)$row['A']);
+ $revision->setRemovedLineCount((int)$row['D']);
+ }
+ }
}
diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php
--- a/src/applications/differential/storage/DifferentialRevision.php
+++ b/src/applications/differential/storage/DifferentialRevision.php
@@ -61,6 +61,8 @@
const PROPERTY_CLOSED_FROM_ACCEPTED = 'wasAcceptedBeforeClose';
const PROPERTY_DRAFT_HOLD = 'draft.hold';
const PROPERTY_HAS_BROADCAST = 'draft.broadcast';
+ const PROPERTY_LINES_ADDED = 'lines.added';
+ const PROPERTY_LINES_REMOVED = 'lines.removed';
public static function initializeNewRevision(PhabricatorUser $actor) {
$app = id(new PhabricatorApplicationQuery())
@@ -728,6 +730,21 @@
return $this->setProperty(self::PROPERTY_HAS_BROADCAST, $has_broadcast);
}
+ public function setAddedLineCount($count) {
+ return $this->setProperty(self::PROPERTY_LINES_ADDED, $count);
+ }
+
+ public function getAddedLineCount() {
+ return $this->getProperty(self::PROPERTY_LINES_ADDED);
+ }
+
+ public function setRemovedLineCount($count) {
+ return $this->setProperty(self::PROPERTY_LINES_REMOVED, $count);
+ }
+
+ public function getRemovedLineCount() {
+ return $this->getProperty(self::PROPERTY_LINES_REMOVED);
+ }
public function loadActiveBuilds(PhabricatorUser $viewer) {
$diff = $this->getActiveDiff();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 24, 11:02 PM (3 d, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7383335
Default Alt Text
D18832.id45184.diff (2 KB)
Attached To
Mode
D18832: Denormalize added and removed line counts for the current diff onto revisions
Attached
Detach File
Event Timeline
Log In to Comment