Sorted fileformat for schematic editor for easier version control merging
Description
Currently using normal merge tools in version control does not work very well in the schematic editor. The problem is that the data in the file changes the placement of items in the file every time you save. This is natural consequence of storing the data in a r-tree and dumping the data verbatim.
But there are simple solutions for this problem:
Since the r-tree does not actually care of the order in the file
-
Just simply sort the elements into alphabetical order into the file at save time. This does not change version compatibility in any way.
-
A good long term solution would be to just make the internal data structure both a r-tree and a linked list (or better a hierarchy tree) like thing at the same time. This would have many advantages with very minimal overhead in complexity.
You could now implement a user order able outline view of components. You could now easily be able to implement layers and hierarchical groups. All of this would pave way for making it easier to implement a visual merge tool helper inside the editor itself.
Steps to reproduce
- save file
- sort order of items in file
- put in version control
- change file
- sort again
- save into version control
- now try merging file
KiCad Version
Application: KiCad Schematic Editor x64 on x64
Version: 7.0.6, release build
Libraries: wxWidgets 3.2.2 FreeType 2.12.1 HarfBuzz 6.0.0 FontConfig 2.14.1
Platform: Windows 10 (build 19045), 64-bit edition, 64 bit, Little endian, wxMSW
wxWidgets: 3.2.2 (wchar_t,wx containers)
Boost: 1.81.0
OCC: 7.6.3
Curl: 7.88.1-DEV
ngspice: 40
Compiler: Visual C++ 1936 without C++ ABI
Build settings: KICAD_SPICE=ON