better structure

This commit is contained in:
Peter Cottle 2012-11-03 14:45:26 -07:00
parent 4e9e48ab4b
commit d485120f44

View file

@ -48,6 +48,7 @@ GitEngine.prototype.init = function() {
GitEngine.prototype.exportTree = function() { GitEngine.prototype.exportTree = function() {
// need to export all commits, their connectivity / messages, branches, and state of head. // need to export all commits, their connectivity / messages, branches, and state of head.
// this would be simple if didn't have circular structures.... :P // this would be simple if didn't have circular structures.... :P
// thus, we need to loop through and "flatten" our graph of objects referencing one another
var totalExport = { var totalExport = {
branches: {}, branches: {},
commits: {}, commits: {},
@ -62,8 +63,10 @@ GitEngine.prototype.exportTree = function() {
}); });
_.each(this.commitCollection.toJSON(), function(commit) { _.each(this.commitCollection.toJSON(), function(commit) {
commit.visNode = undefined; // clear out the fields that reference objects and create circular structure
commit.children = []; _.each(Commit.prototype.constants.circularFields, function(field) {
commit[field] = undefined;
}, this);
// convert parents // convert parents
var parents = []; var parents = [];
@ -1450,6 +1453,10 @@ var Commit = Backbone.Model.extend({
gitVisuals: null gitVisuals: null
}, },
constants: {
circularFields: ['gitVisuals', 'visNode', 'children']
},
getLogEntry: function() { getLogEntry: function() {
// for now we are just joining all these things with newlines which // for now we are just joining all these things with newlines which
// will get placed by paragraph tags. Not really a fan of this, but // will get placed by paragraph tags. Not really a fan of this, but