@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Denormalize added and removed line counts for the current diff onto revisions

Summary:
See PHI230. Currently, we denormalize raw line counts onto diffs and revisions, but not added/removed line counts.

I'd like to try a `[---+ ]` sort of size hint element (see D16322 for more) as a general approach to conveying size information at a glance and see how it feels, since I think the raw size number isn't very scannable/useful and it may be a significant improvement to hint about how much of a change is throwing stuff out vs adding new stuff.

This just makes the data available without any subquerying and doesn't actually change the UI.

Test Plan:
Created a revision, saw detailed change information populate in the database.

```
mysql> select * from differential_revision where id = 292\G
*************************** 1. row ***************************
id: 292
title: WIP
originalTitle: WIP
phid: PHID-DREV-ux3cxptibn3l5pxsug3z
status: draft
summary: asdf
testPlan: asdf
authorPHID: PHID-USER-cvfydnwadpdj7vdon36z
lastReviewerPHID: NULL
lineCount: 41
dateCreated: 1513179418
dateModified: 1513179418
attached: []
mailKey: h4mn6perdio47o4beomyvu75zezwvredx3mbrlgz
branchName: NULL
viewPolicy: users
editPolicy: users
repositoryPHID: PHID-REPO-wif5lutk5gn3y6ursk4p
properties: {"lines.added":40,"lines.removed":1}
activeDiffPHID: PHID-DIFF-ixjphpunpkenqgukpmce
1 row in set (0.00 sec)
```

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D18832

+40 -1
+23 -1
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 132 132 133 133 $diff = $this->requireDiff($xaction->getNewValue()); 134 134 135 - $object->setLineCount($diff->getLineCount()); 135 + $this->updateRevisionLineCounts($object, $diff); 136 + 136 137 if ($this->repositoryPHIDOverride !== false) { 137 138 $object->setRepositoryPHID($this->repositoryPHIDOverride); 138 139 } else { 139 140 $object->setRepositoryPHID($diff->getRepositoryPHID()); 140 141 } 142 + 141 143 $object->attachActiveDiff($diff); 142 144 $object->setActiveDiffPHID($diff->getPHID()); 143 145 return; ··· 1645 1647 return true; 1646 1648 } 1647 1649 1650 + private function updateRevisionLineCounts( 1651 + DifferentialRevision $revision, 1652 + DifferentialDiff $diff) { 1653 + 1654 + $revision->setLineCount($diff->getLineCount()); 1655 + 1656 + $conn = $revision->establishConnection('r'); 1657 + 1658 + $row = queryfx_one( 1659 + $conn, 1660 + 'SELECT SUM(addLines) A, SUM(delLines) D FROM %T 1661 + WHERE diffID = %d', 1662 + id(new DifferentialChangeset())->getTableName(), 1663 + $diff->getID()); 1664 + 1665 + if ($row) { 1666 + $revision->setAddedLineCount((int)$row['A']); 1667 + $revision->setRemovedLineCount((int)$row['D']); 1668 + } 1669 + } 1648 1670 1649 1671 }
+17
src/applications/differential/storage/DifferentialRevision.php
··· 61 61 const PROPERTY_CLOSED_FROM_ACCEPTED = 'wasAcceptedBeforeClose'; 62 62 const PROPERTY_DRAFT_HOLD = 'draft.hold'; 63 63 const PROPERTY_HAS_BROADCAST = 'draft.broadcast'; 64 + const PROPERTY_LINES_ADDED = 'lines.added'; 65 + const PROPERTY_LINES_REMOVED = 'lines.removed'; 64 66 65 67 public static function initializeNewRevision(PhabricatorUser $actor) { 66 68 $app = id(new PhabricatorApplicationQuery()) ··· 728 730 return $this->setProperty(self::PROPERTY_HAS_BROADCAST, $has_broadcast); 729 731 } 730 732 733 + public function setAddedLineCount($count) { 734 + return $this->setProperty(self::PROPERTY_LINES_ADDED, $count); 735 + } 736 + 737 + public function getAddedLineCount() { 738 + return $this->getProperty(self::PROPERTY_LINES_ADDED); 739 + } 740 + 741 + public function setRemovedLineCount($count) { 742 + return $this->setProperty(self::PROPERTY_LINES_REMOVED, $count); 743 + } 744 + 745 + public function getRemovedLineCount() { 746 + return $this->getProperty(self::PROPERTY_LINES_REMOVED); 747 + } 731 748 732 749 public function loadActiveBuilds(PhabricatorUser $viewer) { 733 750 $diff = $this->getActiveDiff();