comparison rep/handler/Editor.java @ 488:c49a86a7ab8f

termination of new merge command...
author one
date Thu, 21 Oct 2010 23:03:22 +0900
parents 455df381449a
children 4aba8ae3125b
comparison
equal deleted inserted replaced
487:455df381449a 488:c49a86a7ab8f
375 public String toString(){ 375 public String toString(){
376 return ("Editor eid="+eid+" sid="+sid+" " + host + ":" + file); 376 return ("Editor eid="+eid+" sid="+sid+" " + host + ":" + file);
377 } 377 }
378 378
379 void checkEndMerge() { 379 void checkEndMerge() {
380 if (merging) { 380 if (blocking) {
381 if (isMerging()) return; 381 if (isMerging()) return;
382 endMerge(); 382 endMerge();
383 merging = false;
384 blocking = false; 383 blocking = false;
385 } 384 }
386 if (quit_2!=null) checkQuit(); 385 if (quit_2!=null) checkQuit();
387 } 386 }
388 387
475 keep.string = ""; 474 keep.string = "";
476 next.send(keep); 475 next.send(keep);
477 } 476 }
478 477
479 private boolean checkQuit() { 478 private boolean checkQuit() {
480 if (quit_2!=null && ackList.size()==0 && sentList.size()==0&&!isMerging() && waitingCommandInMerge.size()==0) { 479 if (quit_2!=null && ackList.size()==0 &&!isMerging() && waitingCommandInMerge.size()==0) {
480 if (emptySentList() ){
481 sendToEditor(quit_2); 481 sendToEditor(quit_2);
482 quit_2 = null; 482 quit_2 = null;
483 return true; 483 return true;
484 }
484 } 485 }
485 return false; 486 return false;
487 }
488
489 private boolean emptySentList() {
490 return sentList.size()==0||(sentList.size()==1 && sentList.getFirst().cmd==REP.REPCMD_MERGE_MARK);
486 } 491 }
487 492
488 @Override 493 @Override
489 public boolean manage(REPCommand command) { 494 public boolean manage(REPCommand command) {
490 495
714 */ 719 */
715 sentMergedList.clear(); 720 sentMergedList.clear();
716 List<REPCommand> output1 = optimizer.optimize(output); 721 List<REPCommand> output1 = optimizer.optimize(output);
717 if (output1.size()==0) { 722 if (output1.size()==0) {
718 merging = false; 723 merging = false;
719 blocking = false;
720 return false; 724 return false;
721 } 725 }
722 for(REPCommand c:output1) { 726 for(REPCommand c:output1) {
723 REPCommand m = new REPCommand(c); 727 REPCommand m = new REPCommand(c);
724 m.setEID(REP.MERGE_EID.id); 728 m.setEID(REP.MERGE_EID.id);
781 sentMergedList.removeFirst(); 785 sentMergedList.removeFirst();
782 } 786 }
783 // previous merge command may be returned 787 // previous merge command may be returned
784 788
785 if(sentMergedList.size()==0 && !mergeAgain) { 789 if(sentMergedList.size()==0 && !mergeAgain) {
786 // this is duplicate...
787 merging=false; 790 merging=false;
788 blocking = false;
789 } 791 }
790 return mergeAgain; 792 return mergeAgain;
791 } 793 }
792 794
793 public void getMergeAgain() { 795 public void getMergeAgain() {
794 if (sentMergedList.size()>0) return; // wait for previous merge completion 796 if (sentMergedList.size()>0) return; // wait for previous merge completion
795 if (mergeMode==MergeMode.Direct) { 797 if (mergeMode==MergeMode.Direct) {
796 logger.writeLog("MergeAgain "+eid); 798 logger.writeLog("MergeAgain "+eid);
799 mergeAgain = false;
797 merge(preMergeCommand); 800 merge(preMergeCommand);
798 return; 801 return;
799 } 802 }
800 803
801 LinkedList<REPCommand> returnCommand = new LinkedList<REPCommand>(); 804 LinkedList<REPCommand> returnCommand = new LinkedList<REPCommand>();