mlistB.print();
mlistB.print();*/
  public MergeList mergeLists( MergeList mlistA, MergeList mlistB ) {    MergeList merged = new MergeList(mlistA.getEntryParent());    mergeDeletedOrMoved( mlistA, mlistB );// LATER      mergeDeletedOrMovedOut( docA, docB, mlistA, mlistB, docBMatching );/*    System.out.println("A list (after delormove):");    mlistA.print();    System.out.println("B list (after delormove):");    mlistB.print();*/    // Now we should have exactly the same entries in mlistA and mlistB    // quick check    if( mlistA.getEntryCount() != mlistB.getEntryCount() )        throw new RuntimeException("ASSERTION FAILED: MergeList.merge(): lists different lengths!");    // So let's do the merge    // Some things to prove:    // No node can get "skipped" (deleted)    // No node gets extra copies    // Sequencing isn't violated if merge is successful    int posA = 0, posB = 0, nextA=-1,nextB=-1;    while(true) {      // pos is set up so that ea and eb are merge-partners      MergeEntry ea = mlistA.getEntry(posA), eb= mlistB.getEntry(posB);//        MergeEntry chosenEn=ea,otherEn=eb;      merged.add( ea );      // Hangon nodes      if( eb.inserts.size() > 0 ) {        if( ea.inserts.size() > 0 ) {          // Both have hangons,          // add CONFLICTCODE here          // for now, chain A and B hangons          System.out.println("CONFLICTW; both nodes have hangons; sequencing them"); // as updated(or A if no update)-Other");          System.out.println("First list:");          mlistA.print();          System.out.println("Second list:");          mlistB.print();        }        for( int i=0;i<eb.inserts.size();i++)          ea.inserts.add( eb.inserts.elementAt(i) );      }      // See if we're done      if( ea.node == END || eb.node == END ) {        if( ea.node != eb.node )          throw new RuntimeException("ASSERTION FAILED: Merge.mergeLists(). Both cursors not at end");        break;      }      // figure out the next one      nextA = ea.locked && mlistA.getEntry(posA+1).locked ? posA + 1 : -1; // -1 means free      nextB = eb.locked && mlistB.getEntry(posB+1).locked ? posB + 1 : -1;      if( nextA == -1 && nextB == -1 ) { // No locking, just let both go forward        nextA = posA + 1;        nextB = posB + 1;      }      if( nextB == -1 )        nextB = mlistB.findPartner(mlistA.getEntry(nextA));   /// getPartnerPos( mlistA.getEntry(nextA), mlistB, docB, docBMatching );      else if (nextA == -1 )        nextA = mlistA.findPartner(mlistB.getEntry(nextB)); ///getPartnerPos( mlistB.getEntry(nextB), mlistA, docA, this );      else if (nextB != mlistB.findPartner(mlistA.getEntry(nextA))) { //           getPartnerPos( mlistA.getEntry(nextA), mlistB, docB, docBMatching ) ) {        // add CONFLICTCODE here        // for now, follow sequencing of mlist A        System.out.println("CONFLICT: Sequencing conflict, using only one list's sequencing");        nextB = mlistB.findPartner(mlistA.getEntry(nextA)); ///getPartnerPos( mlistA.getEntry(nextA), mlistB, docB, docBMatching);      }      posA = nextA;      posB = nextB;    }/*    System.out.println("Merged list:");    merged.print();*/    return merged;  }