<commit_before><?php

namespace spidgorny\migrate;

class Repo {

	var $path;

	var $hash;

	var $nr;

	var $tag;

	var $message;

	var $date;

	protected $verbose;

	function __construct($folder = NULL)
	{
		$this->path = $folder;
	}

	function setVerbose($v) {
		$this->verbose = $v;
	}

	function exec($cmd, &$lines = []) {
		if ($this->verbose) {
			echo '> ', $cmd, BR;
		}
		$line = exec($cmd, $lines);
		return $line;
	}

	function system($cmd) {
		if ($this->verbose) {
			echo '> ', $cmd, BR;
		}
		system($cmd);
	}

	static function decode($properties) {
		$repo = new static();
		foreach ((array)$properties AS $key => $value) {
			$repo->{$key} = $value;
		}
		return $repo;
	}

	function nr() {
		return intval($this->nr);
	}

	function getHash() {
		$hash = str_replace('+', '', $this->hash);
		return $hash;
	}

	function path() {
		$path = str_replace('\\', '/', $this->path);
		return $path;
	}

	function __toString()
	{
		return implode(TAB, [$this->hash, $this->nr, $this->tag,
			 $this->date,
			str_pad($this->path, 35, ' '), '"'.$this->message.'"']);
	}

	function check() {
		$line = $this->exec('hg id -int '.$this->path);
		//echo $line, BR;
		$parts = trimExplode(' ', $line);
		//pre_print_r($parts);
		if (sizeof($parts) == 3) {
			list($this->hash, $this->nr, $this->tag) = $parts;
		} else {
			list($this->hash, $this->nr) = $parts;
		}

		$save = getcwd();
		chdir($this->path);

		$cmd = 'hg log -l 1 --template "{date|shortdate}\t{desc}\n"';
		$this->exec($cmd, $lines);
		list($this->date, $this->message) = trimExplode(TAB, first($lines));

		chdir($save);
	}

	function install() {
		$save = getcwd();
		chdir($this->path);

		system('hg pull');
		system('hg update -r '.$this->getHash());

		chdir($save);
	}

	function thg() {
		chdir($this->path);
		system('thg');
	}

	function push() {<commit_msg>- ADD Exception when folder from VERSION.json does not exist<commit_after><?php

namespace spidgorny\migrate;

class Repo {

	var $path;

	var $hash;

	var $nr;

	var $tag;

	var $message;

	var $date;

	protected $verbose;

	function __construct($folder = NULL)
	{
		$this->path = $folder;
	}

	function setVerbose($v) {
		$this->verbose = $v;
	}

	function exec($cmd, &$lines = []) {
		if ($this->verbose) {
			echo '> ', $cmd, BR;
		}
		$line = exec($cmd, $lines);
		return $line;
	}

	function system($cmd) {
		if ($this->verbose) {
			echo '> ', $cmd, BR;
		}
		system($cmd);
	}

	static function decode($properties) {
		$repo = new static();
		foreach ((array)$properties AS $key => $value) {
			$repo->{$key} = $value;
		}
		return $repo;
	}

	function nr() {
		return intval($this->nr);
	}

	function getHash() {
		$hash = str_replace('+', '', $this->hash);
		return $hash;
	}

	function path() {
		$path = str_replace('\\', '/', $this->path);
		return $path;
	}

	function __toString()
	{
		return implode(TAB, [$this->hash, $this->nr, $this->tag,
			 $this->date,
			str_pad($this->path, 35, ' '), '"'.$this->message.'"']);
	}

	function check() {
		$line = $this->exec('hg id -int '.$this->path);
		//echo $line, BR;
		$parts = trimExplode(' ', $line);
		//pre_print_r($parts);
		if (sizeof($parts) == 3) {
			list($this->hash, $this->nr, $this->tag) = $parts;
		} else {
			list($this->hash, $this->nr) = $parts;
		}

		$save = getcwd();
		chdir($this->path);

		$cmd = 'hg log -l 1 --template "{date|shortdate}\t{desc}\n"';
		$this->exec($cmd, $lines);
		list($this->date, $this->message) = trimExplode(TAB, first($lines));

		chdir($save);
	}

	function install() {
		$save = getcwd();
		$ok = @chdir($this->path);
		if ($ok) {

			system('hg pull');
			system('hg update -r ' . $this->getHash());

			chdir($save);
		} else {
			throw new \InvalidArgumentException('Folder '.$this->path.' does not exist. Install aborted.');
		}
	}

	function thg() {
		chdir($this->path);
		system('thg');
	}

	function push() {
{'fraction_non_alphanumeric': 0.22724922440537745, 'fraction_numerical': 0.002068252326783868, 'mean_word_length': 3.298888888888889, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 66, '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': '290382', 'n_tokens_mistral': 1683, 'n_tokens_neox': 1494, 'n_words': 328}