Skip to content

Commit

Permalink
removed the FileLog.Entry field from Record
Browse files Browse the repository at this point in the history
  • Loading branch information
bchang committed Feb 27, 2012
1 parent ee6c247 commit 0b608d0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
Expand Up @@ -154,7 +154,7 @@ class P4Blame implements IP4Blame
if (recordsChangedWithinPath.Count > 0) {
var changeInfo = new ChangeInfo(logEntry)
for (rec in recordsChangedWithinPath) {
rec.discovered(logEntry, changeInfo)
rec.discovered(changeInfo)
for (listener in _listeners) {
listener.lineDiscovered(rec)
}
Expand Down
5 changes: 1 addition & 4 deletions p4blame/src/main/java/com/github/bchang/p4/blame/Record.gs
@@ -1,13 +1,11 @@
package com.github.bchang.p4.blame

uses com.github.bchang.p4.base.FileLog
uses com.github.bchang.p4.base.IP4BlameLine
uses com.github.bchang.p4.base.IP4ChangeInfo
uses java.lang.Integer

class Record implements IP4BlameLine
{
var _fileLogEntry : FileLog.Entry as readonly LogEntry // TODO - this can go away when I write ConsoleBlame
var _changeInfo : IP4ChangeInfo as readonly ChangeInfo
var _line : String as readonly Line
var _id : Integer as readonly Id
Expand All @@ -17,8 +15,7 @@ class Record implements IP4BlameLine
_id = i
}

function discovered(entry : FileLog.Entry, change : IP4ChangeInfo) {
_fileLogEntry = entry
function discovered(change : IP4ChangeInfo) {
_changeInfo = change
}

Expand Down
21 changes: 10 additions & 11 deletions p4blame/src/main/java/com/github/bchang/p4/blame/RecordList.gs
Expand Up @@ -34,24 +34,23 @@ class RecordList implements List<Record>
function writeTo(writer : Writer) {
if (_title != null) writer.append(_title + "\n")

var header = { "Change", "Date", "P4 Op", "User", "Path", "", "Line"}
var header = { "Change", "Date", "User", "Path", "", "Line"}

var lineNumberColumnWidth = (this.Count as String).length()

var c = { 7, 11, 9, 10, 78, lineNumberColumnWidth, 1000 }
var headerFmt = "%1$-"+c[0]+"s" + " %2$-"+c[1]+"s" + "%3$-"+c[2]+"s" + " %4$-"+c[3]+"s" + " %5$-"+c[4]+"s" + " %6$-"+c[5]+"s %7$-"+c[6]+"s"
var rowFmt = "%1$-"+c[0]+"s" + " %2$-"+c[1]+"s" + "%3$-"+c[2]+"s" + " %4$-"+c[3]+"s" + " %5$-"+c[4]+"s" + " %6$" +c[5]+"s %7$-"+c[6]+"s"
var c = { 7, 11, 10, 78, lineNumberColumnWidth, 1000 }
var headerFmt = "%1$-"+c[0]+"s" + " %2$-"+c[1]+"s" + " %3$-"+c[2]+"s" + " %4$-"+c[3]+"s" + " %5$-"+c[4]+"s %6$-"+c[5]+"s"
var rowFmt = "%1$-"+c[0]+"s" + " %2$-"+c[1]+"s" + " %3$-"+c[2]+"s" + " %4$-"+c[3]+"s" + " %5$" +c[4]+"s %6$-"+c[5]+"s"

writer.append(String.format(headerFmt, header.toTypedArray()).trim()).append("\n")
for (rec in this index i) {
writer.append(String.format(rowFmt, new String[] {
rec.LogEntry.Change as String,
rec.LogEntry.Date,
truncate(rec.LogEntry.Op, c[2], 1, ""),
rec.LogEntry.User,
truncate(rec.LogEntry.PathRev as String, c[4], 0, "..."),
rec.ChangeInfo.Change as String,
rec.ChangeInfo.Date,
rec.ChangeInfo.User,
truncate(rec.ChangeInfo.Path, c[3], 0, "..."),
(i + 1) as String,
truncate(rec.Line, c[6], 1, "...")
truncate(rec.Line, c[4], 1, "...")
}).trim()).append("\n")
}
}
Expand All @@ -75,7 +74,7 @@ class RecordList implements List<Record>

function isComplete() : boolean {
for (rec in this) {
if (rec != null and rec.LogEntry == null) {
if (rec != null and rec.ChangeInfo == null) {
return false
}
}
Expand Down
Expand Up @@ -218,7 +218,7 @@ class P4BlameTest extends AbstractP4Test {
}

function assertThat(recordList : RecordList) : ListAssert {
var stringEntries = recordList.map( \ rec -> rec.LogEntry.Change + ":" + rec.LogEntry.User + ":" + rec.LogEntry.PathRev + ":" + rec.Line )
var stringEntries = recordList.map( \ rec -> rec.ChangeInfo.Change + ":" + rec.ChangeInfo.User + ":" + rec.ChangeInfo.Path + ":" + rec.Line )
return Assertions.assertThat(stringEntries)
}
}

0 comments on commit 0b608d0

Please sign in to comment.