diff --git a/resources/sql/autopatches/20160418.repoversion.1.sql b/resources/sql/autopatches/20160418.repoversion.1.sql new file mode 100644 index 0000000000..e80e4322d0 --- /dev/null +++ b/resources/sql/autopatches/20160418.repoversion.1.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_repository.repository_workingcopyversion + ADD writeProperties LONGTEXT COLLATE {$COLLATE_TEXT}; diff --git a/src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php b/src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php index 9babe3ebb1..f5e314f462 100644 --- a/src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php +++ b/src/applications/diffusion/ssh/DiffusionGitReceivePackSSHWorkflow.php @@ -26,7 +26,8 @@ final class DiffusionGitReceivePackSSHWorkflow extends DiffusionGitSSHWorkflow { $command = csprintf('git-receive-pack %s', $repository->getLocalPath()); $did_synchronize = true; - $repository->synchronizeWorkingCopyBeforeWrite(); + $viewer = $this->getUser(); + $repository->synchronizeWorkingCopyBeforeWrite($viewer); } $caught = null; diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php index ee7f6b6bb6..fa13395e28 100644 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -2482,7 +2482,8 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO /** * @task sync */ - public function synchronizeWorkingCopyBeforeWrite() { + public function synchronizeWorkingCopyBeforeWrite( + PhabricatorUser $actor) { if (!$this->shouldEnableSynchronization()) { return; } @@ -2516,7 +2517,12 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO PhabricatorRepositoryWorkingCopyVersion::willWrite( $repository_phid, - $device_phid); + $device_phid, + array( + 'userPHID' => $actor->getPHID(), + 'epoch' => PhabricatorTime::getNow(), + 'devicePHID' => $device_phid, + )); $this->clusterWriteVersion = $max_version; $this->clusterWriteLock = $write_lock; diff --git a/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php b/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php index 1b1150f8cd..888301e807 100644 --- a/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php +++ b/src/applications/repository/storage/PhabricatorRepositoryWorkingCopyVersion.php @@ -7,6 +7,7 @@ final class PhabricatorRepositoryWorkingCopyVersion protected $devicePHID; protected $repositoryVersion; protected $isWriting; + protected $writeProperties; protected function getConfiguration() { return array( @@ -14,6 +15,7 @@ final class PhabricatorRepositoryWorkingCopyVersion self::CONFIG_COLUMN_SCHEMA => array( 'repositoryVersion' => 'uint32', 'isWriting' => 'bool', + 'writeProperties' => 'text?', ), self::CONFIG_KEY_SCHEMA => array( 'key_workingcopy' => array( @@ -66,7 +68,10 @@ final class PhabricatorRepositoryWorkingCopyVersion * lock is released by default. This is a durable lock which stays locked * by default. */ - public static function willWrite($repository_phid, $device_phid) { + public static function willWrite( + $repository_phid, + $device_phid, + array $write_properties) { $version = new self(); $conn_w = $version->establishConnection('w'); $table = $version->getTableName(); @@ -74,16 +79,19 @@ final class PhabricatorRepositoryWorkingCopyVersion queryfx( $conn_w, 'INSERT INTO %T - (repositoryPHID, devicePHID, repositoryVersion, isWriting) + (repositoryPHID, devicePHID, repositoryVersion, isWriting, + writeProperties) VALUES - (%s, %s, %d, %d) + (%s, %s, %d, %d, %s) ON DUPLICATE KEY UPDATE - isWriting = VALUES(isWriting)', + isWriting = VALUES(isWriting), + writeProperties = VALUES(writeProperties)', $table, $repository_phid, $device_phid, 0, - 1); + 1, + phutil_json_encode($write_properties)); } @@ -101,7 +109,10 @@ final class PhabricatorRepositoryWorkingCopyVersion queryfx( $conn_w, - 'UPDATE %T SET repositoryVersion = %d, isWriting = 0 + 'UPDATE %T SET + repositoryVersion = %d, + isWriting = 0, + writeProperties = null WHERE repositoryPHID = %s AND devicePHID = %s AND