Page MenuHomePhabricator

D20836.id.diff
No OneTemporary

D20836.id.diff

diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -11,7 +11,7 @@
'conpherence.pkg.js' => '020aebcf',
'core.pkg.css' => '6a8c9533',
'core.pkg.js' => '6e5c894f',
- 'differential.pkg.css' => 'ce54994e',
+ 'differential.pkg.css' => 'abd2c0d8',
'differential.pkg.js' => '68fa36fc',
'diffusion.pkg.css' => '42c75c37',
'diffusion.pkg.js' => 'a98c0bf7',
@@ -61,7 +61,7 @@
'rsrc/css/application/dashboard/dashboard.css' => '5a205b9d',
'rsrc/css/application/diff/inline-comment-summary.css' => '81eb368d',
'rsrc/css/application/differential/add-comment.css' => '7e5900d9',
- 'rsrc/css/application/differential/changeset-view.css' => 'db306b82',
+ 'rsrc/css/application/differential/changeset-view.css' => '5dda5e53',
'rsrc/css/application/differential/core.css' => '7300a73e',
'rsrc/css/application/differential/phui-inline-comment.css' => '48acce5b',
'rsrc/css/application/differential/revision-comment.css' => '7dbc8d1d',
@@ -554,7 +554,7 @@
'conpherence-thread-manager' => 'aec8e38c',
'conpherence-transaction-css' => '3a3f5e7e',
'd3' => '9d068042',
- 'differential-changeset-view-css' => 'db306b82',
+ 'differential-changeset-view-css' => '5dda5e53',
'differential-core-view-css' => '7300a73e',
'differential-revision-add-comment-css' => '7e5900d9',
'differential-revision-comment-css' => '7dbc8d1d',
@@ -1457,6 +1457,9 @@
'javelin-dom',
'phuix-dropdown-menu',
),
+ '5dda5e53' => array(
+ 'phui-inline-comment-view-css',
+ ),
'5faf27b9' => array(
'phuix-form-control-view',
),
@@ -2069,9 +2072,6 @@
'javelin-uri',
'phabricator-notification',
),
- 'db306b82' => array(
- 'phui-inline-comment-view-css',
- ),
'dfa1d313' => array(
'javelin-behavior',
'javelin-dom',
diff --git a/src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php b/src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
--- a/src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
+++ b/src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
@@ -379,7 +379,15 @@
if ($old) {
$old_content = $old->newContentView();
$old_key = $old->getBlockKey();
- $old_classes = implode(' ', $old->getClasses());
+
+ $old_classes = $old->getClasses();
+
+ if ($old->getDifferenceType() === '-') {
+ $old_classes[] = 'old';
+ $old_classes[] = 'old-full';
+ }
+
+ $old_classes = implode(' ', $old_classes);
} else {
$old_content = null;
$old_key = null;
@@ -389,7 +397,14 @@
if ($new) {
$new_content = $new->newContentView();
$new_key = $new->getBlockKey();
- $new_classes = implode(' ', $new->getClasses());
+ $new_classes = $new->getClasses();
+
+ if ($new->getDifferenceType() === '+') {
+ $new_classes[] = 'new';
+ $new_classes[] = 'new-full';
+ }
+
+ $new_classes = implode(' ', $new_classes);
} else {
$new_content = null;
$new_key = null;
diff --git a/src/applications/files/diff/PhabricatorDocumentEngineBlock.php b/src/applications/files/diff/PhabricatorDocumentEngineBlock.php
--- a/src/applications/files/diff/PhabricatorDocumentEngineBlock.php
+++ b/src/applications/files/diff/PhabricatorDocumentEngineBlock.php
@@ -6,6 +6,8 @@
private $blockKey;
private $content;
private $classes = array();
+ private $differenceHash;
+ private $differenceType;
public function setContent($content) {
$this->content = $content;
@@ -38,4 +40,22 @@
return $this->classes;
}
+ public function setDifferenceHash($difference_hash) {
+ $this->differenceHash = $difference_hash;
+ return $this;
+ }
+
+ public function getDifferenceHash() {
+ return $this->differenceHash;
+ }
+
+ public function setDifferenceType($difference_type) {
+ $this->differenceType = $difference_type;
+ return $this;
+ }
+
+ public function getDifferenceType() {
+ return $this->differenceType;
+ }
+
}
diff --git a/src/applications/files/diff/PhabricatorDocumentEngineBlocks.php b/src/applications/files/diff/PhabricatorDocumentEngineBlocks.php
--- a/src/applications/files/diff/PhabricatorDocumentEngineBlocks.php
+++ b/src/applications/files/diff/PhabricatorDocumentEngineBlocks.php
@@ -20,28 +20,54 @@
$rows = array();
$lists = $this->lists;
- $idx = 0;
- while (true) {
- $found_any = false;
+ $specs = array();
+ foreach ($this->lists as $list) {
+ $specs[] = $this->newDiffSpec($list['blocks']);
+ }
- $row = array();
- foreach ($lists as $list) {
- $blocks = $list['blocks'];
- $cell = idx($blocks, $idx);
+ $old_map = $specs[0]['map'];
+ $new_map = $specs[1]['map'];
- if ($cell !== null) {
- $found_any = true;
- }
+ $old_list = $specs[0]['list'];
+ $new_list = $specs[1]['list'];
+
+ $changeset = id(new PhabricatorDifferenceEngine())
+ ->generateChangesetFromFileContent($old_list, $new_list);
+
+ $hunk_parser = id(new DifferentialHunkParser())
+ ->parseHunksForLineData($changeset->getHunks())
+ ->reparseHunksForSpecialAttributes();
+
+ $old_lines = $hunk_parser->getOldLines();
+ $new_lines = $hunk_parser->getNewLines();
- $row[] = $cell;
+ $rows = array();
+
+ $count = count($old_lines);
+ for ($ii = 0; $ii < $count; $ii++) {
+ $old_line = idx($old_lines, $ii);
+ $new_line = idx($new_lines, $ii);
+
+ if ($old_line) {
+ $old_hash = rtrim($old_line['text'], "\n");
+ $old_block = array_shift($old_map[$old_hash]);
+ $old_block->setDifferenceType($old_line['type']);
+ } else {
+ $old_block = null;
}
- if (!$found_any) {
- break;
+ if ($new_line) {
+ $new_hash = rtrim($new_line['text'], "\n");
+ $new_block = array_shift($new_map[$new_hash]);
+ $new_block->setDifferenceType($new_line['type']);
+ } else {
+ $new_block = null;
}
- $rows[] = $row;
- $idx++;
+ $rows[] = array(
+ $old_block,
+ $new_block,
+ );
}
return $rows;
@@ -80,4 +106,25 @@
}
+ private function newDiffSpec(array $blocks) {
+ $map = array();
+ $list = array();
+
+ foreach ($blocks as $block) {
+ $hash = $block->getDifferenceHash();
+
+ if (!isset($map[$hash])) {
+ $map[$hash] = array();
+ }
+ $map[$hash][] = $block;
+
+ $list[] = $hash;
+ }
+
+ return array(
+ 'map' => $map,
+ 'list' => implode("\n", $list)."\n",
+ );
+ }
+
}
diff --git a/src/applications/files/document/PhabricatorImageDocumentEngine.php b/src/applications/files/document/PhabricatorImageDocumentEngine.php
--- a/src/applications/files/document/PhabricatorImageDocumentEngine.php
+++ b/src/applications/files/document/PhabricatorImageDocumentEngine.php
@@ -55,9 +55,12 @@
'src' => $file->getBestURI(),
)));
+ $hash = $file->getContentHash();
+
$blocks[] = id(new PhabricatorDocumentEngineBlock())
->setBlockKey('1')
->addClass('diff-image-cell')
+ ->setDifferenceHash($hash)
->setContent($image_view);
return $blocks;
diff --git a/src/applications/files/document/PhabricatorJupyterDocumentEngine.php b/src/applications/files/document/PhabricatorJupyterDocumentEngine.php
--- a/src/applications/files/document/PhabricatorJupyterDocumentEngine.php
+++ b/src/applications/files/document/PhabricatorJupyterDocumentEngine.php
@@ -82,8 +82,13 @@
),
$notebook_table);
+ $hash = PhabricatorHash::digestWithNamedKey(
+ serialize($cell),
+ 'document-engine.content-digest');
+
$blocks[] = id(new PhabricatorDocumentEngineBlock())
->setBlockKey($idx)
+ ->setDifferenceHash($hash)
->setContent($container);
$idx++;
diff --git a/webroot/rsrc/css/application/differential/changeset-view.css b/webroot/rsrc/css/application/differential/changeset-view.css
--- a/webroot/rsrc/css/application/differential/changeset-view.css
+++ b/webroot/rsrc/css/application/differential/changeset-view.css
@@ -282,7 +282,8 @@
font-weight: bold;
}
-.differential-diff .diff-image-cell {
+.differential-diff td.diff-image-cell {
+ background-color: transparent;
background-image: url(/rsrc/image/checker_light.png);
padding: 8px;
}

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 9, 9:04 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7387052
Default Alt Text
D20836.id.diff (8 KB)

Event Timeline