This invokes the tranformation block if one is installed and queues the resulting CBL_Revision
2941
private void queueDownloadedRevision(RevisionInternal rev) {

        if (revisionBodyTransformationBlock != null) {
            // Add 'file' properties to attachments pointing to their bodies:

            for (Map.Entry<String, Map<String, Object>> entry : (
                    (Map<String, Map<String, Object>>) rev.getProperties().get("_attachments")).entrySet()) {
                String name = entry.getKey();
                Map<String, Object> attachment = entry.getValue();
                attachment.remove("file");
                if (attachment.get("follows") != null && attachment.get("data") == null) {
                    String filePath = db.fileForAttachmentDict(attachment).getPath();
                    if (filePath != null)
                        attachment.put("file", filePath);
                }
            }

            RevisionInternal xformed = transformRevision(rev);
            if (xformed == null) {
                Log.v(TAG, "%s: Transformer rejected revision %s", this, rev);
                pendingSequences.removeSequence(rev.getSequence());
                lastSequence = pendingSequences.getCheckpointedValue();
                pauseOrResume();
                return;
            }
            rev = xformed;

            // Clean up afterwards
            Map<String, Map<String, Object>> attachments = (Map<String, Map<String, Object>>) rev.getProperties().get("_attachments");

            for (Map.Entry<String, Map<String, Object>> entry : attachments.entrySet()) {
                Map<String, Object> attachment = entry.getValue();
                attachment.remove("file");
            }
        }

        // NOTE: should not/not necessary to call Body.compact()
        // new RevisionInternal(Map<string, Object>) creates Body instance only
        // with `object`. Serializing object to json causes two unnecessary
        // JSON serializations.

        if (rev.getBody() != null)
            queuedMemorySize.addAndGet(rev.getBody().getSize());

        downloadsToInsert.queueObject(rev);

        // if queue memory size is more than maximum, force flush the queue.
        if (queuedMemorySize.get() > MAX_QUEUE_MEMORY_SIZE) {
            Log.d(TAG, "Flushing queued memory size at: " + queuedMemorySize);
            downloadsToInsert.flushAllAndWait();
        }
    }
51844
def update(self):
        
        # build requests for this iteration
        reqs = self.build_requests()
        for r in reqs:
            r.block = self.block
        results = self.send_requests(*reqs)

        # call callback with the results
        self.callback(results)
143392
def prepare_revision
      return if self.new_record?
      if (self.respond_to?(:blocks_attributes_changed) && self.blocks_attributes_changed) || 
        !(self.changed & revision_fields).empty?
        self.revision_data = revision_fields.inject({}) do |c, field|
          c[field] = self.send("#{field}_was")
          c
        end
      end
    end
583733
private void noSuccessor() {
        if (compute == FRAMES) {
            Label l = new Label();
            l.frame = new Frame();
            l.frame.owner = l;
            l.resolve(this, code.length, code.data);
            previousBlock.successor = l;
            previousBlock = l;
        } else {
            currentBlock.outputStackMax = maxStackSize;
        }
        currentBlock = null;
    }
569421
def revision(revision, path, branch_label, splice, head, sql, autogenerate, message):
    
    alembic_command.revision(
        config=get_config(),
        rev_id=revision,
        version_path=path,
        branch_label=branch_label,
        splice=splice,
        head=head,
        sql=sql,
        autogenerate=autogenerate,
        message=message
    )
1348860
def check_rev_options(self, rev, dest, rev_options):
        
        revisions = self.get_tag_revs(dest)
        revisions.update(self.get_branch_revs(dest))

        origin_rev = 'origin/%s' % rev
        if origin_rev in revisions:
            # remote branch
            return [revisions[origin_rev]]
        elif rev in revisions:
            # a local tag or branch name
            return [revisions[rev]]
        else:
            logger.warn("Could not find a tag or branch '%s', assuming commit." % rev)
            return rev_options
