Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15456108
D8764.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D8764.diff
View Options
diff --git a/src/applications/differential/storage/DifferentialHunk.php b/src/applications/differential/storage/DifferentialHunk.php
--- a/src/applications/differential/storage/DifferentialHunk.php
+++ b/src/applications/differential/storage/DifferentialHunk.php
@@ -9,6 +9,10 @@
protected $newOffset;
protected $newLen;
+ const FLAG_LINES_ADDED = 1;
+ const FLAG_LINES_REMOVED = 2;
+ const FLAG_LINES_STABLE = 4;
+
public function getAddedLines() {
return $this->makeContent($include = '+');
}
@@ -29,6 +33,26 @@
return implode('', $this->makeContent($include = '-+'));
}
+ public function getContentWithMask($mask) {
+ $include = array();
+
+ if (($mask & self::FLAG_LINES_ADDED)) {
+ $include[] = '+';
+ }
+
+ if (($mask & self::FLAG_LINES_REMOVED)) {
+ $include[] = '-';
+ }
+
+ if (($mask & self::FLAG_LINES_STABLE)) {
+ $include[] = ' ';
+ }
+
+ $include = implode('', $include);
+
+ return implode('', $this->makeContent($include));
+ }
+
final private function makeContent($include) {
$results = array();
$lines = explode("\n", $this->changes);
diff --git a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
--- a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
+++ b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
@@ -204,56 +204,21 @@
}
protected function loadContentDictionary() {
- $changesets = $this->loadChangesets();
-
- $hunks = array();
- if ($changesets) {
- $hunks = id(new DifferentialHunk())->loadAllWhere(
- 'changesetID in (%Ld)',
- mpull($changesets, 'getID'));
- }
-
- $dict = array();
- $hunks = mgroup($hunks, 'getChangesetID');
- $changesets = mpull($changesets, null, 'getID');
- foreach ($changesets as $id => $changeset) {
- $path = $this->getAbsoluteRepositoryPathForChangeset($changeset);
- $content = array();
- foreach (idx($hunks, $id, array()) as $hunk) {
- $content[] = $hunk->makeChanges();
- }
- $dict[$path] = implode("\n", $content);
- }
-
- return $dict;
+ $add_lines = DifferentialHunk::FLAG_LINES_ADDED;
+ $rem_lines = DifferentialHunk::FLAG_LINES_REMOVED;
+ $mask = ($add_lines | $rem_lines);
+ return $this->loadContentWithMask($mask);
}
protected function loadAddedContentDictionary() {
- $changesets = $this->loadChangesets();
-
- $hunks = array();
- if ($changesets) {
- $hunks = id(new DifferentialHunk())->loadAllWhere(
- 'changesetID in (%Ld)',
- mpull($changesets, 'getID'));
- }
-
- $dict = array();
- $hunks = mgroup($hunks, 'getChangesetID');
- $changesets = mpull($changesets, null, 'getID');
- foreach ($changesets as $id => $changeset) {
- $path = $this->getAbsoluteRepositoryPathForChangeset($changeset);
- $content = array();
- foreach (idx($hunks, $id, array()) as $hunk) {
- $content[] = implode('', $hunk->getAddedLines());
- }
- $dict[$path] = implode("\n", $content);
- }
-
- return $dict;
+ return $this->loadContentWithMask(DifferentialHunk::FLAG_LINES_ADDED);
}
protected function loadRemovedContentDictionary() {
+ return $this->loadContentWithMask(DifferentialHunk::FLAG_LINES_REMOVED);
+ }
+
+ private function loadContentWithMask($mask) {
$changesets = $this->loadChangesets();
$hunks = array();
@@ -270,7 +235,7 @@
$path = $this->getAbsoluteRepositoryPathForChangeset($changeset);
$content = array();
foreach (idx($hunks, $id, array()) as $hunk) {
- $content[] = implode('', $hunk->getRemovedLines());
+ $content[] = $hunk->getContentWithMask($mask);
}
$dict[$path] = implode("\n", $content);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 31, 7:09 AM (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7332819
Default Alt Text
D8764.diff (3 KB)
Attached To
Mode
D8764: Simplify Herald logic for loading Differential changes
Attached
Detach File
Event Timeline
Log In to Comment