@since 0.3

@param Revision $revision

@return bool success
7224
public function patrol( Revision $revision ) {
		$this->api->postRequest( new SimpleRequest(
			'patrol', [
				'revid' => $revision->getId(),
				'token' => $this->getTokenForRevision( $revision ),
			] ) );
		return true;
	}
879059
public function getConfigRevisionLimit() {
        $default = Config::get('revisionable.revisions.limit');
        if(is_null($this->revisionLimit)) {
            // the parameter is not set - default behaviour is to create revisions
            return $default;
        }

        if(! is_numeric($this->revisionLimit)) {
            return $default;
        }

        return $this->revisionLimit;
    }
398058
public function getAction(Revision $revision)
    {
        $this->granted('VIEW', $revision->getContent());

        $response = $this->createJsonResponse();
        $response->setData($revision->jsonSerialize(Revision::JSON_REVISION_FORMAT));

        return $response;
    }
1339540
protected function taskUpdateSourceCode($branch, $revision = '')
    {
        $repo   = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_GIT_URL);
        $gitDir = $this->config(Config::KEY_DEPLOY . '/' . Config::KEY_GIT_DIR);
        $gitBin = $this->config(Config::KEY_ENV . '/' . Config::KEY_GIT_BIN);

        /** @var RoboFile|CollectionBuilder $collection */
        $collection = $this->collectionBuilder();

        $isFirstRun = !is_dir($gitDir);
        if ($isFirstRun) {
            // Clone git Repo
            $cloneRepo = $this->taskGitStack($gitBin)->cloneRepo($repo, $gitDir);
            $cloneRepo->run();
        }

        // Fetch origin
        $collection->taskGitStack($gitBin)->dir($gitDir)->exec(['fetch', '-vp', 'origin']);

        // parse the revision from the parameter if set
        if (\strpos($branch, '@') !== false) {
            [$branch, $revision] = explode('@', $branch);
        }

        // Detect if tag or branch
        $isTag = $this->isTag($branch);

        // Checkout branch or tag
        $collection->taskGitStack($gitBin)->dir($gitDir)->exec(['checkout', '-f', $branch]);

        // Reset to origin Branch / Tag
        $resetTo = $isTag ? $branch : "origin/$branch";

        $collection->taskGitStack($gitBin)->dir($gitDir)->exec(['reset', '--hard', $resetTo]);

        if (!empty($revision)) {
            // checkout exact commit hash
            $collection->taskGitStack($gitBin)->dir($gitDir)->exec(['checkout', $revision]);
        }

        $collection->taskGitStack($gitBin)->dir($gitDir)->exec(['status']);

        return $collection;
    }
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));
    }
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);
    }
645758
public function changelog($revision1, $revision2)
    {
        return $this->execute('log', array(
                '-r' => sprintf('%s:%s', $revision2, $revision1),
                '--xml' => true,
                $this->getSvnUrl($this->getHead())
            )
        );
    }
127378
def restore_revision(id, revision_number)
      revision_record = revision(id, revision_number)
      return revision_record.restore if revision_record
    end
1340073
public function restore(Revision $revision) {
        $resourceId = $revision->getResourceId();
        $data = $this->getStorage()->getData($revision);

        $resource = new \core_kernel_classes_Resource($resourceId);
        $originFilesystemMap = CloneHelper::getPropertyStorageMap($resource->getRdfTriples());
        DeleteHelper::deepDelete($resource);

        foreach (CloneHelper::deepCloneTriples($data, $originFilesystemMap) as $triple) {
            ModelManager::getModel()->getRdfInterface()->add($triple);
        }

        return true;
    }
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'];
	}
132084
public function setStagedRevision(Revision $revision)
    {
        if (!empty($this->publishedRevision)
            && $this->publishedRevision->getRevisionId() == $revision->getRevisionId()
        ) {
            $this->removePublishedRevision();
        }

        $this->stagedRevision = $revision;
        $this->stagedRevisionId = $revision->getRevisionId();
    }
