void ConflictResult::assignResult(svn_wc_conflict_result_t**aResult,const Pool&pool)const { #if ((SVN_VER_MAJOR == 1) && (SVN_VER_MINOR >= 5)) || (SVN_VER_MAJOR > 1) svn_wc_conflict_choice_t _choice; switch (choice()) { case ConflictResult::ChooseBase: _choice=svn_wc_conflict_choose_base; break; case ConflictResult::ChooseTheirsFull: _choice=svn_wc_conflict_choose_theirs_full; break; case ConflictResult::ChooseMineFull: _choice=svn_wc_conflict_choose_mine_full; break; case ConflictResult::ChooseTheirsConflict: _choice=svn_wc_conflict_choose_theirs_conflict; break; case ConflictResult::ChooseMineConflict: _choice=svn_wc_conflict_choose_mine_conflict; break; case ConflictResult::ChooseMerged: _choice=svn_wc_conflict_choose_merged; break; case ConflictResult::ChoosePostpone: default: _choice=svn_wc_conflict_choose_postpone; break; } const char* _merged_file = mergedFile().isNull()?0:apr_pstrdup (pool,mergedFile().toUtf8()); if ((*aResult)==0) { (*aResult) = svn_wc_create_conflict_result(_choice,_merged_file,pool); } else { (*aResult)->choice=_choice; (*aResult)->merged_file=_merged_file; } #else Q_UNUSED(aResult); Q_UNUSED(pool); #endif }
//merges two files //eliminates duplicate entries by comparing substrings up to the first occurance of delim //then combines the lines after delim by concatenating with conn //returns a reference to the mergeCount for use by larger programs can update it //so that mergeFiles will not overwrite externally created merge files //note that mergeCount is equal to the number in the current merge file upon function start //and is off by 1 upon function completion int& mergeFiles(const string &f1, const string &f2, const char delim, const char conn, string mergeFileName) { static int mergeCount = 0; ifstream file1(f1), file2(f2); ofstream mergedFile(mergeFileName); char buffer1[LINE_BUFFER_SIZE], buffer2[LINE_BUFFER_SIZE]; string line1 = "", line2 = ""; while(file1.good() && file2.good()) { if(line1 == "") { file1.getline(buffer1,LINE_BUFFER_SIZE,'\n'); if(file1.eof()) { break; } while(file1.fail() && !file1.eof()) { line1 += buffer1; file1.clear(); file1.getline(buffer1,LINE_BUFFER_SIZE,'\n'); } line1 += buffer1; } if(line2 == "") { file2.getline(buffer2,LINE_BUFFER_SIZE,'\n'); if(file2.eof()) { break; } while(file2.fail()) { line2 += buffer2; file2.clear(); file2.getline(buffer2,LINE_BUFFER_SIZE,'\n'); } line2 += buffer2; } static int delim1, delim2; delim1 = line1.find(delim); delim2 = line2.find(delim); if(line1.substr(0,delim1) == line2.substr(0,delim2)) { line1 += conn + line2.substr(delim2+1); line2 = ""; } else if(line1.substr(0,delim1) > line2.substr(0,delim2)) { mergedFile << line2 << endl; line2 = ""; } else { mergedFile << line1 << endl; line1 = ""; } } if(file1.good()) { mergedFile << line1 << endl; while(file1.getline(buffer1,LINE_BUFFER_SIZE,'\n')) { line1 = buffer1; while(file1.fail() && !file1.eof()) { line1 += buffer1; file1.clear(); file1.getline(buffer1,LINE_BUFFER_SIZE,'\n'); } mergedFile << line1 << endl; } } else if(file2.good()) { mergedFile << line2 << endl; while(file2.getline(buffer2,LINE_BUFFER_SIZE,'\n')) { line2 = buffer2; while(file2.fail()) { line2 += buffer2; file2.clear(); file2.getline(buffer2,LINE_BUFFER_SIZE,'\n'); } mergedFile << line2 << endl; } } file1.close(); file2.close(); mergedFile.close(); return mergeCount; }