Roll back by finding a specific version in the history of the service and
  putting it as the new current version.
  Args:
    context: a populated EFVersionContext object
966802
def cmd_rollback_to(context):
  
  version = get_version_by_value(context, context.rollback_to)
  context.value = version.value
  context.commit_hash = version.commit_hash
  context.build_number = version.build_number
  context.location = version.location
  context.stable = True
  cmd_set(context)
561284
function (context, callback) {

            var self = this,
                options = {},
                model,
                processor,
                isPatch = context.request.method === "PATCH",
                upsert = this.$resourceConfiguration.$.upsert,
                defaults;


            flow()
                .seq("collection", function (cb) {
                    self._findCollection(context, cb);
                })
                .seq(function (cb) {
                    model = this.vars.collection.createItem(self.$resourceId);
                    defaults = _.clone(model.$);
                    // check if model exists
                    if (upsert && !isPatch) {
                        cb();
                    } else {
                        model.fetch(null, cb);
                    }
                })
                .seq(function () {
                    if (!isPatch) {
                        model.clear();
                        model.set(defaults);
                    }

                    var payload = context.request.params;

                    processor = self.$restHandler.$restDataSource.getProcessorForModel(model);

                    model.set(processor.parse(model, payload || {}));

                    options.action = DataSource.ACTION.UPDATE;

                    // TODO: add hook to add session data like user id
                    if (upsert === true) {
                        options.upsert = true;
                        model.set(model.idField, model.factory.prototype.convertIdentifier(self.$resourceId));
                    }
                })
                .seq(function () {
                    self._generateAutoValues(model);
                })
                .seq(function (cb) {
                    self._validate(model, context, cb);
                })
                .seq(function (cb) {
                    self._beforeModelSave(model, context, cb);
                })
                .seq(function (cb) {
                    self._beforeModelUpdate(model, context, cb);
                })
                .seq(function (cb) {
                    model.validateAndSave(options, cb);
                })
                .seq(function (cb) {
                    self._afterModelUpdate(model, context, cb);
                })
                .exec(function (err, results) {
                    if (!err) {
                        // TODO: do correct invalidation
                        results.collection.invalidatePageCache();

                        self._fetchAllHrefsForModel(model, context);

                        // TODO: generate the location header
                        var body = JSON.stringify(processor.compose(model, null));

                        var response = context.response;
                        response.writeHead(200, "", {
                            'Content-Type': 'application/json'
                            // TODO : add updated date in head ???
//                            'Location': context.request.urlInfo.uri
                        });

                        response.write(body);
                        response.end();

                        callback(null);
                    } else {
                        if (!(err instanceof HttpError)) {
                            var statusCode = 400;
                            if (err === DataSource.ERROR.NOT_FOUND) {
                                statusCode = 404;
                            }
                            err = new HttpError(err, statusCode);
                        }
                        callback(err);
                    }
                });

        }
975712
def update_version(self, service_id, version_number, **kwargs):
		""""""
		body = self._formdata(kwargs, FastlyVersion.FIELDS)
		content = self._fetch("/service/%s/version/%d/" % (service_id, version_number), method="PUT", body=body)
		return FastlyVersion(self, content)
1367081
function(instance, opt){
      var previousVersion = instance._previousDataValues;
      var currentVersion = instance.dataValues;

      // Disallow change of revision
      instance.set(options.revisionAttribute, instance._previousDataValues[options.revisionAttribute]);

      // Get diffs
      var diffs = getDifferences(previousVersion, currentVersion, options.exclude);

      if(diffs && diffs.length > 0){
         instance.set(options.revisionAttribute, (instance.get(options.revisionAttribute) || 0) + 1);
         if(!instance.context){
            instance.context = {};
         }
         instance.context.diffs = diffs;
      }
   }
741393
def current_db_version(self):
        

        query = """
        SELECT version from {} WHERE success = TRUE ORDER BY version DESC
        """.format(self.upgrades_table)

        self.cursor.execute(query)

        return self.cursor.fetchone()[0]
264767
def update(self, version, reason=None):
        
        _check_version_format(version)
        return self.collection.update({'_id': 'manifest'}, {
            '$set': {'version': version},
            '$push': {'history': {
                'timestamp': datetime.utcnow(), 'version': version,
                'reason': reason}}
        })
885107
def rollback(awsclient, function_name, alias_name=ALIAS_NAME, version=None):
    
    if version:
        log.info('rolling back to version {}'.format(version))
    else:
        log.info('rolling back to previous version')
        version = _get_previous_version(awsclient, function_name, alias_name)
        if version == '0':
            log.error('unable to find previous version of lambda function')
            return 1

        log.info('new version is %s' % str(version))

    _update_alias(awsclient, function_name, version, alias_name)
    return 0
