<commit_before>'use strict';

var environment = require('./lib/environment'),
    atomPerforce = require('./lib/atom-perforce');

function setupEnvironment() {
    return environment.loadVarsFromEnvironment([
        'PATH',
        'P4CONFIG',
        'P4DIFF',
        'P4IGNORE',
        'P4MERGE',
        'P4PORT',
        'P4USER',
        'PAGER',
        'PATH'
    ]).catch(function(err) {
        console.error('could not load environment variables:', err);
        // try simply making sure /usr/local/bin (the default p4 location) is in the path
        // TODO: fallback for windows?
        if(process.platform !== 'win32') {
            if(process.env.PATH.split(':').indexOf('/usr/local/bin') === -1) {
                process.env.PATH = process.env.PATH + ':/usr/local/bin';
            }
        }
    });
}

function setupObservers() {
    return atom.workspace.observeTextEditors(function(editor) {
        // mark changes on save
        editor.buffer.onDidSave(function(file) {
            atomPerforce.getChanges()
            .then(function(changes) {
                atomPerforce.showDiffMarks(file.path, changes);
            });
        });

        // mark changes on initial load
        if(editor.getPath()) {
            atomPerforce.getChanges(editor)
            .then(function(changes) {
                atomPerforce.showDiffMarks(editor.getPath(), changes);
            });
        }

        atomPerforce.showClientName();
    });
}

function setupCommands() {
    atom.commands.add('atom-workspace', 'perforce:edit', atomPerforce.edit);
    atom.commands.add('atom-workspace', 'perforce:add', atomPerforce.add);
    atom.commands.add('atom-workspace', 'perforce:sync', atomPerforce.sync);
    atom.commands.add('atom-workspace', 'perforce:revert', atomPerforce.revert);
    atom.commands.add('atom-workspace', 'perforce:load-opened-files', atomPerforce.loadAllOpenFiles);
}

module.exports = {
    activate: function activate(/*state*/) {
        setupEnvironment()<commit_msg>added p4 prefix/namespace for each command<commit_after>'use strict';

var environment = require('./lib/environment'),
    atomPerforce = require('./lib/atom-perforce');

function setupEnvironment() {
    return environment.loadVarsFromEnvironment([
        'PATH',
        'P4CONFIG',
        'P4DIFF',
        'P4IGNORE',
        'P4MERGE',
        'P4PORT',
        'P4USER',
        'PAGER',
        'PATH'
    ]).catch(function(err) {
        console.error('could not load environment variables:', err);
        // try simply making sure /usr/local/bin (the default p4 location) is in the path
        // TODO: fallback for windows?
        if(process.platform !== 'win32') {
            if(process.env.PATH.split(':').indexOf('/usr/local/bin') === -1) {
                process.env.PATH = process.env.PATH + ':/usr/local/bin';
            }
        }
    });
}

function setupObservers() {
    return atom.workspace.observeTextEditors(function(editor) {
        // mark changes on save
        editor.buffer.onDidSave(function(file) {
            atomPerforce.getChanges()
            .then(function(changes) {
                atomPerforce.showDiffMarks(file.path, changes);
            });
        });

        // mark changes on initial load
        if(editor.getPath()) {
            atomPerforce.getChanges(editor)
            .then(function(changes) {
                atomPerforce.showDiffMarks(editor.getPath(), changes);
            });
        }

        atomPerforce.showClientName();
    });
}

function setupCommands() {
    ['perforce', 'p4'].forEach(function(prefix) {
        atom.commands.add('atom-workspace', prefix + ':edit', atomPerforce.edit);
        atom.commands.add('atom-workspace', prefix + ':add', atomPerforce.add);
        atom.commands.add('atom-workspace', prefix + ':sync', atomPerforce.sync);
        atom.commands.add('atom-workspace', prefix + ':revert', atomPerforce.revert);
        atom.commands.add('atom-workspace', prefix + ':load-opened-files', atomPerforce.loadAllOpenFiles);
    });
}

module.exports = {
    activate: function activate(/*state*/) {
        setupEnvironment()
{'fraction_non_alphanumeric': 0.14806763285024155, 'fraction_numerical': 0.005314009661835749, 'mean_word_length': 2.411037891268534, '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': '6654620', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1197, 'n_words': 205}