%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /data/old/home/stash/atlassian/stash/3.7.1/atlassian-stash/static/model/
Upload File :
Create Path :
Current File : //data/old/home/stash/atlassian/stash/3.7.1/atlassian-stash/static/model/file-change.js

define('model/file-change', [
    'backbone-brace',
    'util/deprecation',
    'model/commit-range',
    'model/conflict',
    'model/file-change-types',
    'model/path',
    'model/repository'
], function (
    Brace,
    deprecate,
    CommitRange,
    Conflict,
    ChangeType,
    Path,
    Repository
) {

    'use strict';

    var FileChange = Brace.Model.extend({
        namedAttributes : {
            "repository" : Repository,
            "commitRange" : CommitRange,
            "srcPath" : Path,
            "path" : Path,
            "line" : null,
            "search" : null,
            "type" : null,
            "nodeType" : null,
            "conflict" : Conflict,
            "diff" : null,
            "srcExecutable" : null,
            "executable" : null
        },
        initialize : function() {
            // BEGIN - remove in 4.0 when we stop deprecating Path in JSON output
            // This check avoids those nested deprecations sticking around in Brace-to-JSON-to-Brace conversion loops.
            if (this.getPath()) {
                this.setPath(new Path(this.getPath()));
            }
            if (this.getSrcPath()) {
                this.setSrcPath(new Path(this.getSrcPath()));
            }
            // END - remove in 4.0 when we stop deprecating path in JSON output

            this.setType(
                FileChange._mapChangeType(
                    this.getType(),
                    this.getSrcPath(),
                    this.getPath()
                )
            );
        }
    }, {
        fromDiff : function(diffJson, commitRange, repository) {
            return new FileChange({
                repository : repository,
                commitRange : commitRange,
                srcPath : diffJson.source,
                path : diffJson.destination,
                diff : diffJson,
                type: ChangeType.guessChangeTypeFromDiff(diffJson)
            });
        },
        _mapChangeType : function(modState, srcPath, path) {
            return (modState === ChangeType.MOVE && srcPath && srcPath.isSameDirectory(path)) ?
                    ChangeType.RENAME :
                    ChangeType.changeTypeFromId(modState);
        }
    });

    //Deprecation - Remove in 4.0
    (function (oldToJSON) {
        FileChange.prototype.toJSON = function() {
            var path = this.getPath();
            var srcPath = this.getSrcPath();

            // temporarily unset to avoid deprecation warning during oldToJSON
            this.setPath(null);
            this.setSrcPath(null);

            var json = oldToJSON.apply(this, arguments);
            if (path) {
                json.path = deprecate.jsonAsBrace(path, '3.2', '4.0');
            }
            if (srcPath) {
                json.srcPath = deprecate.jsonAsBrace(srcPath, '3.2', '4.0');
            }
            this.setPath(path);
            this.setSrcPath(srcPath);
            return json;
        };
    })(FileChange.prototype.toJSON);

    return FileChange;
});

Zerion Mini Shell 1.0