raftLog: compact applied entries only

compact MUST happen on entries that have been applied, or
1. it may screw up the log by setting wrong commitIndex
2. discard unapplied entries
Merge pull request #1049 from unihorn/120

raftLog: enhance check in compact