瀏覽代碼

Merge pull request #91 from vmarkovtsev/master

Fix the alive accounting during File merge
Vadim Markovtsev 6 年之前
父節點
當前提交
c6550105b8
共有 2 個文件被更改,包括 9 次插入13 次删除
  1. 8 12
      internal/burndown/file.go
  2. 1 1
      internal/burndown/file_test.go

+ 8 - 12
internal/burndown/file.go

@@ -249,24 +249,20 @@ func (file *File) Merge(day int, others... *File) {
 			if ol & TreeMergeMark == TreeMergeMark {
 				continue
 			}
-			if l & TreeMergeMark == TreeMergeMark {
-				myself[i] = ol
-			} else if l != ol {
-				// the same line introduced in different branches
+			if l & TreeMergeMark == TreeMergeMark || l > ol {
+				// 1 - the line is merged in myself and exists in other
+				// 2 - the same line introduced in different branches,
 				// consider the oldest version as the ground truth
-				if l > ol {
-					myself[i] = ol
-					// subtract from the newer day l
-					file.updateTime(ol, l, -1)
-				} else {
-					// subtract from the newer day ol
-					file.updateTime(l, ol, -1)
-				}
+				//
+				// in case with (2) we should decrease the "future" counter,
+				// but that really poisons the analysis
+				myself[i] = ol
 			}
 		}
 	}
 	for i, l := range myself {
 		if l & TreeMergeMark == TreeMergeMark {
+			// original merge conflict resolution
 			myself[i] = day
 			file.updateTime(day, day, 1)
 		}

+ 1 - 1
internal/burndown/file_test.go

@@ -604,7 +604,7 @@ func TestFileMerge(t *testing.T) {
 	assert.Equal(t, int64(0), status[3])
 	assert.Equal(t, int64(10), status[4])
 	assert.Equal(t, int64(20), status[5])
-	assert.Equal(t, int64(0), status[6])
+	assert.Equal(t, int64(10), status[6])
 	assert.Equal(t, int64(10), status[7])
 }