1125963
private void upgradeLockIfNeeded()
    {
        // using clone to avoid ConcurentModificationException
        Iterator iter = ((List) mvOrderOfIds.clone()).iterator();
        TransactionImpl tx = getTransaction();
        ObjectEnvelope mod;
        while(iter.hasNext())
        {
            mod = (ObjectEnvelope) mhtObjectEnvelopes.get(iter.next());
            // ignore transient objects
            if(!mod.getModificationState().isTransient())
            {
                /*
                now we check if all modified objects has a write lock. On insert of new
                objects we don't need a write lock.
                */
                if(!mod.needsInsert())
                {
                    if((mod.needsDelete() || mod.needsUpdate()
                            || mod.hasChanged(tx.getBroker())))
                    {
                        needsCommit = true;
                        // mark object dirty
                        mod.setModificationState(mod.getModificationState().markDirty());
                        ClassDescriptor cld = mod.getClassDescriptor();
                        // if the object isn't already locked, we will do it now
                        if(!mod.isWriteLocked())
                        {
                            tx.doSingleLock(cld, mod.getObject(), mod.getIdentity(), Transaction.WRITE);
                        }
                    }
                }
                else
                {
                    needsCommit = true;
                }
            }
        }
    }
1253172
function (callback) {

    var self = this;

    var warnings = null;

    async.series([
      // load domain files...
      function (callback) {
        debug('load denormalizer files..');
        self.structureLoader(self.options.denormalizerPath, function (err, tree, warns) {
          if (err) {
            return callback(err);
          }
          warnings = warns;
          self.tree = attachLookupFunctions(tree);
          callback(null);
        });
      },

      // prepare infrastructure...
      function (callback) {
        debug('prepare infrastructure...');
        async.parallel([

          // prepare repository...
          function (callback) {
            debug('prepare repository...');

            self.repository.on('connect', function () {
              self.emit('connect');
            });

            self.repository.on('disconnect', function () {
              self.emit('disconnect');
            });

            self.repository.connect(callback);
          },

          // prepare revisionGuard...
          function (callback) {
            debug('prepare revisionGuard...');

            self.revisionGuardStore.on('connect', function () {
              self.emit('connect');
            });

            self.revisionGuardStore.on('disconnect', function () {
              self.emit('disconnect');
            });

            self.revisionGuardStore.connect(callback);
          }
        ], callback);
      },

      // inject all needed dependencies...
      function (callback) {
        debug('inject all needed dependencies...');

        self.revisionGuard = new RevisionGuard(self.revisionGuardStore, self.options.revisionGuard);
        self.revisionGuard.onEventMissing(function (info, evt) {
          self.onEventMissingHandle(info, evt);
        });

        self.eventDispatcher = new EventDispatcher(self.tree, self.definitions.event);
        self.tree.defineOptions(self.options)
          .defineEvent(self.definitions.event)
          .defineNotification(self.definitions.notification)
          .idGenerator(self.getNewId)
          .useRepository(self.repository);

        self.revisionGuard.defineEvent(self.definitions.event);

        self.replayHandler = new ReplayHandler(self.eventDispatcher, self.revisionGuardStore, self.definitions.event, self.options);

        callback(null);
      }
    ], function (err) {
      if (err) {
        debug(err);
      }
      if (callback) { callback(err, warnings); }
    });
  }
725063
def run_migrations_online():
    

    # this callback is used to prevent an auto-migration from being generated
    # when there are no changes to the schema
    # reference: https://alembic.sqlalchemy.org/en/latest/cookbook.html
    def process_revision_directives(context, revision, directives):
        if getattr(config.cmd_opts, 'autogenerate', False):
            script = directives[0]
            if script.upgrade_ops.is_empty():
                directives[:] = []
                logger.info('No changes in schema detected.')

    engine = engine_from_config(config.get_section(config.config_ini_section),
                                prefix='sqlalchemy.',
                                poolclass=pool.NullPool)

    connection = engine.connect()
    kwargs = {}
    if engine.name in ('sqlite', 'mysql'):
        kwargs = {
            'transaction_per_migration': True,
            'transactional_ddl': True,
        }
    configure_args = current_app.extensions['migrate'].configure_args
    if configure_args:
        kwargs.update(configure_args)

    context.configure(connection=connection,
                      target_metadata=target_metadata,
                      # compare_type=True,
                      process_revision_directives=process_revision_directives,
                      **kwargs)

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
849106
def upgrade(config, revision, **kwargs):
    
    with alembic_lock(
        config.registry["sqlalchemy.engine"], config.alembic_config()
    ) as alembic_config:
        alembic.command.upgrade(alembic_config, revision, **kwargs)
