Re-initialize then merge given state

 === Parameters
 state_to_merge(RightScale::InstanceState):: InstanceState to be passed on to Cook
 overrides(Hash):: Hash keyed by state name that will override state_to_merge

 === Return
 true:: Always
351634
def update(state_to_merge, overrides = {})
      # only merge state if state to be merged has values
      @startup_tags = state_to_merge.startup_tags if state_to_merge.respond_to?(:startup_tags)
      @reboot       = state_to_merge.reboot?      if state_to_merge.respond_to?(:reboot?)
      @log_level    = state_to_merge.log_level    if state_to_merge.respond_to?(:log_level)
      if state_to_merge.respond_to?(:log_file) && state_to_merge.respond_to?(:value)
        @log_file = state_to_merge.log_file(state_to_merge.value)
      end

      @startup_tags = overrides[:startup_tags] if overrides.has_key?(:startup_tags)
      @reboot       = overrides[:reboot]       if overrides.has_key?(:reboot)
      @log_file     = overrides[:log_file]     if overrides.has_key?(:log_file)

      # check the log level again after the startup_tags have been updated or
      # overridden.
      if overrides.has_key?(:log_level)
        @log_level = overrides[:log_level]
      elsif tagged_log_level = dev_log_level
        @log_level = tagged_log_level
      end

      save_state

      true
    end
872360
def dependency_states
      states = {}
      deps.each do |dep|
        gem = Polisher::Gem.new :name => dep.name
        states.merge! dep.name => gem.state(:check => dep)
      end
      states
    end
678087
def load_state
      if File.file?(STATE_FILE)
        state = RightScale::JsonUtilities::read_json(STATE_FILE)
        @log_level = state['log_level'] || Logger::INFO
        Log.info("Initializing CookState from  #{STATE_FILE} with #{state.inspect}") if @log_level == Logger::DEBUG

        @has_downloaded_cookbooks = state['has_downloaded_cookbooks']
        @startup_tags = state['startup_tags'] || []
        @reboot = state['reboot']
        @log_file = state['log_file'] # nil if not in state loaded from disk
      end
      true
    end
921003
def retriable_configuration
      Take2::Configuration::CONFIG_ATTRS.each_with_object({}) do |key, hash|
        hash[key] = send(key)
      end
    end
1300360
def merge!(another)
      configs = self.configs
      another.each_pair do |key, value|
        if config = configs[key]
          config.set(receiver, value)
        else
          store[key] = value
        end
      end
      self
    end
165456
def merge(attrs)
      # deep clone of attrs
      h = to_hash

      # merge in-place
      h.deep_merge!(attrs.to_hash, overwrite_arrays: true, merge_nil_values: true)

      self.class.new(h)
    end
988509
def set_state(k, v)
        if @state[k] != v # Only set state if it has actually changed
          @state[k] = v

          if !self.methods.include? k
            self.define_singleton_method(k.to_sym) do
              return State.new(@state[k])
            end
          end

          notify_listeners(k)
        end
      end
167750
def set_state(self, state):
        
        SimStatePlugin.set_state(self, state)

        # Delayed initialization
        stack_region_map, generic_region_map = self._temp_stack_region_map, self._temp_generic_region_map

        if stack_region_map or generic_region_map:
            # Inherited from its parent
            self._stack_region_map = stack_region_map.copy()
            self._generic_region_map = generic_region_map.copy()

        else:
            if not self._abstract_backer and o.REGION_MAPPING in self.state.options:
                # Only the top-level SimMemory instance can have region maps.
                self._stack_region_map = RegionMap(True)
                self._generic_region_map = RegionMap(False)

            else:
                self._stack_region_map = None
                self._generic_region_map = None
1077995
private boolean setState(State newState) {
        switch (newState) {
            case DEPLOYED:
                return changeState(State.DEPLOYING, State.DEPLOYED);
            case DEPLOYING:
                //can move from either UNDEPLOYED or FAILED into DEPLOYING state
                return (changeState(State.UNDEPLOYED, State.DEPLOYING) || changeState(State.FAILED, State.DEPLOYING));
            case UNDEPLOYING:
                return changeState(State.DEPLOYED, State.UNDEPLOYING);
            case UNDEPLOYED:
                return changeState(State.UNDEPLOYING, State.UNDEPLOYED);
            case FAILED:
                return changeState(State.DEPLOYING, State.FAILED);
            default:
                return false;
        }
    }
