@since 0.5

@param Revision $revision

@return bool
345768
public function restore( Revision $revision ) {
		$params = [
			'type' => 'revision',
			'show' => 'content',
			// Note: pre 1.24 this is a delete token, post it is csrf
			'token' => $this->api->getToken( 'delete' ),
			'ids' => $revision->getId(),
		];

		$this->api->postRequest( new SimpleRequest(
			'revisiondelete',
			$params
		) );

		return true;
	}
4375
public function hydrate($puppetModules, $revision)
    {
        if ($revision->hasGroups()) {
            foreach ($revision->getGroups() as $group) {
                $this->groupHydrator->hydrate($puppetModules, $group);
            }
        }
    }
1094135
public function deleteFromRevision( Revision $revision, array $extraParams = [] ) {
		$this->api->postRequest( new SimpleRequest(
			'delete',
			$this->getDeleteParams( $revision->getPageIdentifier(), $extraParams )
		) );
		return true;
	}
1175640
public function getCommitsSince(string $revision) : array
    {
        $cmd = (new Commits($this->repo->getRoot()))->byRevision($revision)
                                                    ->prettyFormat(Commits\Jsonized::FORMAT);

        $result = $this->runner->run($cmd, new Commits\Jsonized());
        return $result->getFormattedOutput();
    }
896644
public function restore($file, $revision)
    {
        $call = 'restore/' . $this->root . '/' . $this->encodePath($file);
        $params = array('rev' => $revision);
        $response = $this->fetch('POST', self::API_URL, $call, $params);
        return $response;
    }
1183424
public function save( Revision $revision, EditInfo $editInfo = null ) {
		if( !$revision->getContent()->getData() instanceof EntityDocument ) {
			throw new RuntimeException( 'Can only save Content of EntityDocuments' );
		}

		/** @var Item|Property $entity */
		$entity = $revision->getContent()->getData();
		$serialized = $this->entitySerializer->serialize( $entity );

		$params = array(
			'data' => json_encode( $serialized )
		);

		$revId = $revision->getId();
		if( !is_null( $revId ) ) {
			$params['baserevid'] = $revId;
		}

		$entityId = $entity->getId();
		if( !is_null( $entityId ) ) {
			$params['id'] = $entityId->getSerialization();

			// Always clear so that removing elements is possible
			$params['clear'] = 'true';
			// Add more detail to the default "Cleared an entity" summary
			// Note: this is later overridden if a summary is provided in the EditInfo
			$params['summary'] = 'Edited a ' . $entity->getType();

		} else {
			$params['new'] = $entity->getType();
		}

		// If no editInfo is explicitly passed call back to the one in the revision?
		if( $editInfo === null ) {
			$editInfo = $revision->getEditInfo();
		}

		if( $editInfo->getBot() ) {
			$params['bot'] = true;
		}
		if( $editInfo->getMinor() ) {
			$params['minor'] = true;
		}
		$summary = $editInfo->getSummary();
		if( !empty( $summary ) ) {
			$params['summary'] = $summary;
		}

		$result = $this->api->postRequest( 'wbeditentity', $params, $editInfo );
		return $this->entityDeserializer->deserialize( $result['entity'] );
	}
1172336
def _get_revision(self):
        
        assert self._revisions, "no migration revision exist"
        revision = self._rev or self._revisions[-1]
        # revision count must be less or equal since revisions are ordered
        assert revision in self._revisions, "invalid revision specified"
        return revision
144570
protected function log($action, $revisioned)
    {
        if(! $revisioned->getConfigRevisionForModel()) {
            return;
        }

        $old = $new = [];

        switch ($action) {
            case 'created':
                $new = $revisioned->getNewAttributes();
                break;
            case 'deleted':
                $old = $revisioned->getOldAttributes();
                break;
            case 'updated':
                $old = $revisioned->getOldAttributes();
                $new = $revisioned->getNewAttributes();
                break;
        }

        $revisioned->revisions()->create([
            'action' => $action,
            'table_name' => $revisioned->getTable(),

            'user_id' => $this->userProvider->getUserId(),

            'old' => json_encode($old),
            'new' => json_encode($new),

            'ip' => data_get($_SERVER, 'REMOTE_ADDR'),
            'ip_forwarded' => data_get($_SERVER, 'HTTP_X_FORWARDED_FOR'),
        ]);

        // check if we need to cleanup old revisions
        if($revisioned->getConfigRevisionLimitCleanup()) {
            // we need to cleanup
            if($revisioned->revisions()->count() > $revisioned->getConfigRevisionLimit()) {
                // we currently have more revisions than we want to have
                $diff = $revisioned->revisions()->count() - $revisioned->getConfigRevisionLimit();
                // we need to delete the oldest N revisions
                $revsToDelete = $revisioned->revisions()->get()->reverse()->take($diff);
                foreach($revsToDelete as $rev) {
                    Revision::destroy($rev->id);
                }
            }
        }
    }
