fix bug in tracking parent commits

This commit is contained in:
Raghu Rajagopalan
2016-03-28 13:17:31 +05:30
parent 5cb44d55ff
commit 038062b3c3

View File

@@ -1,7 +1,8 @@
var crypto = require("crypto"); var crypto = require("crypto");
var Logger = require('../../logger'); var Logger = require('../../logger');
var log = new Logger.Log();
var _ = require("lodash"); var _ = require("lodash");
var log = new Logger.Log();
//var log = new Logger.Log(1); //var log = new Logger.Log(1);
@@ -18,17 +19,14 @@ function getId() {
function isfastforwardable(currentCommit, otherCommit) { function isfastforwardable(currentCommit, otherCommit) {
var currentSeq = currentCommit.seq; log.debug("Entering isfastforwardable:", currentCommit.id, otherCommit.id);
var otherSeq = otherCommit.seq; while (currentCommit.seq <= otherCommit.seq && currentCommit != otherCommit) {
log.debug(commits);
log.debug(currentCommit, otherCommit);
while (currentSeq <= otherSeq && currentCommit != otherCommit) {
// only if other branch has more commits // only if other branch has more commits
if (otherCommit.parent == null) break; if (otherCommit.parent == null) break;
if (Array.isArray(otherCommit.parent)){ if (Array.isArray(otherCommit.parent)){
return isfastforwardable(currentCommit, otherCommit.parent[0]) || log.debug("In merge commit:", otherCommit.parent);
isfastforwardable(currentCommit, otherCommit.parent[1]) return isfastforwardable(currentCommit, commits[otherCommit.parent[0]]) ||
isfastforwardable(currentCommit, commits[otherCommit.parent[1]])
} else { } else {
otherCommit = commits[otherCommit.parent]; otherCommit = commits[otherCommit.parent];
} }
@@ -80,7 +78,7 @@ exports.merge = function(otherBranch) {
id: getId(), id: getId(),
message: 'merged branch ' + otherBranch + ' into ' + curBranch, message: 'merged branch ' + otherBranch + ' into ' + curBranch,
seq: seq++, seq: seq++,
parent: [head == null ? null : head.id, commits[branches[otherBranch]]] parent: [head == null ? null : head.id, branches[otherBranch]]
}; };
head = commit; head = commit;
commits[commit.id] = commit; commits[commit.id] = commit;