changeset 488:c49a86a7ab8f

termination of new merge command...
author one
date Thu, 21 Oct 2010 23:03:22 +0900
parents 455df381449a
children 4aba8ae3125b
files rep/handler/Editor.java
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/rep/handler/Editor.java	Thu Oct 21 22:35:37 2010 +0900
+++ b/rep/handler/Editor.java	Thu Oct 21 23:03:22 2010 +0900
@@ -377,10 +377,9 @@
 	}
 
 	void checkEndMerge() {
-		if (merging) {
+		if (blocking) {
 			if (isMerging()) return;
 			endMerge();
-			merging = false;
 			blocking = false;
 		}
 		if (quit_2!=null) checkQuit();
@@ -477,14 +476,20 @@
 	}
 
 	private boolean checkQuit() {
-		if (quit_2!=null && ackList.size()==0 && sentList.size()==0&&!isMerging() && waitingCommandInMerge.size()==0) {
+		if (quit_2!=null && ackList.size()==0 &&!isMerging() && waitingCommandInMerge.size()==0) {
+			if (emptySentList() ){
 			sendToEditor(quit_2);
 			quit_2 = null;
 			return true;
+			}
 		}
 		return false;
 	}
 
+	private boolean emptySentList() {
+		return sentList.size()==0||(sentList.size()==1 && sentList.getFirst().cmd==REP.REPCMD_MERGE_MARK);
+	}
+
 	@Override
 	public boolean manage(REPCommand command) {
 		
@@ -716,7 +721,6 @@
 		List<REPCommand> output1 = optimizer.optimize(output);
 		if (output1.size()==0) {
 			merging = false;
-			blocking = false;
 			return false;
 		}
 		for(REPCommand c:output1) {
@@ -783,9 +787,7 @@
 		//  previous merge command may be returned
 
 		if(sentMergedList.size()==0 && !mergeAgain) {
-			// this is duplicate...
 			merging=false;
-			blocking = false;
 		}
 		return mergeAgain;
 	}
@@ -794,6 +796,7 @@
 		if (sentMergedList.size()>0) return; //  wait for previous merge completion
 		if (mergeMode==MergeMode.Direct) {
 			logger.writeLog("MergeAgain "+eid);
+			mergeAgain = false;
 			merge(preMergeCommand);
 			return;
 		}