RFE #436548 Allow WinMerge to merge CVS conflict files
http://winmerge.org/rfe/436548
This is currently our oldest open RFE. And we've got *lots* of queries about it. But now I finally have implementation that works.
For parsing conflict file I took TortoiseCVS's parser code (src/TortoiseAct/ConflictParser.cpp in their source tree) and modified it to work with WinMerge codebase. Then I added needed temp file handling and GUI.
I have so far tested this with one conflict file as I'm not sure which kind of files different systems produce. They have same basic structure, but I think separator chars/lines differ a bit. But I want to commit this initial implementation first and then improve and add support for more formats as we find them.
Original and altered files.
Example conflict file
Logged In: YES
user_id=631874
Originator: YES
Adding example conflict file. Feel free to send me more from different systems.
File Added: CompareOptions.h
Updated patch - my to mine change
Logged In: YES
user_id=631874
Originator: YES
I changed 'my' to 'mine' in shown file descriptions. 'mine' is term used in lots of documentation, program help files etc.
Attaching updated patch.
File Added: ResolveConflictFile2.zip
Logged In: YES
user_id=631874
Originator: YES
Committed to SVN trunk:
Completed: At revision: 4934
Updated English.pot and all PO files:
Completed: At revision: 4935
Logged In: YES
user_id=631874
Originator: YES
Attaching a patch to set right-side "mine" (user's workspace) file to modified right after opening conflict files. This allows user to save "mine" file as resolved file by just saving the file. And also prevents accidentally closing files without changes when the resolved file doesn't get saved at all.
File Added: SetConflictFileModified.zip
Patch to set conflict "mine" file modified
Logged In: YES
user_id=954028
Originator: NO
I found two problems.
WinMerge can compare your example file 'CompareOptions.h' that has Unix style EOL. But if opening a conflict file that has DOS style EOL, WinMerge displays extra EOL.
Index: ConflictFileParser.cpp
--- ConflictFileParser.cpp (revision 4937)
+++ ConflictFileParser.cpp (working copy)
@@ -56,8 +56,8 @@
BOOL success = conflictFile.OpenReadOnly(conflictFileName.c_str());
- BOOL success2 = workingCopy.Open(workingCopyFileName.c_str(), _T("w"));
- BOOL success3 = newRevision.Open(newRevisionFileName.c_str(), _T("w"));
+ BOOL success2 = workingCopy.Open(workingCopyFileName.c_str(), _T("wb"));
+ BOOL success3 = newRevision.Open(newRevisionFileName.c_str(), _T("wb"));
WinMerge displays their file as my file. And vice versa.
Index: MainFrm.cpp
--- MainFrm.cpp (revision 4937)
+++ MainFrm.cpp (working copy)
@@ -3480,8 +3480,8 @@
m_strSaveAsPath = conflictFile;
String theirs = LoadResString(IDS_CONFLICT_THEIRS_FILE);
String my = LoadResString(IDS_CONFLICT_MINE_FILE);
- m_strDescriptions[0] = theirs;
- m_strDescriptions[1] = my;
+ m_strDescriptions[0] = my;
+ m_strDescriptions[1] = theirs;
DoFileOpen(workFile.c_str(), revFile.c_str(),
FFILEOPEN_READONLY |FFILEOPEN_NOMRU, FFILEOPEN_NOMRU );
}
Logged In: YES
user_id=631874
Originator: YES
Thanks a lot for testing!
First fix is good. I was myself apparently mostly testing with Unix files as I've been using Cygwin/Mercurial as my local repository. So I didn't notice this, otherwise than some weird additional linefeeds.
Second fix is not correct. We need to set "my" file as right-side file. That way user can save it right away as a resolved file. And all programs I know of set "my" file as right-side file.
Correct fix is of course this:
- DoFileOpen(workFile.c_str(), revFile.c_str(),
- FFILEOPEN_READONLY |FFILEOPEN_NOMRU, FFILEOPEN_NOMRU );
+ DoFileOpen(revFile.c_str(), workFile.c_str(),
+ FFILEOPEN_READONLY |FFILEOPEN_NOMRU, FFILEOPEN_NOMRU );
I was just too happy to get the whole thing working I didn't even notice this. :(
Logged In: YES
user_id=631874
Originator: YES
First fix committed to SVN:
Completed: At revision: 4939
Second (my version) committed to SVN:
Completed: At revision: 4940
Logged In: YES
user_id=631874
Originator: YES
Committed the patch to set "mine" file as modified.
Completed: At revision: 4944
Closing this patch item now.
Logged In: YES
user_id=631874
Originator: YES
In ConflictFileParser.cpp, replaced block marker strings in the code with string constants defined in begin of the file. I got a conflict into this file and parser got confused about those strings.
Completed: At revision: 4945