code: func (ssc *defaultStatefulSetControl) truncateHistory(
  	set *apps.StatefulSet,
  	pods []*v1.Pod,
  	revisions []*apps.ControllerRevision,
  	current *apps.ControllerRevision,
  	update *apps.ControllerRevision) error {
  	history := make([]*apps.ControllerRevision, 0, len(revisions))
  	// mark all live revisions
  	live := map[string]bool{current.Name: true, update.Name: true}
  	for i := range pods {
  		live[getPodRevision(pods[i])] = true
  	}
  	// collect live revisions and historic revisions
  	for i := range revisions {
  		if !live[revisions[i].Name] {
  			history = append(history, revisions[i])
  		}
  	}
  	historyLen := len(history)
  	historyLimit := int(*set.Spec.RevisionHistoryLimit)
  	if historyLen <= historyLimit {
  		return nil
  	}
  	// delete any non-live history to maintain the revision limit.
  	history = history[:(historyLen - historyLimit)]
  	for i := 0; i < len(history); i++ {
  		if err := ssc.controllerHistory.DeleteControllerRevision(history[i]); err != nil {
  			return err
  		}
  	}
  	return nil
  }
docs: // truncateHistory truncates any non-live ControllerRevisions in revisions from set's history. The UpdateRevision and
  // CurrentRevision in set's Status are considered to be live. Any revisions associated with the Pods in pods are also
  // considered to be live. Non-live revisions are deleted, starting with the revision with the lowest Revision, until
  // only RevisionHistoryLimit revisions remain. If the returned error is nil the operation was successful. This method
  // expects that revisions is sorted when supplied.