93995
def with_current_context(self, func):
        """"""

        caller_context = self.snapshot()

        def call_with_current_context(*args, **kwargs):
            try:
                backup_context = self.snapshot()
                self.apply(caller_context)
                return func(*args, **kwargs)
            finally:
                self.apply(backup_context)

        return call_with_current_context
742281
def post_versions_undo(self, version_id):
        
        return self._get('post_versions/{0}/undo.json'.format(version_id),
                         method='PUT', auth=True)
1095705
function replacePropagatingVersions(uri, data) {
  if (references.isPropagatingVersion(uri)) {
    references.replaceAllVersions(uri.split('@')[1])(data);
  }

  return data;
}
1015824
def update(self, **kwargs):
        
        self.reload_context(es_based=False, **kwargs)
        return super(ESCollectionView, self).update(**kwargs)
644090
def version(context=None):
    '''
    
    '''
    contextkey = 'salt.utils.systemd.version'
    if isinstance(context, dict):
        # Can't put this if block on the same line as the above if block,
        # because it will break the elif below.
        if contextkey in context:
            return context[contextkey]
    elif context is not None:
        raise SaltInvocationError('context must be a dictionary if passed')
    stdout = subprocess.Popen(
        ['systemctl', '--version'],
        close_fds=True,
        stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
    outstr = salt.utils.stringutils.to_str(stdout)
    try:
        ret = int(re.search(r'\w+ ([0-9]+)', outstr.splitlines()[0]).group(1))
    except (AttributeError, IndexError, ValueError):
        log.error(
            'Unable to determine systemd version from systemctl '
            '--version, output follows:\n%s', outstr
        )
        return None
    else:
        try:
            context[contextkey] = ret
        except TypeError:
            pass
        return ret
280352
static String getAppVersion(Context context) {
        String appVersion = "";
        if (context != null) {
            try {
                final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
                appVersion = packageInfo.versionName;
            } catch (Exception e) {
                PrefHelper.LogException("Error obtaining AppVersion", e);
            }
        }
        return (TextUtils.isEmpty(appVersion) ? BLANK : appVersion);
    }
724291
public static void resetIfAppVersionChanged(Context context) {
        SharedPreferences prefs = getSharedPreferences(context);

        int appVersionCode = Integer.MIN_VALUE;
        final int previousAppVersionCode = prefs.getInt(PREF_KEY_APP_VERSION_CODE, Integer.MIN_VALUE);
        try {
            appVersionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            Log.w(TAG, "Occurred PackageManager.NameNotFoundException", e);
        }

        if (previousAppVersionCode != appVersionCode) {
            SharedPreferences.Editor prefsEditor = prefs.edit();
            prefsEditor.putLong(PREF_KEY_APP_LAUNCH_COUNT, 0);
            prefsEditor.putLong(PREF_KEY_APP_THIS_VERSION_CODE_LAUNCH_COUNT, 0);
            prefsEditor.putLong(PREF_KEY_APP_FIRST_LAUNCHED_DATE, 0);
            prefsEditor.putInt(PREF_KEY_APP_VERSION_CODE, Integer.MIN_VALUE);
            prefsEditor.putLong(PREF_KEY_RATE_CLICK_DATE, 0);
            prefsEditor.putLong(PREF_KEY_REMINDER_CLICK_DATE, 0);
            prefsEditor.putBoolean(PREF_KEY_DO_NOT_SHOW_AGAIN, false);
            prefsEditor.commit();
        }
    }
1181119
def _update_cache(self):
        "  "
        expected_version = (self.registry._version, self._extra_registry._version)

        if self._last_version != expected_version:
            registry2 = Registry()

            # Copy all bindings from `self.registry`, adding our condition.
            for reg in (self.registry, self._extra_registry):
                for b in reg.key_bindings:
                    registry2.key_bindings.append(
                        _Binding(
                            keys=b.keys,
                            handler=b.handler,
                            filter=self.filter & b.filter,
                            eager=b.eager,
                            save_before=b.save_before))

            self._registry2 = registry2
            self._last_version = expected_version
610809
def _validate_version(connection, dsn):
    
    try:
        version = get_stored_version(connection)
    except VersionIsNotStored:
        logger.debug('Version not stored in the db: assuming new database creation.')
        version = SCHEMA_VERSION
        _update_version(connection, version)
    assert isinstance(version, int)

    if version > 10 and version < 100:
        raise DatabaseError('You are trying to open an old SQLite database.')

    if _migration_required(connection):
        migrate(connection, dsn)
469078
def revert_to(self):

		'''
		
		'''

		# send patch
		response = self.resource.repo.api.http_request('PATCH', self.uri)

		# if response 204
		if response.status_code == 204:
			logger.debug('reverting to previous version of resource, %s' % self.uri)

			# refresh current resource handle
			self._current_resource.refresh()

		else:
			raise Exception('HTTP %s, could not revert to resource version, %s' % (response.status_code, self.uri))