Return a deferred to set current revision in persistent state.
491823
def _setCurrentRev(self, rev, branch='default'):
        """"""
        self.lastRev[branch] = str(rev)
        return self.setState('lastRev', self.lastRev)
162248
public function getCurrentRevision()
    {
        if ($this->currentRevision === null) {
            $this->setCurrentRevision($this->revisionRepository->getCurrentByEnvironment($this));
        }
        return $this->currentRevision;
    }
904878
def transform_revision(self, revision):
        """"""
        config = self.manager.get_source('config')
        return config.load_resource(revision)
161564
def on_revert(request, page_name):
    """"""
    rev_id = request.args.get("rev", type=int)

    old_revision = page = None
    error = "No such revision"

    if request.method == "POST" and request.form.get("cancel"):
        return redirect(href(page_name))

    if rev_id:
        old_revision = Revision.query.filter(
            (Revision.revision_id == rev_id)
            & (Revision.page_id == Page.page_id)
            & (Page.name == page_name)
        ).first()
        if old_revision:
            new_revision = (
                Revision.query.filter(
                    (Revision.page_id == Page.page_id) & (Page.name == page_name)
                )
                .order_by(Revision.revision_id.desc())
                .first()
            )
            if old_revision == new_revision:
                error = "You tried to revert the current active revision."
            elif old_revision.text == new_revision.text:
                error = (
                    "There are no changes between the current "
                    "revision and the revision you want to "
                    "restore."
                )
            else:
                error = ""
                page = old_revision.page
                if request.method == "POST":
                    change_note = request.form.get("change_note", "")
                    change_note = "revert" + (change_note and ": " + change_note or "")
                    session.add(Revision(page, old_revision.text, change_note))
                    session.commit()
                    return redirect(href(page_name))

    return Response(
        generate_template(
            "action_revert.html", error=error, old_revision=old_revision, page=page
        )
    )
147340
def _evaluate(self):
        """"""
        if not self.__retrieved:
            self._elements = self._retrieve_revisions()
            self.__retrieved = True

        return super(RevisionCursor, self)._evaluate()
594093
def commit(self):
        """"""
        if (not self._add_cache and
                not self._remove_cache and
                not self._undefined_cache):
            return

        for store_key, hash_values in self._add_cache.items():
            for hash_value in hash_values:
                super(TransactionalIndex, self).add_hashed_value(
                    hash_value, store_key)
        for store_key in self._remove_cache:
            super(TransactionalIndex, self).remove_key(store_key)
        for store_key in self._undefined_cache:
            super(TransactionalIndex, self).add_undefined(store_key)
        if not self.ephemeral:
            self.save_to_store()

        self._init_cache()
        self._in_transaction = True
448454
def __update_action(self, revision):
        

        patch = revision.get("patch")
        if patch.get("_id"):
            del patch["_id"]

        update_response = yield self.collection.patch(revision.get("master_id"), self.__make_storeable_patch_patchable(patch))

        if update_response.get("n") == 0:
            raise RevisionNotFoundException()
563938
def __return(self, shard_state, tstate, task_directive):
    """"""
    task_directive = self._set_state(shard_state, tstate, task_directive)
    self._save_state_and_schedule_next(shard_state, tstate, task_directive)
    context.Context._set(None)
435198
def set_all_revisions_to_in_process(self, ids):
        

        predicate = {
            "_id" : {
                "$in" : [ ObjectId(id) for id in ids ]
            }
        }

        set = {"$set": { "inProcess": True }}

        yield self.revisions.collection.update(predicate, set, multi=True)
671033
def request_update(self):
        
        with self._lock:
            self._need_update = True
            if not self._future or self._future.is_done:
              self._future = Future()
            return self._future
631438
def save(self, revision):
        
        if not isinstance(revision, Revision):
            raise InvalidArgType()

        self.state.update(revision)
231704
def rev_after(self, rev: int) -> int:
        """"""
        self.seek(rev)
        if self._future:
            return self._future[-1][0]
1293476
def restore_last_revision!(id)
      record = restore_last_revision(id)
      if record
        record.store_revision do
          save_restorable_associations(record, revisionable_associations)
        end
      end
      return record
    end
240139
function (data, fn) {
    this.store.generateBinId(data.length, 0, function generateBinId(err, id) {
      if (err) {
        return fn(err);
      }

      data.url = id;
      data.revision = 1;
      data.latest = true;
      data.streamingKey = this.createStreamingKey(id, data.revision);
      this.store.setBin(data, function (err, id) {
        data.id = id;
        fn(err || null, err ? undefined : data);
      });
    }.bind(this));
  }
1290770
private StateUpdater createReset(StateUpdater check)
    {
        return (extrp, current) ->
        {
            collidable.setEnabled(false);
            return check;
        };
    }
1327338
def restore_revision!(id, revision_number)
      record = restore_revision(id, revision_number)
      if record
        record.store_revision do
          save_restorable_associations(record, revisionable_associations)
        end
      end
      return record
    end
599893
def set(self, key, value):
        
        serialized = json.dumps(value)

        self.cursor.execute('select data from kv where key=?', [key])
        exists = self.cursor.fetchone()

        # Skip mutations to the same value
        if exists:
            if exists[0] == serialized:
                return value

        if not exists:
            self.cursor.execute(
                'insert into kv (key, data) values (?, ?)',
                (key, serialized))
        else:
            self.cursor.execute('''
            update kv
            set data = ?
            where key = ?''', [serialized, key])

        # Save
        if not self.revision:
            return value

        self.cursor.execute(
            'select 1 from kv_revisions where key=? and revision=?',
            [key, self.revision])
        exists = self.cursor.fetchone()

        if not exists:
            self.cursor.execute(
                '''insert into kv_revisions (
                revision, key, data) values (?, ?, ?)''',
                (self.revision, key, serialized))
        else:
            self.cursor.execute(
                '''
                update kv_revisions
                set data = ?
                where key = ?
                and   revision = ?''',
                [serialized, key, self.revision])

        return value