Revert the draft changes: replace the draft content with the content on live

User code should call {@see canRevertToLive()} prior to invoking this method.

@return bool True if the revert was successful
359637
public function doRevertToLive()
    {
        $owner = $this->owner;
        $owner->invokeWithExtensions('onBeforeRevertToLive');
        $owner->rollbackRecursive(static::LIVE);
        $owner->invokeWithExtensions('onAfterRevertToLive');
        return true;
    }
978932
public function unsetDone() {
        $migration = $this->getMigration();
        if (!$migration['state']) {
            return true; //alredy undone
        }
        $this->db()->update($this->table, array('state' => false), array('id' => $migration['id']));
    }
1047632
public function rollBackTransaction(): bool
	{
		if($this->transactionNestingLevel > 0)
		{
			if($this->transactionNestingLevel > 1)
			{
				$success = $this->rollBackSavepoint();
			}
			else
			{
				$success =  $this->pdo->rollBack();
			}

			$this->transactionNestingLevel--;

			return $success;
		}

		return false;
	}
758608
public boolean revert() {
        try {
            setWrongValueMessage(null);
            setValue(propInfo.getPropertyValue(target));
            updateValue();
            return true;
        } catch (Exception e) {
            setWrongValueException(e);
            return false;
        }
    }
288199
protected function process_revert_to_draft($userid = 0) {
        require_sesskey();

        if (!$userid) {
            $userid = required_param('userid', PARAM_INT);
        }

        return $this->revert_to_draft($userid);
    }
773970
public function isOnDraft()
    {
        $id = $this->owner->ID ?: $this->owner->OldID;
        if (!$id) {
            return false;
        }
        if (!$this->hasStages()) {
            return true;
        }

        $draftVersion = static::get_versionnumber_by_stage($this->owner, Versioned::DRAFT, $id);
        return (bool)$draftVersion;
    }
77936
public function doRestoreToStage()
    {
        $this->invokeWithExtensions('onBeforeRestoreToStage', $this);

        // Ensure that the parent page is restored, otherwise restore to root
        if ($this->isParentArchived()) {
            $this->ParentID = 0;
        }

        // Restore
        $this->writeToStage(Versioned::DRAFT);

        // Need to update pages linking to this one as no longer broken
        /** @var SiteTree $result */
        $result = Versioned::get_by_stage(self::class, Versioned::DRAFT)
            ->byID($this->ID);
        $result->updateDependentPages();

        $this->invokeWithExtensions('onAfterRestoreToStage', $result);

        return $result;
    }
713342
public function edit()
    {
        // Validate form
        $form = $this->getForm('Edit' . $this->getEntityName());
        if (!$form->isValid()) {
            return false;
        }

        // Update account
        $now    = new \DateTime();
        $entity = $form->getData();
        $entity->setLastModified($now);

        // Trigger onedit
        $this->onEdit($entity);

        // Save
        return $this->save($this->getEntityName() . ' saved.', 'Unable to save ' . strtolower($this->getEntityName()) . '.');
    }
399246
def revert
      options= {:class => "btn btn-mini btn-danger", form_class: "pull-right"}
      @version = PaperTrail::Version.find(params[:id])
      if @version.reify
        @version.reify.save!
      else
        @version.item.destroy
      end
      if params[:redo] == "true"
        link_name =  I18n.t("reverter.links.undo")
        flash_path = "reverter.flash.redo.one"
      else
        link_name =  I18n.t("reverter.links.redo")
        flash_path = "reverter.flash.undo.one"
      end
      if @version.next.nil?
        redirect_to :back, :notice => I18n.t(flash_path, verb: @version.event, link: "")
      else
        link = view_context.button_to(link_name, revert_version_path(@version.next, :redo => !params[:redo]), options)
        redirect_to :back, :notice => I18n.t(flash_path, verb: @version.event, link: link)
      end
      
    end
41407
def revert(self, unchanged=False):
        
        cmd = ['revert']
        if unchanged:
            cmd.append('-a')

        wasadd = self.action == 'add'

        cmd.append(self.depotFile)

        self._connection.run(cmd)

        if 'movedFile' in self._p4dict:
            self._p4dict['depotFile'] = self._p4dict['movedFile']

        if not wasadd:
            self.query()

        if self._changelist:
            self._changelist.remove(self, permanent=True)
307511
public function performReadonlyTransformation()
    {
        $field = $this;

        if (!$this->readonly) {
            $field = parent::performReadonlyTransformation();

            $field->setTemplate(CompositeField::class);
            $field->setTitle('Title');

            $field->replaceField('Title', LiteralField::create(
                'Title',
                $field->fieldByName('Title')->Value()
            ));

            $displayedText = _t(__CLASS__ . '.DISPLAYED', 'Displayed');
            $notDisplayedText = _t(__CLASS__ . '.NOT_DISPLAYED', 'Not displayed');

            $field->replaceField('ShowTitle', LiteralField::create(
                'ShowTitle',
                $field->fieldByName('ShowTitle')->Value() === 'Yes' ? $displayedText : $notDisplayedText
            )->addExtraClass('show-title'));
        }

        return $field;
    }
1128198
public function undo( Revision $revision ) {
		$this->api->postRequest( new SimpleRequest(
			'edit',
			$this->getParamsFromRevision( $revision )
		) );
		return true;
	}
656950
public function update()
    {
        if ($this->newVersionAvailable === false
        || (!is_bool($this->newVersionAvailable) && !$this->hasUpdate())) {
            return false;
        }
        $this->backupPhar();
        $this->downloadPhar();
        $this->replacePhar();
        return true;
    }
1256827
def revert(self, version, url):
        
        message = "Draft replaced with %s version. This revert has not been published." % version.date_published
        version.make_draft()

        # Log action as a save
        self.log_action(self.object, CMSLog.SAVE, url=url)
        return self.write_message(message=message)
975638
function canVersionRemove( )
    {
        if ( !isset( $this->Permissions['can_versionremove'] ) )
        {
            $this->Permissions['can_versionremove'] = $this->checkAccess( 'versionremove' );
        }
        return ( $this->Permissions['can_versionremove'] == 1 );
    }
234848
public function change()
    {
        $table = $this->table('permissions');
        
        $table->addColumn('owner_model', 'string', [
            'default' => null,
            'null' => false,
            'limit' => 50,
        ]);

        $table->removeColumn('user_id');
        $table->removeColumn('is_active');

        $table->addColumn('owner_foreign_key', 'char', [
            'default' => null,
            'null' => false,
            'limit' => 36 
        ]);

        $table->save();
    }
534761
public function rollBack()
    {
        --$this->transaction_depth;

        // This means we rolled something back and now we lost track of commits
        if ($this->transaction_depth < 0) {
            $this->transaction_depth = 0;
        }

        if ($this->transaction_depth == 0) {
            return $this->dbh->rollBack();
        }

        return false;
    }