862804
function cloneState(state) {
  return {
    options: state.options,
    stack: state.stack.slice(),
    nodes: state.nodes.slice()
  };
}
1316386
function(state, transitionContext)
  {
    // this check is necessary to make sure we don't re-enter a transient state
    // like Renewing when we're already in it
    if (currentState !== state)
    {
      // if we have a current state, exit it; the null check is necessary
      // because the currentState is undefined at bootstrap time when we
      // transition to the first state
      if (currentState)
      {
        currentState.exit();
      }

      // update the current state
      currentState = state;

      // enter the new state
      currentState.enter(transitionContext);
    }
  }
1281827
public void setInstanceStates(java.util.Collection<String> instanceStates) {
        if (instanceStates == null) {
            this.instanceStates = null;
            return;
        }

        this.instanceStates = new com.amazonaws.internal.SdkInternalList<String>(instanceStates);
    }
576618
def _init_state(self, initial_state: Union[int, np.ndarray]):
        """"""
        state = np.reshape(
            sim.to_valid_state_vector(initial_state, self._num_qubits),
            (self._num_shards, self._shard_size))
        state_handle = mem_manager.SharedMemManager.create_array(
            state.view(dtype=np.float32))
        self._shared_mem_dict['state_handle'] = state_handle
161152
def _oneTransition(self, startState, inputToken, endState, outputTokens,
                       collector):
        
        # FIXME: tests for all of this (some of it is wrong)
        # if not isinstance(startState, MethodicalState):
        #     raise NotImplementedError("start state {} isn't a state"
        #                               .format(startState))
        # if not isinstance(inputToken, MethodicalInput):
        #     raise NotImplementedError("start state {} isn't an input"
        #                               .format(inputToken))
        # if not isinstance(endState, MethodicalState):
        #     raise NotImplementedError("end state {} isn't a state"
        #                               .format(startState))
        # for output in outputTokens:
        #     if not isinstance(endState, MethodicalState):
        #         raise NotImplementedError("output state {} isn't a state"
        #                                   .format(endState))
        self._automaton.addTransition(startState, inputToken, endState,
                                      tuple(outputTokens))
        inputToken.collectors[startState] = collector
678516
def append_state(self, s, is_widened_state=False):
        

        if not is_widened_state:
            self.all_states.append(s)
            self.state = s

        else:
            self.widened_state = s
337898
public boolean set(State state) {
    while (true) {
      InternalState internalState = currentInternalState.get();
      checkState(!internalState.isRead, "State was already read, cannot set state.");
      if (state == internalState.state) {
        return false;
      } else {
        if (!currentInternalState.compareAndSet(
            internalState,
            state == State.ENABLED
                ? InternalState.ENABLED_NOT_READ
                : InternalState.DISABLED_NOT_READ)) {
          // The state was changed between the moment the internalState was read and this point.
          // Some conditions may be not correct, reset at the beginning and recheck all conditions.
          continue;
        }
        return true;
      }
    }
  }
797389
def initial_state=(new_initial_state)
      @initial_state = new_initial_state
      add_states([@initial_state]) unless dynamic_initial_state?

      # Update all states to reflect the new initial state
      states.each { |state| state.initial = (state.name == @initial_state) }

      # Output a warning if there are conflicting initial states for the machine's
      # attribute
      initial_state = states.detect { |state| state.initial }
      if !owner_class_attribute_default.nil? && (dynamic_initial_state? || !owner_class_attribute_default_matches?(initial_state))
        warn(
            "Both #{owner_class.name} and its #{name.inspect} machine have defined "\
          "a different default for \"#{attribute}\". Use only one or the other for "\
          "defining defaults to avoid unexpected behaviors."
        )
      end
    end