code: func (s *Filesystem) WriteStateForMigration(f *statefile.File, force bool) error {
  	defer s.mutex()()
  
  	if s.readFile == nil {
  		err := s.refreshState()
  		if err != nil {
  			return err
  		}
  	}
  
  	if !force {
  		err := CheckValidImport(f, s.readFile)
  		if err != nil {
  			return err
  		}
  	}
  
  	if s.readFile != nil {
  		log.Printf(
  			"[TRACE] statemgr.Filesystem: Importing snapshot with lineage %q serial %d over snapshot with lineage %q serial %d at %s",
  			f.Lineage, f.Serial,
  			s.readFile.Lineage, s.readFile.Serial,
  			s.path,
  		)
  	} else {
  		log.Printf(
  			"[TRACE] statemgr.Filesystem: Importing snapshot with lineage %q serial %d as the initial state snapshot at %s",
  			f.Lineage, f.Serial,
  			s.path,
  		)
  	}
  
  	err := s.writeState(f.State, &SnapshotMeta{Lineage: f.Lineage, Serial: f.Serial})
  	if err != nil {
  		return err
  	}
  
  	return nil
  }
docs: // WriteStateForMigration is part of our implementation of Migrator.