458630
private function checkContent(Revision $revision)
    {
        $content = $revision->getContent();

        if (null === $content || !($content instanceof AbstractClassContent)) {
            $this->_em->remove($revision);
            throw new ClassContentException('Orphan revision, deleted', ClassContentException::REVISION_ORPHAN);
        }

        if ($revision->getRevision() != $content->getRevision()) {
            throw new ClassContentException('Content is out of date', ClassContentException::REVISION_OUTOFDATE);
        }

        return $content;
    }
835160
protected function updateEntityRevision(Entity $entity, $revision, FormData $requestData) {
    $this->setRevisionMetadata($revision);
    
    $this->beginTransaction();
    
    // validiert und processed die daten aus requestData und setzt diese im Entity
    $this->processEntityFormRequest($entity, $requestData, $revision);

    $this->repository->save($entity);
    
    $this->commitTransaction();
    
    $this->setEntityResponseMetadata($entity);
    
    return $entity;
  }
1093467
public function sanitizePermissionsValue($permissions, $revision)
    {
        if (is_array($permissions)) {
            $legacyOptions = ['print' => 4, 'modify' => 8, 'copy' => 16, 'annot-forms' => 32];
            foreach ($permissions as $key => $value) {
                if (isset($legacyOptions[$value])) {
                    $permissions[$key] = $legacyOptions[$value];
                } elseif (!is_int($value)) {
                    throw new \InvalidArgumentException(
                        sprintf('Invalid permission value: %s', $value)
                    );
                }
            }

            $permissions = array_sum($permissions);
        }

        $permissions = (int)$permissions;

        $allowed = self::PERM_PRINT
            | self::PERM_MODIFY
            | self::PERM_COPY
            | self::PERM_ANNOT;

        if ($revision > 2) {
            $allowed |= self::PERM_FILL_FORM
                | self::PERM_ACCESSIBILITY
                | self::PERM_ASSEMBLE
                | self::PERM_DIGITAL_PRINT;
        }

        if (($allowed & $permissions) !== $permissions) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Permission flags (%s) are not allowed for this security handler revision %s.',
                    $permissions,
                    $revision
                )
            );
        }

        $permissions = 61632 | 0xFFFF0000 | $permissions;
        if ($revision < 3) {
            // 3840 = bit 9 to 12 to 1 - we are < revision 3
            $permissions |= 3840;
        }

        // PDF integer are 32 bit integers. Ensure this.
        if (PHP_INT_SIZE === 4 || ($permissions) < (2147483647)) {
            return $permissions;
        }

        return ($permissions | (4294967295 << 32));
    }
323028
public function revisions(string $from, string $to): Compare
    {
        $this->compare = escapeshellarg($from) . ' ' . escapeshellarg($to);
        return $this;
    }
182140
public function remove(RevisionInterface $revision)
    {
        $connection = $this->revisionRepository->getDbAdapter()->getDriver()->getConnection()->beginTransaction();
        try {
            $this->revisionRepository->remove($revision);
            if ($revision->getReleasedAt() == null) {
                $lastReleasedRevision = $revision->getEnvironment()->getLastReleasedRevision();
                $this->revisionRepository->add(clone $lastReleasedRevision);
            }
        } catch (ExceptionInterface $e) {
            $connection->rollback();
            throw $e;
        }
        $connection->commit();
        return $this;
    }
132084
public function setStagedRevision(Revision $revision)
    {
        if (!empty($this->publishedRevision)
            && $this->publishedRevision->getRevisionId() == $revision->getRevisionId()
        ) {
            $this->removePublishedRevision();
        }

        $this->stagedRevision = $revision;
        $this->stagedRevisionId = $revision->getRevisionId();
    }
980672
public function checkout(CheckedOutRepository $sourceRepository, Revision $revision) : CheckedOutRepository
    {
        $checkoutDirectory = $this->generateTemporaryPathFor($revision);

        (new Process(['git', 'clone', $sourceRepository, $checkoutDirectory]))->mustRun();
        (new Process(['git', 'checkout', $revision]))->setWorkingDirectory($checkoutDirectory)->mustRun();

        return CheckedOutRepository::fromPath($checkoutDirectory);
    }
861566
public function hasVersionMigrated(Version $version)
    {
        $this->createMigrationCollection();

        $record = $this->getCollection()->findOne(['v' => $version->getVersion()]);

        return null !== $record;
    }
350293
public function getTimestamp($revision = null)
	{
		// Without revision, use current info
		if (!isset($revision)) {
			return $this->info['timestamp'];
		}

		// Obtain the properties of the revision
		if (($info = $this->getRevision($revision)) === null) {
			return null;
		}

		return $info['timestamp'];
	}