Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Handling merge conflicts m_Entries in string tables

Discussion in 'Localization Tools' started by jake_card, May 18, 2022.

  1. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    My team uses one string table per ScriptableObject type (e.g. a Weapons string table, a Spells string table, etc.), and all of the strings are marked as "Smart". Whenever two of us add new entries to this table (which is pretty common), the second person to merge gets a merge conflict in the m_Entries field at the bottom of each string table file. Since the value of this field is just a huge number, it's impossible for us to resolve the merge conflict.

    How do people deal with this merge conflict? Is it safe to just pick the m_Entries value from one branch when merging? If so, could someone explain why doing this doesn't break the smart strings? And if not, could someone suggest a strategy for dealing with this issue?
     
    Last edited: May 18, 2022
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,392
    Can you show an example of one of these merge conflicts?
     
  3. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Sure! I created two branches off master (branch-a and branch-b), each of which adds a smart string entry to the end of the Powers string table. I merged branch-a into master first, then tried to merge branch-b and got this merge conflict from Powers_en.asset:

    Code (csharp):
    1. <<<<<<< HEAD
    2.   - m_Id: 12739685791666176
    3.     m_Localized: Description for Branch A Power.
    4.     m_Metadata:
    5.       m_Items:
    6.       - id: 0
    7. ||||||| b9f51dbb0
    8. =======
    9.   - m_Id: 12739269687349248
    10.     m_Localized: Description for Branch B Power.
    11.     m_Metadata:
    12.       m_Items:
    13.       - id: 0
    14. >>>>>>> branch-b
    15.   references:
    16.     version: 1
    17.     00000000:
    18.       type: {class: SmartFormatTag, ns: UnityEngine.Localization.Metadata, asm: Unity.Localization}
    19.       data:
    20. <<<<<<< HEAD
    21.         m_Entries: 029069f78a320000059069f58a320000119069f58a3200000590a9f58a3200000890a9f58a3200000e90a9f58a320000019029f58a320000029069f58a320000089069f58a3200000b9069f58a3200000e9069f58a320000149069f58a320000179069f58a3200001a9069f58a3200001d9069f58a3200000290a9f58a3200000b90a9f58a3200001190a9f58a3200001490a9f58a3200001790a9f58a3200001a90a9f58a3200001d90a9f58a3200002090a9f58a3200002390a9f58a3200002690a9f58a3200002990a9f58a3200002c90a9f58a3200002f90a9f58a3200003290a9f58a3200000290e9f58a3200000590e9f58a3200000890e9f58a3200000b90e9f58a3200000e90e9f58a3200001190e9f58a3200001490e9f58a3200001790e9f58a3200001a90e9f58a3200001d90e9f58a3200002090e9f58a3200002390e9f58a3200002690e9f58a3200002990e9f58a3200002c90e9f58a3200002f90e9f58a3200003290e9f58a320000029029f68a320000059029f68a320000089029f68a3200000b9029f68a3200000e9029f68a320000119029f68a320000149029f68a320000179029f68a3200001a9029f68a3200001d9029f68a320000209029f68a320000239029f68a320000269029f68a320000299029f68a3200002c9029f68a3200002f9029f68a320000029069f68a320000059069f68a320000089069f68a3200000b9069f68a320000119069f68a3200000e9069f68a320000149069f68a320000179069f68a3200001a9069f68a3200001d9069f68a320000209069f68a320000239069f68a320000269069f68a320000299069f68a3200002c9069f68a3200002f9069f68a320000329069f68a3200000290a9f68a3200000590a9f68a3200000890a9f68a3200000b90a9f68a3200000e90a9f68a3200001190a9f68a3200001490a9f68a3200001790a9f68a3200001a90a9f68a3200001d90a9f68a3200002090a9f68a3200002390a9f68a3200002690a9f68a3200002990a9f68a3200002c90a9f68a3200002f90a9f68a3200003290a9f68a3200000290e9f68a3200000590e9f68a3200000890e9f68a3200000b90e9f68a3200000e90e9f68a3200001190e9f68a3200001490e9f68a3200001790e9f68a3200001a90e9f68a3200001d90e9f68a3200002090e9f68a3200002390e9f68a3200002690e9f68a3200002990e9f68a3200002c90e9f68a3200002f90e9f68a3200003290e9f68a320000029029f78a320000059029f78a320000089029f78a3200000b9029f78a3200000e9029f78a320000119029f78a320000149029f78a320000179029f78a3200001a9029f78a3200001d9029f78a320000209029f78a320000239029f78a320000269029f78a320000299029f78a3200002c9029f78a3200002f9029f78a320000329029f78a320000059069f78a320000089069f78a3200000b9069f78a3200000e9069f78a320000119069f78a320000149069f78a320000179069f78a3200001a9069f78a3200001d9069f78a320000209069f78a320000239069f78a320000269069f78a320000299069f78a3200002c9069f78a3200002f9069f78a3200000290a9f78a3200000590a9f78a3200000890a9f78a3200000b90a9f78a3200000e90a9f78a3200001190a9f78a3200001490a9f78a3200001790a9f78a3200001a90a9f78a3200002090a9f78a3200001d90a9f78a3200000090e96c832e0900001059828876090000205253acfe260000209288611427000020929caca32a000010d90c52d42a000020d253be2b2c000020521007382c00002052a8a33c2c000090293ead422d00
    22. ||||||| b9f51dbb0
    23.         m_Entries: 029069f78a320000059069f58a320000119069f58a3200000590a9f58a3200000890a9f58a3200000e90a9f58a320000019029f58a320000029069f58a320000089069f58a3200000b9069f58a3200000e9069f58a320000149069f58a320000179069f58a3200001a9069f58a3200001d9069f58a3200000290a9f58a3200000b90a9f58a3200001190a9f58a3200001490a9f58a3200001790a9f58a3200001a90a9f58a3200001d90a9f58a3200002090a9f58a3200002390a9f58a3200002690a9f58a3200002990a9f58a3200002c90a9f58a3200002f90a9f58a3200003290a9f58a3200000290e9f58a3200000590e9f58a3200000890e9f58a3200000b90e9f58a3200000e90e9f58a3200001190e9f58a3200001490e9f58a3200001790e9f58a3200001a90e9f58a3200001d90e9f58a3200002090e9f58a3200002390e9f58a3200002690e9f58a3200002990e9f58a3200002c90e9f58a3200002f90e9f58a3200003290e9f58a320000029029f68a320000059029f68a320000089029f68a3200000b9029f68a3200000e9029f68a320000119029f68a320000149029f68a320000179029f68a3200001a9029f68a3200001d9029f68a320000209029f68a320000239029f68a320000269029f68a320000299029f68a3200002c9029f68a3200002f9029f68a320000029069f68a320000059069f68a320000089069f68a3200000b9069f68a320000119069f68a3200000e9069f68a320000149069f68a320000179069f68a3200001a9069f68a3200001d9069f68a320000209069f68a320000239069f68a320000269069f68a320000299069f68a3200002c9069f68a3200002f9069f68a320000329069f68a3200000290a9f68a3200000590a9f68a3200000890a9f68a3200000b90a9f68a3200000e90a9f68a3200001190a9f68a3200001490a9f68a3200001790a9f68a3200001a90a9f68a3200001d90a9f68a3200002090a9f68a3200002390a9f68a3200002690a9f68a3200002990a9f68a3200002c90a9f68a3200002f90a9f68a3200003290a9f68a3200000290e9f68a3200000590e9f68a3200000890e9f68a3200000b90e9f68a3200000e90e9f68a3200001190e9f68a3200001490e9f68a3200001790e9f68a3200001a90e9f68a3200001d90e9f68a3200002090e9f68a3200002390e9f68a3200002690e9f68a3200002990e9f68a3200002c90e9f68a3200002f90e9f68a3200003290e9f68a320000029029f78a320000059029f78a320000089029f78a3200000b9029f78a3200000e9029f78a320000119029f78a320000149029f78a320000179029f78a3200001a9029f78a3200001d9029f78a320000209029f78a320000239029f78a320000269029f78a320000299029f78a3200002c9029f78a3200002f9029f78a320000329029f78a320000059069f78a320000089069f78a3200000b9069f78a3200000e9069f78a320000119069f78a320000149069f78a320000179069f78a3200001a9069f78a3200001d9069f78a320000209069f78a320000239069f78a320000269069f78a320000299069f78a3200002c9069f78a3200002f9069f78a3200000290a9f78a3200000590a9f78a3200000890a9f78a3200000b90a9f78a3200000e90a9f78a3200001190a9f78a3200001490a9f78a3200001790a9f78a3200001a90a9f78a3200002090a9f78a3200001d90a9f78a3200000090e96c832e0900001059828876090000205253acfe260000209288611427000020929caca32a000010d90c52d42a000020d253be2b2c000020521007382c00002052a8a33c2c00
    24. =======
    25.         m_Entries: 029069f78a320000059069f58a320000119069f58a3200000590a9f58a3200000890a9f58a3200000e90a9f58a320000019029f58a320000029069f58a320000089069f58a3200000b9069f58a3200000e9069f58a320000149069f58a320000179069f58a3200001a9069f58a3200001d9069f58a3200000290a9f58a3200000b90a9f58a3200001190a9f58a3200001490a9f58a3200001790a9f58a3200001a90a9f58a3200001d90a9f58a3200002090a9f58a3200002390a9f58a3200002690a9f58a3200002990a9f58a3200002c90a9f58a3200002f90a9f58a3200003290a9f58a3200000290e9f58a3200000590e9f58a3200000890e9f58a3200000b90e9f58a3200000e90e9f58a3200001190e9f58a3200001490e9f58a3200001790e9f58a3200001a90e9f58a3200001d90e9f58a3200002090e9f58a3200002390e9f58a3200002690e9f58a3200002990e9f58a3200002c90e9f58a3200002f90e9f58a3200003290e9f58a320000029029f68a320000059029f68a320000089029f68a3200000b9029f68a3200000e9029f68a320000119029f68a320000149029f68a320000179029f68a3200001a9029f68a3200001d9029f68a320000209029f68a320000239029f68a320000269029f68a320000299029f68a3200002c9029f68a3200002f9029f68a320000029069f68a320000059069f68a320000089069f68a3200000b9069f68a320000119069f68a3200000e9069f68a320000149069f68a320000179069f68a3200001a9069f68a3200001d9069f68a320000209069f68a320000239069f68a320000269069f68a320000299069f68a3200002c9069f68a3200002f9069f68a320000329069f68a3200000290a9f68a3200000590a9f68a3200000890a9f68a3200000b90a9f68a3200000e90a9f68a3200001190a9f68a3200001490a9f68a3200001790a9f68a3200001a90a9f68a3200001d90a9f68a3200002090a9f68a3200002390a9f68a3200002690a9f68a3200002990a9f68a3200002c90a9f68a3200002f90a9f68a3200003290a9f68a3200000290e9f68a3200000590e9f68a3200000890e9f68a3200000b90e9f68a3200000e90e9f68a3200001190e9f68a3200001490e9f68a3200001790e9f68a3200001a90e9f68a3200001d90e9f68a3200002090e9f68a3200002390e9f68a3200002690e9f68a3200002990e9f68a3200002c90e9f68a3200002f90e9f68a3200003290e9f68a320000029029f78a320000059029f78a320000089029f78a3200000b9029f78a3200000e9029f78a320000119029f78a320000149029f78a320000179029f78a3200001a9029f78a3200001d9029f78a320000209029f78a320000239029f78a320000269029f78a320000299029f78a3200002c9029f78a3200002f9029f78a320000329029f78a320000059069f78a320000089069f78a3200000b9069f78a3200000e9069f78a320000119069f78a320000149069f78a320000179069f78a3200001a9069f78a3200001d9069f78a320000209069f78a320000239069f78a320000269069f78a320000299069f78a3200002c9069f78a3200002f9069f78a3200000290a9f78a3200000590a9f78a3200000890a9f78a3200000b90a9f78a3200000e90a9f78a3200001190a9f78a3200001490a9f78a3200001790a9f78a3200001a90a9f78a3200002090a9f78a3200001d90a9f78a3200000090e96c832e0900001059828876090000205253acfe260000209288611427000020929caca32a000010d90c52d42a000020d253be2b2c000020521007382c00002052a8a33c2c000090695c4c422d00
    26. >>>>>>> branch-b
    The first part is easy to resolve (we can just pick both), but the second part with m_Entries is basically impossible.
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,392
    Oh I think that's supposed to be the contents of the list but it's in binary for some reason. With the smart string tag it's actually safe to pick any version as long as it's referenced by the entries. Internally it keeps a list of the entries using it so we can remove the tag when all references are removed but it won't affect anything else.
    I'll ask the team if we can stop it being binary.
     
    jake_card likes this.
  5. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Ahh ok, good to know it's in binary! It'd be great for that to change, thanks for asking.

    Can you explain what you mean by "With the smart string tag it's actually safe to pick any version as long as it's referenced by the entries."? This m_Entries field is at the very bottom of our string table .asset file, and it changes any time add/remove a smart string in the table, so I'm not sure what you mean by "referenced by the entries".
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,392
    m_Entries is a serialized field that is part of SmartFormatTag metadata. We mark smart format entries using this metadata so we know they should use smart format. The contents of m_Entries is not that important, it's just for Keeping track of all the uses so we can remove it when it's not used. So if it's wrong it's fine, it won't stop the smart strings from working.
     
    jake_card likes this.
  7. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Ahh ok, understood now! Thanks a bunch for the explanation, we'll stop worrying about the changes to that field.
     
    karl_jones likes this.
  8. Benzor

    Benzor

    Joined:
    Dec 29, 2013
    Posts:
    16
    Hi, sorry to necro an old thread but I have questions because we are also repeatedly running into merge conflicts on the `m_Entries` field and it's taking up time for our devs to resolve.

    @karl_jones are you saying that we don't need to do anything to resolve conflicts on `m_Entries` here? We can randomly keep `ours` or `theirs` or just nuke it entirely and there won't be any impact?

    Assuming this is true, why is this data serialized to disk at all? It would save our devs a lot of merge conflict pain if this was stored only in memory e.g. at Unity editor startup, or in a separate scratch file we could .gitignore.

    Thanks.
     
  9. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,392
    Hi,
    This is used to indicate if an entry is marked to use Smart formatting. We store this in a list inside of m_Entries and we also store it in the entry metadata. So as long as the reference is still in the entries metadata then you can ignore m_Entries. I would do a quick check to make sure the items you expect to be marked as smart are just to be safe as we have fixed some bugs in the past where they were not being correctly marked as smart.
     
  10. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    818
    Chiming in with the same question and request as @Benzor which you didn't address specifically @karl_jones, namely, shouldn't this field be removed from serialized data and be cached in memory instead?

     
  11. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,392
    No, it needs to be serialized. We use it to indicate if entries are marked as smart.

    We do the following to check if an entry is marked as smart:
    1) HasTagMetadata<SmartFormatTag>() - This uses m_Entries
    2) GetMetadata<SmartFormatTag> Fallback to checking if the StringTableEntry has SmartFormatTag applied to it.

    In the past we had some bugs with the metadata not being added for step 2 so only step 1 would work. We need to keep this to support people upgrading packages or they may find some of their smart strings no longer work. There's no way to make it optional in the serialization system.

    In the future, we would like to move the IsSmart flag directly into the entry to avoid using Metdata but for now this is needed.
     
  12. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    818
    Thanks for the clarifications!

    In that case, was there a reason why the field was kept as binary last time you discussed it with the team in 2022? Making this field YAML-based would allow the merge tool to merge it without flagging manual conflicts.
     
  13. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,392
    Yes, it is by design. Its an optimization of packing of arrays for basic types.
    Maybe we can force it to use text if we change the type to something else. Ill make a task to look into it some more. (LOC-1095)
     
  14. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,392
    Hey, we now have a fix for this. Should be available in the next release 1.5.2 due in a couple of months.

    instead of this:

    data:
    m_Entries: 007062c69b030000

    you should get this:

    data:
    m_Entries:
    m_SharedEntries:
    - id: 3967583154176
    - id: 98006364160
    - id: 263928586334208
    - id: 285893116194816
     
    LazloBonin likes this.