<commit_before>/**
 * The central tree data structure that is used to calculate state for
 * a Microcosm. Each node in the tree represents an action. Branches
 * are changes over time.
 *
 * @flow
 */

import Action from './action'

import {
  BIRTH,
  START
} from './lifecycle'

export default function History (limit) {
  this.ids = 0
  this.size = 0
  this.limit = Math.max(1, limit || 1)
  this.repos = []

  this.genesis = new Action(BIRTH, 'resolve', this)

  this.append(START, 'resolve')
}

History.prototype = {

  getId () {
    return ++this.ids
  },

  addRepo (repo) {
    this.repos.push(repo)
  },

  removeRepo (repo) {
    let index = this.repos.indexOf(repo)

    if (~index) {
      this.repos.splice(index, 1)
    }
  },

  invoke (method, payload) {
    let repos = this.repos

    for (var i = 0; i < repos.length; i++) {
      console.assert(repos[i], `No repo. Was it removed before invoke could run ${method}?`)
      repos[i][method](payload)
    }
  },

  checkout (action) {
    this.head = action || this.head<commit_msg>Improve error message<commit_after>/**
 * The central tree data structure that is used to calculate state for
 * a Microcosm. Each node in the tree represents an action. Branches
 * are changes over time.
 *
 * @flow
 */

import Action from './action'

import {
  BIRTH,
  START
} from './lifecycle'

export default function History (limit) {
  this.ids = 0
  this.size = 0
  this.limit = Math.max(1, limit || 1)
  this.repos = []

  this.genesis = new Action(BIRTH, 'resolve', this)

  this.append(START, 'resolve')
}

History.prototype = {

  getId () {
    return ++this.ids
  },

  addRepo (repo) {
    this.repos.push(repo)
  },

  removeRepo (repo) {
    let index = this.repos.indexOf(repo)

    if (~index) {
      this.repos.splice(index, 1)
    }
  },

  invoke (method, payload) {
    let repos = this.repos

    for (var i = 0; i < repos.length; i++) {
      console.assert(repos[i], `Missing repo! Was it removed before it could run repo.${method}?`)
      repos[i][method](payload)
    }
  },

  checkout (action) {
    this.head = action || this.head
{'fraction_non_alphanumeric': 0.14035916824196598, 'fraction_numerical': 0.005671077504725898, 'mean_word_length': 2.7602131438721136, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1147647', 'n_tokens_mistral': 757, 'n_tokens_neox': 707, 'n_words': 211}