[Winmerge-development] Organizing folder compare code
Windows visual diff and merge for files and directories
Brought to you by:
christianlist,
grimmdp
From: Kimmo V. <ki...@wi...> - 2007-07-31 21:16:54
|
I've already done some compare code re-org in current trunk. Namely adding CompareOptions class and compare-type specific inherited classes. But now I want to do some serious reorg - something we haven't done since pre 2.0 release when I added threading etc. I try to explain the big picture I have for this first. Our current compare procedure is basically this (inside compare thread): - DirScan_CompareItems() loop through items we have found in collect thread - DirScan_CompareItems() calls CompareDiffItem() for every item in the list - CompareDiffItem() determines item type, checks against filters and does the actual compare, either by comparing attributes or calling FolderCmp class And this is where we have got it wrong always. Even when I've worked with this code for years, its always unclear for me how it really works. What code gets called for which compare method, where compare options are, where results are saved... Our most important code is probably the hardest one to understand. I've earlier written about this into wiki: http://winmerge.org/Wiki/Comparing and the "Architectural rework" section there. I cleaned it up a bit earlier, but that was just a begin so I could myself better understand what happens in the code.. So I have this idea about "Compare Engine" concept. And I want our code being structured so that we have one engine for one compare method. Clearly separated in the code also. Our current engines are diffutils and quick compare. And then couple of 'if's as size/date compare. All called and used differently. What I'm going to do is: - make FolderCmp an API for compare engines. That is, FolderCmp has the knowledge of selected compare engine, its options and how to use the engine. Later it may be a real C-API (custom engines, etc) but a class is a good start. - move size/date compare code to own engine - create "attributes" compare engine, for size/date/file attribute/version/.. compare - add own compare options class for engines (diffutils and quick compare have them) - create folder structure: Src |-CompareEngines | |-diffutils where CompareEngines -folder has all current quick compare code files and new attributes-based engine's files. So basically this will move diffutils-folder from /Src/ to new CompareEngines -folder, with few files from /Src. I'll try to do this pretty fast, to minimize the hazzle this causes (moving files and folders). This is just a start, file compare code is still a big question, propably needs similar reorganization later. Regards, Kimmo |