src/common/storage/util.js
function (project, projectJson, options, callback) {
            var deferred = Q.defer(),
                toPersist = {},
                rootHash = projectJson.rootHash,
                defaultCommitMessage = 'Importing contents of [' +
                    projectJson.projectId + '@' + rootHash + ']',
                objects = projectJson.objects,
                i;

            for (i = 0; i < objects.length; i += 1) {
                // we have to patch the object right before import, for smoother usage experience
                toPersist[objects[i]._id] = objects[i];
            }

            options = options || {};

            options.branch = options.branch || null;
            options.parentCommit = options.parentCommit || [];

            project.makeCommit(options.branch, options.parentCommit,
                rootHash, toPersist, options.commitMessage || defaultCommitMessage)
                .then(function (commitResult) {
                    deferred.resolve(commitResult);
                })
                .catch(deferred.reject);

            return deferred.promise.nodeify(callback);
        }
function (project, projectJson, options, callback) {
            var deferred = Q.defer(),
                toPersist = {},
                rootHash = projectJson.rootHash,
                defaultCommitMessage = 'Importing contents of [' +
                    projectJson.projectId + '@' + rootHash + ']',
                objects = projectJson.objects,
                i;

            for (i = 0; i < objects.length; i += 1) {
                // we have to patch the object right before import, for smoother usage experience
                toPersist[objects[i]._id] = objects[i];
            }

            options = options || {};

            options.branch = options.branch || null;
            options.parentCommit = options.parentCommit || [];

            project.makeCommit(options.branch, options.parentCommit,
                rootHash, toPersist, options.commitMessage || defaultCommitMessage)
                .then(function (commitResult) {
                    deferred.resolve(commitResult);
                })
                .catch(deferred.reject);

            return deferred.promise.nodeify(callback);
        }
function ( project , projectJson , options , callback ) { var deferred = Q . defer ( ) , toPersist = { } , rootHash = projectJson . rootHash , defaultCommitMessage = 'Importing contents of [' + projectJson . projectId + '@' + rootHash + ']' , objects = projectJson . objects , i ; for ( i = 0 ; i < objects . length ; i += 1 ) { // we have to patch the object right before import, for smoother usage experience toPersist [ objects [ i ] . _id ] = objects [ i ] ; } options = options || { } ; options . branch = options . branch || null ; options . parentCommit = options . parentCommit || [ ] ; project . makeCommit ( options . branch , options . parentCommit , rootHash , toPersist , options . commitMessage || defaultCommitMessage ) . then ( function ( commitResult ) { deferred . resolve ( commitResult ) ; } ) . catch ( deferred . reject ) ; return deferred . promise . nodeify ( callback ) ; }
Inserts a serialized project tree into the storage and associates it with a commitHash.

@param {ProjectInterface} project
@param {object} [options]
@param {string} [options.branch] - Name of branch to update
@param {string} [options.parentCommit] - Array of parents for new commit
@param {string} [options.commitMessage=%defaultCommitMessage%] information about the insertion
@param {function(Error, hashes)} callback
Inserts a serialized project tree into the storage and associates it with a commitHash .