<commit_before>/* This file is licensed under the Affero General Public License. */

/*global _, jsyaml, esprima, estraverse, string, io, File, XDomainRequest, JSZip, getFile: true, putFile: true, prepareFile: true, prepareString: true, prepareUrl: true, startTransaction: true, endTransaction: true, resolve: true, basename: true, deepEquals: true */

var core_version = 3;

var settings = {};

var inTransaction = false;
var transaction = null;
var transactionDate;
var transactionIdPrefix;
var filesToPut;
function startTransaction() {
	inTransaction = true;
	if(!transaction) {
		transaction = {};
		transactionDate = new Date();
		transactionIdPrefix = Math.round(Math.random() * Date.now()).toString(16);
		filesToPut = 0;
	}
}
window.startTransaction = startTransaction;
function endTransaction() {
	console.trace(inTransaction, filesToPut, transaction);
	if(!transaction) return;
	inTransaction = false;
	if(filesToPut) return;
	var _transaction = transaction;
	transaction = null;
	var transactions = {};
	Object.keys(_transaction).forEach(function(path) {
		var transactionId = getTransactionId(_transaction[path][1]);
		if(!transactions[transactionId]) {
			transactions[transactionId] = 0;
		}
		if(/\.history\/.+/.test(_transaction[path][0])) {
			transactions[transactionId] += 2;
		} else {
			transactions[transactionId]++;
		}
	});
	Object.keys(transactions).forEach(function(transactionId) {
		var req = new XMLHttpRequest();
		req.open('POST', '/transaction/add');
		req.setRequestHeader('Content-Type', 'application/json');
		req.send(JSON.stringify({
			transactionId: transactionId,
			messageCount: transactions[transactionId]
		}));
	});
	Object.keys(_transaction).forEach(function(path) {
		_transaction[path][1].finishingTransaction = true;
		if(/\/\.history\//.test(_transaction[path][0])) {
			window.getFileCache[_transaction[path][0]] = {codec: _transaction[path][1].codec, contents: _transaction[path][2], ts: Date.now()};
		}
		putFile.apply(window, _transaction[path]);
	});
}<commit_msg>Fix comitting transactions in which a file was changed more than one time<commit_after>/* This file is licensed under the Affero General Public License. */

/*global _, jsyaml, esprima, estraverse, string, io, File, XDomainRequest, JSZip, getFile: true, putFile: true, prepareFile: true, prepareString: true, prepareUrl: true, startTransaction: true, endTransaction: true, resolve: true, basename: true, deepEquals: true */

var core_version = 3;

var settings = {};

var inTransaction = false;
var transaction = null;
var transactionDate;
var transactionIdPrefix;
var filesToPut;
function startTransaction() {
	inTransaction = true;
	if(!transaction) {
		transaction = {};
		transactionDate = new Date();
		transactionIdPrefix = Math.round(Math.random() * Date.now()).toString(16);
		filesToPut = 0;
	}
}
window.startTransaction = startTransaction;
function endTransaction() {
	console.trace(inTransaction, filesToPut, transaction);
	if(!transaction) return;
	inTransaction = false;
	if(filesToPut) return;
	var _transaction = transaction;
	transaction = null;
	var transactions = {};
	var fileNamesSeen = {};
	Object.keys(_transaction).forEach(function(path) {
		var transactionId = getTransactionId(_transaction[path][1]);
		if(!transactions[transactionId]) {
			transactions[transactionId] = 0;
		}
		if(/\.history\/.+/.test(_transaction[path][0])) {
			transactions[transactionId]++;
			var nonHistFileName = _transaction[path][0].split('.history/')[0];
			if(!fileNamesSeen[nonHistFileName]) {
				fileNamesSeen[nonHistFileName] = true;
				transactions[transactionId]++;
			}
		} else {
			transactions[transactionId]++;
		}
	});
	Object.keys(transactions).forEach(function(transactionId) {
		var req = new XMLHttpRequest();
		req.open('POST', '/transaction/add');
		req.setRequestHeader('Content-Type', 'application/json');
		req.send(JSON.stringify({
			transactionId: transactionId,
			messageCount: transactions[transactionId]
		}));
	});
	Object.keys(_transaction).forEach(function(path) {
		_transaction[path][1].finishingTransaction = true;
		if(/\/\.history\//.test(_transaction[path][0])) {
			window.getFileCache[_transaction[path][0]] = {codec: _transaction[path][1].codec, contents: _transaction[path][2], ts: Date.now()};
		}
		putFile.apply(window, _transaction[path]);
	});
}
{'fraction_non_alphanumeric': 0.14844835572024084, 'fraction_numerical': 0.006252894858730894, 'mean_word_length': 5.675425038639877, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7328274', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1291, 'n_words': 280}