code: func (w *IndexWriter) commitInternal(mergePolicy MergePolicy) error {
  	if w.infoStream.IsEnabled("IW") {
  		w.infoStream.Message("IW", "commit: start")
  	}
  
  	w.ClosingControl.ensureOpen(false)
  
  	if w.infoStream.IsEnabled("IW") {
  		w.infoStream.Message("IW", "commit: enter lock")
  	}
  
  	if w.pendingCommit == nil {
  		if w.infoStream.IsEnabled("IW") {
  			w.infoStream.Message("IW", "commit: now prepare")
  		}
  		err := w.prepareCommitInternal(mergePolicy)
  		if err != nil {
  			return err
  		}
  	} else {
  		if w.infoStream.IsEnabled("IW") {
  			w.infoStream.Message("IW", "commit: already prepared")
  		}
  	}
  	return w.finishCommit()
  }
docs: /*
  Assume commitLock is locked.
  */