changeset 489:4aba8ae3125b

debugging new merge
author one
date Fri, 22 Oct 2010 11:27:57 +0900
parents c49a86a7ab8f
children 168909388479
files rep/handler/Editor.java
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/rep/handler/Editor.java	Thu Oct 21 23:03:22 2010 +0900
+++ b/rep/handler/Editor.java	Fri Oct 22 11:27:57 2010 +0900
@@ -196,13 +196,14 @@
 
 	private void userEditorCommand(REPCommand command) {
 		//エディタからの新たな編集コマンド
-		if (mergeMode==MergeMode.Direct) {
-			truncateSentList(command);
-			ServerMainLoop.logger.writeLog("Editor"+eid+": User Command "+command+report());
-		}
 		if (next==this) return; // singleton case
 		transSendCmd(command);
 		sendEditorCommand(command);
+		if (mergeMode==MergeMode.Direct) {
+			ServerMainLoop.logger.writeLog("Editor"+eid+": User Command Before "+command+report());
+			truncateSentList(command);
+			ServerMainLoop.logger.writeLog("Editor"+eid+": User Command After "+command+report());
+		}
 		return;
 	}
 	
@@ -394,6 +395,7 @@
 			if (last!=null && last.eid==eid && last.sid==sid)
 				truncateSentList(last);
 			preMergeCommand = null;
+			ServerMainLoop.logger.writeLog("Editor"+eid+": EndMerge "+report());
 			return ;
 		}
 		sortedEditCmds = null;
@@ -460,6 +462,10 @@
 		if (flag) sentList = s;
 	}
 
+	/**
+	 * Send ack command after receiving self command
+	 * @param command
+	 */
 	private void sendAck(REPCommand command) {
 		REPCommand keep = new REPCommand(command);
 		// First Phase End, send ACK
@@ -627,7 +633,7 @@
 	 */
 	public REPCommand transSendCmd(REPCommand cmd){
 		assert(cmd.eid==eid);
-		unMergedCmds.addLast(cmd);
+		unMergedCmds.addFirst(cmd);
 		
 		//マージ中にユーザから割り込みがあった場合
 		if(isMerging()){
@@ -651,7 +657,8 @@
 		// merge queue上にあるコマンドを全部undoコマンドするのと同時に
 		// sort したコマンド列を生成する
 		for( REPCommand cmd0 : unMergedCmds) {
-			output.addLast( createUndo(cmd0) );
+			if (cmd0.cmd==REP.REPCMD_INSERT || cmd0.cmd==REP.REPCMD_DELETE) 
+				output.addLast( createUndo(cmd0) );
 		}
 
 		sortedEditCmds = new TreeSet<REPCommand>(new REPCommandComparator(1));
@@ -830,7 +837,7 @@
 	 */
 	public void mergeAck() {
 		logger.writeLog("Editor"+eid+": START MERGE "+
-				((unMergedCmds.size()>0)?" and top of unMergedCmds = "+ unMergedCmds.getLast():""));
+				((unMergedCmds.size()>0)?" unMergedCmds = "+ unMergedCmds : ""));
 		merging = true;
 	}