Page MenuHomePhabricator

D21670.id51571.diff
No OneTemporary

D21670.id51571.diff

diff --git a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
--- a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
+++ b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php
@@ -216,13 +216,7 @@
$event->setRejectCode($this->rejectCode);
$event->setRejectDetails($this->rejectDetails);
- $event->openTransaction();
- $event->save();
- foreach ($all_updates as $update) {
- $update->setPushEventPHID($event->getPHID());
- $update->save();
- }
- $event->saveTransaction();
+ $event->saveWithLogs($all_updates);
if ($caught) {
throw $caught;
diff --git a/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php b/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php
--- a/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php
+++ b/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php
@@ -901,4 +901,41 @@
new PhutilNumber($duration)));
}
+ public function newMaintenanceEvent() {
+ $viewer = $this->getViewer();
+ $repository = $this->getRepository();
+ $now = PhabricatorTime::getNow();
+
+ $event = PhabricatorRepositoryPushEvent::initializeNewEvent($viewer)
+ ->setRepositoryPHID($repository->getPHID())
+ ->setEpoch($now)
+ ->setPusherPHID($this->getEffectiveActingAsPHID())
+ ->setRejectCode(PhabricatorRepositoryPushLog::REJECT_ACCEPT);
+
+ return $event;
+ }
+
+ public function newMaintenanceLog() {
+ $viewer = $this->getViewer();
+ $repository = $this->getRepository();
+ $now = PhabricatorTime::getNow();
+
+ $device = AlmanacKeys::getLiveDevice();
+ if ($device) {
+ $device_phid = $device->getPHID();
+ } else {
+ $device_phid = null;
+ }
+
+ return PhabricatorRepositoryPushLog::initializeNewLog($viewer)
+ ->setDevicePHID($device_phid)
+ ->setRepositoryPHID($repository->getPHID())
+ ->attachRepository($repository)
+ ->setEpoch($now)
+ ->setPusherPHID($this->getEffectiveActingAsPHID())
+ ->setChangeFlags(PhabricatorRepositoryPushLog::CHANGEFLAG_MAINTENANCE)
+ ->setRefType(PhabricatorRepositoryPushLog::REFTYPE_MAINTENANCE)
+ ->setRefNew('');
+ }
+
}
diff --git a/src/applications/repository/storage/PhabricatorRepositoryPushEvent.php b/src/applications/repository/storage/PhabricatorRepositoryPushEvent.php
--- a/src/applications/repository/storage/PhabricatorRepositoryPushEvent.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryPushEvent.php
@@ -81,6 +81,21 @@
return $this->assertAttached($this->logs);
}
+ public function saveWithLogs(array $logs) {
+ assert_instances_of($logs, 'PhabricatorRepositoryPushLog');
+
+ $this->openTransaction();
+ $this->save();
+ foreach ($logs as $log) {
+ $log->setPushEventPHID($this->getPHID());
+ $log->save();
+ }
+ $this->saveTransaction();
+
+ $this->attachLogs($logs);
+
+ return $this;
+ }
/* -( PhabricatorPolicyInterface )----------------------------------------- */
diff --git a/src/applications/repository/storage/PhabricatorRepositoryPushLog.php b/src/applications/repository/storage/PhabricatorRepositoryPushLog.php
--- a/src/applications/repository/storage/PhabricatorRepositoryPushLog.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryPushLog.php
@@ -18,6 +18,7 @@
const REFTYPE_BOOKMARK = 'bookmark';
const REFTYPE_COMMIT = 'commit';
const REFTYPE_REF = 'ref';
+ const REFTYPE_MAINTENANCE = 'maintenance';
const CHANGEFLAG_ADD = 1;
const CHANGEFLAG_DELETE = 2;
@@ -27,6 +28,7 @@
const CHANGEFLAG_ENORMOUS = 32;
const CHANGEFLAG_OVERSIZED = 64;
const CHANGEFLAG_TOUCHES = 128;
+ const CHANGEFLAG_MAINTENANCE = 256;
const REJECT_ACCEPT = 0;
const REJECT_DANGEROUS = 1;
@@ -70,6 +72,7 @@
self::CHANGEFLAG_ENORMOUS => pht('Enormous'),
self::CHANGEFLAG_OVERSIZED => pht('Oversized'),
self::CHANGEFLAG_TOUCHES => pht('Touches Too Many Paths'),
+ self::CHANGEFLAG_MAINTENANCE => pht('Maintenance'),
);
}

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 15, 10:01 AM (11 h, 34 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6992099
Default Alt Text
D21670.id51571.diff (4 KB)

Event Timeline