169867
public function loadSubcontents(Revision $revision)
    {
        $content = $revision->getContent();
        if ($content instanceof ContentSet) {
            while ($subcontent = $revision->next()) {
                if (!($subcontent instanceof AbstractClassContent)) {
                    continue;
                }

                if ($this->_em->contains($subcontent)) {
                    continue;
                }

                $subcontent = $this->_em->find(get_class($subcontent), $subcontent->getUid());
            }
        } else {
            foreach ($revision->getData() as $key => $value) {
                if (is_array($value)) {
                    foreach ($value as &$val) {
                        if ($val instanceof AbstractClassContent) {
                            if (null !== $entity = $this->_em->find(get_class($val), $val->getUid())) {
                                $val = $entity;
                            }
                        }
                    }

                    unset($val);
                } elseif ($value instanceof AbstractClassContent) {
                    if (null !== $entity = $this->_em->find(get_class($value), $value->getUid())) {
                        $value = $entity;
                    }
                }

                $revision->$key = $value;
            }
        }

        return $revision;
    }
1254108
public function getCanonicalTitle($revision = null)
	{
		// Without revision, use current info
		if (!isset($revision)) {
			return $this->info['canonicaltitle'];
		}

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

		return $info['canonicaltitle'];
	}
957824
public function revert(&$entity, $revision)
    {
        /** @var ClassMetadataInfo $meta */
        $meta = $this->getClassMetadata(get_class($entity));

        $data = $this->getRevisionData($entity, ['revision_id = :revisionId'], ['revisionId' => $revision], 1);

        /** @var \ReflectionProperty[] $revisedProperties */
        $revisedProperties = $this->annotationReader->getRevisedProperties($entity);

        $exception = null;
        foreach ($revisedProperties as $field => $property) {
            if (! key_exists($field, $revisedProperties)) {
                continue;
            }

            if (isset($meta->fieldMappings[$field])) {
                $columnName = $meta->fieldMappings[$field]['columnName'];
            } elseif (isset($meta->associationMappings[$field])) {
                $columnName = $meta->associationMappings[$field]['joinColumns'][0]['name'];
            } else {
                throw new \Exception('Cannot find column name for' . $field);
            }

            $value = $data[$columnName];

            $property = $meta->getReflectionProperty($field);
            $property->setValue($entity, $value);

            if ($field == 'deletedAt' && $value !== null) {
                $exception = new DeletedException('Entity is deleted in this revision');
            }
        }

        if ($exception) {
            $exception->setEntity($entity);
            throw $exception;
        }

        return $entity;
    }
1196856
public function update(Revision $revision)
    {
        switch ($revision->getState()) {
            case Revision::STATE_ADDED:
                throw new ClassContentException('Content is not versioned yet', ClassContentException::REVISION_ADDED);
                break;

            case Revision::STATE_MODIFIED:
                try {
                    $this->checkContent($revision);
                    throw new ClassContentException(
                        'Content is already up-to-date',
                        ClassContentException::REVISION_UPTODATE
                    );
                } catch (ClassContentException $e) {
                    if (ClassContentException::REVISION_OUTOFDATE == $e->getCode()) {
                        return $this->loadSubcontents($revision);
                    } else {
                        throw $e;
                    }
                }
                break;

            case Revision::STATE_CONFLICTED:
                throw new ClassContentException(
                    'Content is in conflict, resolve or revert it',
                    ClassContentException::REVISION_CONFLICTED
                );
                break;
        }

        throw new ClassContentException('Content is already up-to-date', ClassContentException::REVISION_UPTODATE);
    }
199972
public function revisionAction()
    {
        $revisionId = (int)$this->getEvent()->getRouteMatch()->getParam('revisionId');

        $revision = \SoliantEntityAudit\Module::getModuleOptions()->getEntityManager()
            ->getRepository('SoliantEntityAudit\\Entity\\Revision')
            ->find($revisionId);

        if (!$revision)
            return $this->plugin('redirect')->toRoute('audit');

        return array(
            'revision' => $revision,
        );
    }
858692
private function getTokenForRevision( Revision $revision ) {
		$result = $this->api->postRequest(
			new SimpleRequest(
				'query', [
				'prop' => 'revisions',
				'revids' => $revision->getId(),
				'rvtoken' => 'rollback',
			]
			)
		);
		$result = array_shift( $result['query']['pages'] );

		return $result['revisions'][0]['rollbacktoken'];
	}