Page MenuHomePhabricator

D19445.diff
No OneTemporary

D19445.diff

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
@@ -682,8 +682,13 @@
if ($config_inline || $config_attach) {
$body_limit = PhabricatorEnv::getEnvConfig('metamta.email-body-limit');
- $patch = $this->buildPatchForMail($diff);
- if ($config_inline) {
+ try {
+ $patch = $this->buildPatchForMail($diff, $body_limit);
+ } catch (ArcanistDiffByteSizeException $ex) {
+ $patch = null;
+ }
+
+ if (($patch !== null) && $config_inline) {
$lines = substr_count($patch, "\n");
$bytes = strlen($patch);
@@ -706,7 +711,7 @@
}
}
- if ($config_attach) {
+ if (($patch !== null) && $config_attach) {
// See T12033, T11767, and PHI55. This is a crude fix to stop the
// major concrete problems that lackluster email size limits cause.
if (strlen($patch) < $body_limit) {
@@ -1411,13 +1416,14 @@
array('style' => 'font-family: monospace;'), $patch);
}
- private function buildPatchForMail(DifferentialDiff $diff) {
+ private function buildPatchForMail(DifferentialDiff $diff, $byte_limit) {
$format = PhabricatorEnv::getEnvConfig('metamta.differential.patch-format');
return id(new DifferentialRawDiffRenderer())
->setViewer($this->getActor())
->setFormat($format)
->setChangesets($diff->getChangesets())
+ ->setByteLimit($byte_limit)
->buildPatch();
}
diff --git a/src/applications/differential/render/DifferentialRawDiffRenderer.php b/src/applications/differential/render/DifferentialRawDiffRenderer.php
--- a/src/applications/differential/render/DifferentialRawDiffRenderer.php
+++ b/src/applications/differential/render/DifferentialRawDiffRenderer.php
@@ -5,6 +5,7 @@
private $changesets;
private $format = 'unified';
private $viewer;
+ private $byteLimit;
public function setFormat($format) {
$this->format = $format;
@@ -35,6 +36,15 @@
return $this->viewer;
}
+ public function setByteLimit($byte_limit) {
+ $this->byteLimit = $byte_limit;
+ return $this;
+ }
+
+ public function getByteLimit() {
+ return $this->byteLimit;
+ }
+
public function buildPatch() {
$diff = new DifferentialDiff();
$diff->attachChangesets($this->getChangesets());
@@ -52,15 +62,18 @@
$bundle = ArcanistBundle::newFromChanges($changes);
$bundle->setLoadFileDataCallback(array($loader, 'loadFileData'));
+ $byte_limit = $this->getByteLimit();
+ if ($byte_limit) {
+ $bundle->setByteLimit($byte_limit);
+ }
+
$format = $this->getFormat();
switch ($format) {
case 'git':
return $bundle->toGitPatch();
- break;
case 'unified':
default:
return $bundle->toUnifiedDiff();
- break;
}
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 24, 2:31 PM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7708703
Default Alt Text
D19445.diff (3 KB)

Event Timeline