code: func (s *State) WriteStateForMigration(f *statefile.File, force bool) error {
  	s.mu.Lock()
  	defer s.mu.Unlock()
  
  	checkFile := statefile.New(s.state, s.lineage, s.serial)
  	if !force {
  		if err := statemgr.CheckValidImport(f, checkFile); err != nil {
  			return err
  		}
  	}
  
  	// We create a deep copy of the state here, because the caller also has
  	// a reference to the given object and can potentially go on to mutate
  	// it after we return, but we want the snapshot at this point in time.
  	s.state = f.State.DeepCopy()
  	s.lineage = f.Lineage
  	s.serial = f.Serial
  
  	return nil
  }
docs: // WriteStateForMigration is part of our implementation of statemgr.Migrator.