devbisme / KiField

Edit/insert/delete part fields in KiCad schematics or libraries using a spreadsheet.
MIT License
70 stars 27 forks source link

Feature request: minimize diffs #46

Open mignon-p opened 5 years ago

mignon-p commented 5 years ago

One of the reasons I don't use kifield as often as I otherwise might is that it creates large, unnecessary diffs. This makes it harder to tell what has changed in a particular commit.

There are at least three ways kifield creates larger diffs than necessary:

xesscorp commented 5 years ago

You're right that schematic diffs can get large.

The solution for point #1 is to disable whitespace compares.

Regarding point #2, KiCad doesn't seem to have any standardization as to which of the field numbers is associated with each type of information (except for F0-F2). I've seen the same field number used for different types of information in a single file. KiField would have to remember which field number went with each individual field rather than trying to make all the fields consistent as it does now.

As to point #3, the order of the internal structures of the schematic file isn't strictly specified. I'm using the order I've seen in my schematic files and which was given in a Python script I got from https://github.com/KiCad/kicad-library-utils/tree/master/sch. Maybe the order has changed with V5. I don't know. (I'm sure it will change completely with V6 when they move to using S-expressions.) In any event, the order of sections would be easy to change in the save() method of the sch.py file. However, the order of the individual wires, junctions, components, etc. within each section may not be preserved, so this may not be much of a solution.

mignon-p commented 5 years ago

Maybe the order has changed with V5. I don't know.

I don't know about v5, but my experience with 4.0.7 is that everything just appears in the file in the order in which it was created, so there are no "sections". The wires, junctions, components, etc. are intermixed.

nhatkhai commented 5 years ago

The parser do a sort, with cause everything move around. In 4.7.x they aren't save back in the file that way - which actual better compare to blindly sort everything. It was make more sense when a human look at the text file of .lib, .sch saved by 4.7x compare to 5.x and above.... I had mention this on kicad bug report too.

nhatkhai commented 5 years ago

I'm sort of solving this issue in my script using my own iterator parser: nhatkhai/kicad_scripts