1235070
public void finalizeBlockInternal(int namespaceId, Block b, boolean reFinalizeOk)
    throws IOException {
    lock.writeLock().lock();
    DatanodeBlockInfo binfo = volumeMap.get(namespaceId, b);
    try {
      ActiveFile activeFile = volumeMap.getOngoingCreates(namespaceId, b);
      if (activeFile == null) {
        if (reFinalizeOk) {
          return;
        } else {
          throw new IOException("Block " + b + " is already finalized.");
        }
      }
      File f = activeFile.getDataFile();
      if (f == null || !f.exists()) {
        throw new IOException("No temporary file " + f + " for block " + b);
      }
      FSVolume v = binfo.getBlockDataFile().getVolume();
      if (v == null) {
        throw new IOException("No volume for temporary file " + f + 
                              " for block " + b);
      }
          
      File dest = null;
      dest = v.addBlock(namespaceId, b, f, activeFile.isInlineChecksum(),
          binfo.getChecksumType(), binfo.getBytesPerChecksum());
      volumeMap.add(
          namespaceId,
          b,
          new DatanodeBlockInfo(v, dest, activeFile.getBytesWritten(), true,
              activeFile.isInlineChecksum(), binfo.getChecksumType(),
              binfo.getBytesPerChecksum(),
              activeFile.getCrcUpdater().isCrcValid(activeFile.getBytesWritten()),
              activeFile.getCrcUpdater().getBlockCrc()));
      ActiveFile af = volumeMap.removeOngoingCreates(namespaceId, b);
      af.blockFinalize();
    } finally {
      lock.writeLock().unlock();
    }
  }
954492
@InterfaceAudience.Private
    public void pullRemoteRevisions() {
        //find the work to be done in a synchronized block
        List<RevisionInternal> workToStartNow = new ArrayList<RevisionInternal>();
        List<RevisionInternal> bulkWorkToStartNow = new ArrayList<RevisionInternal>();

        synchronized (bulkRevsToPull) {
            while (httpConnectionCount + workToStartNow.size() < MAX_OPEN_HTTP_CONNECTIONS) {
                int nBulk = (bulkRevsToPull.size() < MAX_REVS_TO_GET_IN_BULK) ?
                        bulkRevsToPull.size() : MAX_REVS_TO_GET_IN_BULK;

                if (nBulk == 1) {
                    // Rather than pulling a single revision in 'bulk', just pull it normally:
                    queueRemoteRevision(bulkRevsToPull.remove(0));
                    nBulk = 0;
                }

                if (nBulk > 0) {
                    bulkWorkToStartNow.addAll(bulkRevsToPull.subList(0, nBulk));
                    bulkRevsToPull.subList(0, nBulk).clear();
                } else {
                    // Prefer to pull an existing revision over a deleted one:
                    if (revsToPull.size() == 0 && deletedRevsToPull.size() == 0) {
                        break;  // both queues are empty
                    } else if (revsToPull.size() > 0) {
                        workToStartNow.add(revsToPull.remove(0));
                    } else if (deletedRevsToPull.size() > 0) {
                        workToStartNow.add(deletedRevsToPull.remove(0));
                    }
                }
            }
        }

        //actually run it outside the synchronized block
        if (bulkWorkToStartNow.size() > 0) {
            pullBulkRevisions(bulkWorkToStartNow);
        }

        for (RevisionInternal work : workToStartNow) {
            pullRemoteRevision(work);
        }
    }
1324773
def _on_completions_refreshed(self, new_completer):
        
        with self._completer_lock:
            self.completer = new_completer
            # When cli is first launched we call refresh_completions before
            # instantiating the cli object. So it is necessary to check if cli
            # exists before trying the replace the completer object in cli.
            if self.cli:
                self.cli.current_buffer.completer = new_completer

        if self.cli:
            # After refreshing, redraw the CLI to clear the statusbar
            # "Refreshing completions..." indicator
            self.cli.request_redraw()
1023395
def rollback(self, revision):
        

        print("Rolling back..")

        self.zappa.rollback_lambda_function_version(
            self.lambda_name, versions_back=revision)
        print("Done!")
989720
def is_revision_chain_placeholder(pid):
    """"""
    return d1_gmn.app.models.ReplicaRevisionChainReference.objects.filter(
        pid__did=pid
    ).exists()
267865
def complete_block(self):
        """"""
        return "".join(line[SOURCE] for line in self._boot_lines + self._source_lines)
672595
protected void doGlobalVersioning(StaplerRequest req) {
        if (req.getParameter("releaseVersion") != null) {
            releaseVersion = req.getParameter("releaseVersion");
        }
        if (req.getParameter("nextVersion") != null) {
            nextVersion = req.getParameter("nextVersion");
        }
    }