cancel
Showing results for 
Search instead for 
Did you mean: 

Merge conflicts when changing in the .touchgfx-file, solution?

Sandy.Dahl
Associate II

Hi,

does anybody have a solution for when more than one person is working in a TouchGFX-designer project? We get really annoying merge conflicts (git) in the .touchgfx-file that is often pretty difficult to solve manually.

What's your tip for us, @Martin KJELDSEN​ ? 🙂

Grateful for help, thanks!

7 REPLIES 7
Alexandre RENOUX
Principal

Hello,

Could you elaborate what kind of issue you encounter with the .touchgfx file versioning ?

/Alexandre

Sandy.Dahl
Associate II

Thanks for getting back to me, @Alexandre RENOUX​ !

As always there is an issue trying to merge large text-files, when multiple developers work in the file.

Are there any plans to split the .touchgfx-file into multiple files instead? Or in an other way make it easier to be more developers working in the designer? =)

Kind regards

Sandy

Alexandre RENOUX
Principal

Hello,

Unfortunately, there's no plan so far but we will discuss it and see what we can do.

/Alexandre

SClin.1
Associate II

The problem goes deeper than simply merging large text files.

The .touchgfx project file is a JSON file, and the usual source control merge strategies are geared toward code. There seem to be solutions for merging JSON out there, so that would be one part of the solution.

The bigger issue has to do with how Designer allocates text identifiers. When you add non-resource text, Designer creates a TextId such as "SingleUseId106". If multiple people are adding any sort of new text (e.g. for widgets), their local copy of the project file will allocate SingleUseId106, SingleUseId107, etc. along with the references to such IDs in the code and text xlxs spreadsheet.

When you attempt to merge Alice's work with Bob's work, you will have conflicts with SingleUseId106, etc. within the JSON project file. The sensible thing to do is to keep Alice's IDs (106-109 for example) and add N new IDs for Bob's, renumbering his (e.g. 106-108 to 110-112). But then you have to change all uses of Bob's IDs in the project file to match the number numbering, which frankly beyond your typical merge tool. You'd also have to change the references to Bob's IDs in the generated code, but it might be more sensible to regenerate the generated code at this point.

Merging the text xlxs spreadsheet is a different sort of problem, since it is not a text file and would probably need to be merged manually with a spreadsheet app. TBH I don't know if there are any important relationships between the spreadsheet entries and the project json file (order of elements?), but that could probably be figured out. One approach to consider is a merge rule to convert it into a text-friendly format (such as CSV), merge tool it, and then convert back to xlxs.

Image IDs at least are based on the file name, so other than merging JSON elements this isn't the same kind of problem as text IDs.

My suggestion to the Designer developers would be to adopt a different naming scheme for SingleUseId. It would be 10x better if the generated ID was based on the screen name. For one, it is easier to manage localization with IDs such as SettingsScreenTextID001, since the prefix points to where it is used. I would further suggest that rather than sequential numbers that the postfix be based on the default text or on the widget using it: SettingsScreen_TextID_Factory_Reset. Again, better for translators and avoids name/ID conflicts except when Alice and Bob add widgets with the same name etc., which is more of a development process problem than a source control problem.

There may be other merge related issues lurking in the system I'm not aware of. We are no longer using the tool-chain project files (gcc, EWARM, etc.), so beware.

We have had to institute processes to avoid touchgfx project file merges altogether. Specifically we have a master-touchgfx branch which is the one and only branch where the touchgfx project can be edited via Designer. Only one developer can work on this branch at a time, and must pull-edit-add-push the branch while they hold the virtual mutex. This is OK but not great when, for example, resources are deleted or renamed, since the corresponding non-touchgfx-project work is to be done on another branch and merging from master-touchgfx to a different branch will break the code that depends on those resources until the corresponding work is also merged from the corresponding working branch. The general rule of thumb is no avoid removing or renaming resources except for maintenance periods.

Sadly this is the best I can recommend. In its current form, Designer projects cannot be branched and merged in practice, and developers will need processes such as described above to avoid the inherent pitfalls.

SClin.1
Associate II

If we were making a heavier investment in touchGFX Designer I would consider writing a python script to convert SingleUseIdxxx to a screen-and-widget based ID (as described in previous post). It seems likely that SingleUseID has no real significance within Designer or than as a means to generate unique IDs. If so, one could run this script against the project after the tool is closed to make it friendlier for source control. With merge tools for JSON and XLXS it might be feasible to cobble together a feasibly mergeable solution for Designer.

Martin KJELDSEN
Chief III

Have you considered tools that can actually merge excel sheets? There are some gnu tools that you can add to your .gitattributes file?

What makes touchgfx Designer projects un-mergeable is the generation of duplicate identifiers (SingleUseIDxxx). Changing these IDs to be unique might make the problem solveable with appropriate 3rd party merge tools.