Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dymola, whitespace and version control

I opened a Modelica library in Dymola, changed one line, closed Dymola and clicked "Save all", now TortoiseSVN is showing several hundred changed files instead of just one file with the one line changed I intended to do. All these changes are either whitespace, or line breaks, introduced by Dymola it seems.

Of course I can now be careful to only commit the file I have changed (and revert the rest), but that makes committing more time-consuming and error-prone than it needs to be. Or I can just commit it all, but that makes it hard for my colleagues to review the change. Also, it feels like it is not deterministic, so a later commit might just revert parts back. I sometimes even revert all changes, then use a text editor to change just the one line. All this makes version control unnecessarily complicated.

When I look at the commits and diffs for e.g. the Modelica Standard library:
https://github.com/modelica/ModelicaStandardLibrary/commits/master
The diffs are nice and small and readable usually. Is there a trick to avoid the whitespace issue?
How I can I turn off all autoformatting by Dymola? Is there a technical reason to do it in the first place?

like image 985
Priyanka Avatar asked Mar 01 '23 23:03

Priyanka


1 Answers

You can reduce (but not entirely prevent) this behavior as follows:

  1. Increase the maximum line length, e.g. to 130

    • In the GUI: Options > Text Editor > Max line length
    • From the command line: Advanced.MaxLineLength=130
  2. Let Dymola format your whole library one time

    • Open the text view of the top-level package
    • Mark everything with Ctrl+A
    • Auto-format with Ctrl+Shift+L or Right-Click > Auto-Format
    • Save everything with Ctrl+Shift+S
    • Now go through the changes. Most will be useful, but sometimes spaces are removed, which you usually like to keep (especially before import and extends statements. They are sometimes moved to the very left)
    • Commit the changes
  3. From now on try to save individual models only, not packages
    (When packages are saved, Dymola sometimes reformats the nested classes)

like image 173
marco Avatar answered Mar 19 '23 18:03

marco