<commit_before>/*
 * A diff to be uploaded to a server.
 *
 * For now, this is used only for uploading new diffs.
 *
 * It is expected that parentObject will be set to a ReviewRequest instance.
 */
RB.Diff = RB.BaseResource.extend({
    rspNamespace: 'diff',

    getErrorString: function(rsp) {
        if (rsp.err.code == 207) {
            return 'The file "' + rsp.file + '" (revision ' + rsp.revision +
                    ') was not found in the repository';
        }

        return rsp.err.msg;
    }
});
<commit_msg>Enhance RB.Diff to be able to create new diffs.<commit_after>/*
 * A diff to be uploaded to a server.
 *
 * For now, this is used only for uploading new diffs.
 *
 * It is expected that parentObject will be set to a ReviewRequest instance.
 */
RB.Diff = RB.BaseResource.extend({
    defaults: {
        diff: null,
        parentDiff: null,
        basedir: ''
    },

    payloadFileKeys: ['path', 'parent_diff_path'],

    rspNamespace: 'diff',

    getErrorString: function(rsp) {
        if (rsp.err.code == 207) {
            return 'The file "' + rsp.file + '" (revision ' + rsp.revision +
                    ') was not found in the repository';
        }

        return rsp.err.msg;
    },

    toJSON: function() {
        var payload;

        if (this.isNew()) {
            payload = {
                basedir: this.get('basedir'),
                path: this.get('diff'),
                parent_diff_path: this.get('parentDiff')
            };
        } else {
            payload = RB.BaseResource.prototype.toJSON.apply(this, arguments);
        }

        return payload;
    }
});

{'fraction_non_alphanumeric': 0.1206896551724138, 'fraction_numerical': 0.003694581280788177, 'mean_word_length': 1.8863232682060391, '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': '1205556', 'n_tokens_mistral': 503, 'n_tokens_neox': 478, 'n_words': 144}