-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve XML indentation, thus optimizing file sizes #5911
Conversation
Those reductions in size come at a price:
I therefor object to those changes to the mtest mscx, mscx, xml, musicxml and mxl files and recommend to add Those spaces are not illegal, so don't punish for using them. |
4dc1c81
to
350856d
Compare
Out of curiosity, what platform are you building with? I've recently been trying to build and run the mtests with msvc under Windows and had no luck so far. If you did manage to do it, I would be curious to see how. |
@Jojo-Schmitz: Done → 350856d Actually i only did 4dc1c81 because i understood these "would need" to be adjusted, as opposed to "maybe" modifying the tests themselves - doing the first cost me a whole day, the other half of the day was spent in vain trying to get the tests to pass on my machine 😏. But for what it's worth, maybe the script may come in handy someday to convert existing, non-versioned files before they get committed into some sort of repository.
Actually i was contemplating over writing a MuseScore Plugin for git version control of scores, that's why i looked into the files in the first place to analyze the feasibilty of doing so. As form and function are inexplicably intertwined in software and data structures (and also the standards show it as good practice), i am very happy for this to go forward into v3.5.0 |
@Marr11317 i'm a Linux user, currently using Manjaro with a 4.19 kernel. I followed the instructions in the |
350856d
to
f1c9a36
Compare
@Jojo-Schmitz using I tried locally though and found that using |
Hmm, OK
Not quite sure what the difference is and why one works here and the other does not (and thought |
No worries, i'll get over it ;) And yes you mentioned it, i was just unsure about it. I actually linked that very comment of yours in my reply above when i said
Still have one unticked box for this PR - writing a regression test. The test can be very simple, testing a generated empty score will do, as it will be sufficient to check if the last line (which contains Two questions:
|
don't think an mtest is needed here |
7ebdd46
to
e0ddd73
Compare
c5ea88f
to
00bbb23
Compare
Reduce file size and increase readability by fixing node indentation of XML output to be well-formed. This affects **any** XML generated through MuseScore 3. See https://musescore.org/en/node/303489 for full issue description and examples. In order for tests not to fail after this change, the test runner setup is modified to ignore whitespace changes for diff's.
00bbb23
to
40c2964
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is safe to ignore whitespace in XML, therefore I oppose merging this except in tandem with all the other changes in coding style (see musescore/musescore-code-style#5).
The reason is whitespace can sometimes be significant in XML (at least how MuseScore uses it).
<StaffText>
<text>This text
spans
multiple
lines.
</text>
</StaffText>
Even if it is safe to ignore whitespace, doing so only delays the increase in repository size, it does not prevent it entirely. The whitespace change would happen when test files are next updated, which increases size and also masks the important changes in those files.
Correcting the indentation in files for a data exchange format and changing coding styles are two separate things and i'm failing to see why they would need to be done together. Of course i agree that everybody needs to agree on how to deal with the implications of diffs not matching anymore.
I could revert the whitespace ignore flag change and easily convert all the files as done before in 4dc1c81. |
Very true.
Because they have the same negative impact on |
@vpereverzev Isn't there going to be a big rebase for MuseScore 4 to align the code base with the new coding style? I believe @shoogle was working on that fork that used to be musescore/musescore-code-style., rewriting the git history to work around exactly the git-blame / git history growth problem that you are understandibly concerned about. If we could pull this change in in a similar fashion, we'd improve XML readability, make them finally conforming to the standard and reduce file sizes, all in one go :) |
That 'big rebase' happened quite a while ago already |
@Philzen, if you look at the C++ files on the master branch you will see that the new style is already in use.
This was the plan at one point, but it seems that the in-house team changed their minds and decided to apply the coding style via an ordinary merge (i.e. not via a rebase). This means there was one big commit that changed the style rather than rewriting every commit back to the initial one with the new style as though it had been used from the very beginning. Since history was not rewritten, this means that the repository size increased (though not massively after compression) and Also, as @Jojo-Schmitz mentioned, it is possible to ignore the style commit altogether for offline usage of # ignore once
git blame file1.cpp --ignore-revs-file .git-blame-ignore-revs
# ignore always
git config blame.ignoreRevsFile .git-blame-ignore-revs
git blame file1.cpp
git blame file2.cpp I would like to use the new style for XML-based files but I'm not convinced it's worth the effort. If we did do it then I would prefer to see the test files using the new style rather than make the tests ignore whitespace for the reasons I gave before. This would mean employing the same workarounds to preserve |
Resolves: https://musescore.org/en/node/303489
Description
As described in the linked issue description, closing brackets in any generated XML are rendered on the same indent level as their preceding child nodes, which (a) makes them harder parse visually, (b) unneccessarily bloats file size, and (c) also contradicts the expected MusicXML default formatting (References: 1, 2, 3).
Improvement
File size comparison before and after:
Baseline: Raw XML size is decreased by ~2%, and even compressed MuseScore files are shrunk by a few bytes 😄
Open Points / Help needed
mtest/libmscore/parts/part-image-parts.mscx
andmtest/libmscore/parts/part-all-insertmeasures.mscx
are invalid XML, as they contain a</BarLine>
closing tag that is not opened anywheremtest/musicxml/io/testMultipleNotations.xml
has some more indentation jumps than expected, however i can adjust this file manually and amend the commit if needed (once everything is good to go)mtest/libmscore/compat114/
andmtest/libmscore/compat206/
(judging from their name and contents)mtest
that are rewritten in 4dc1c81 - however, the whole project contains 2679 XML files (=1230 files untouched), pls advise if you think those should be reformatted as wellmtest
folder. Is there any way i can speed up this process, am i looking at the wrong tutorial? Right now i'm doingmake clean
and repeat all the steps there - maybe we can improve on that document to hint what is necessary and what isn't to get a proper test run (and also not overwrite an existing install)Checklist