Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Version Control and Automatic Merging

Discussion in 'Editor & General Support' started by Dave-Hampson, Jan 5, 2015.

  1. Dave-Hampson

    Dave-Hampson

    Unity Technologies

    Joined:
    Jan 2, 2014
    Posts:
    149
    Hi everybody,

    I was reading a thread about flaws with Unity on Reddit, particularly this comment: http://www.reddit.com/r/gamedev/com...es_developed_with_unity/cn6mij2?context=10000 and realised I know a bit about this and could help a bit, so wanted to create a discussion thread.

    Just to give a little background, I joined Unity a year ago, and have been working in the support department as a Developer Relations Engineer. Previously I worked for Codemasters, Bizarre Creations, Juice and TT Fusion, so I know what it's like having hundreds of devs working on the same repository! I discovered another programmer within Unity called Jonas Drewsen had written a tool UnityYAMLMerge.exe which is included in the Unity 5.0 Beta. If you are lucky enough to be on the Beta, you can give it a try.

    Last year I worked on a little Python script which builds upon Jonas's tool to try and provide a 'one-click' solution to merge conflicts. I'm posting it in the hope that it will be useful to someone. (Consider it MIT licence.) Please study the script carefully any make sure you understand exactly what it's doing before running it, especially the '-r' switch which prioritises local changes over remote ones. Make a backup of your project first, etc etc!

    Anyway, here is the small script:
    https://gist.github.com/davehampson/6806b7d64adedb1dafa6
    Personally I have a batch file unity-merge-mercurial.bat next to it with this inside:
    %~dp0..\tools\python27\python.exe -u %~dp0%~n0.py %*
    Obviously adapt to wherever you have python.exe.

    It only works with Mercurial currently, but I guess it would be straightforward for someone fluent in Git to adapt it. An SVN or Perforce version would be nice too if anyone has the time to work on this. Copy, paste, fork, branch, please go crazy. Fix any bugs I missed :)

    The idea of the script is that it can be used to automatically merge changes, so you'd put it in version control in the root of your project (or a subdirectory), possibly with an installation of Python, then tell everyone on the project "If you update version control, and you get a scary error message about multiple heads or something, just run this batch file". I know programmers love using Git and artists hate it, so maybe this is a way everyone can be happy.

    I have not tested this script in battle, but I'd love to think it could help reduce someone's day-to-day pain in 2015. I've simulated it by making two parallel changes to a Unity scene in a repository, and trying to merge using this script. It worked great, and so I only hope someone on the 5.0 Pro Beta can scale it up to a full project involving hundreds of developers all working on the same scenes simultaneously! If nothing else, I hope that more people will be encouraged to seek out Jonas's awesome tool in the Beta.

    Enjoy!
    Dave
     
    Last edited: Jan 5, 2015
    Griautis likes this.
  2. jdrewsen

    jdrewsen

    Unity Technologies

    Joined:
    Mar 28, 2011
    Posts:
    153
    This is a nice wrapper for a common workflow using the tool. Thanks!

    Anyone having access to Unity5 beta manual can checkout the standard way of using the merge tool in the "SmartMerge" section.
     
  3. pbrooksuk

    pbrooksuk

    Joined:
    Jun 27, 2014
    Posts:
    8
    Hi Dave,
    We (like most others) have rolled our own YAML handling tool, we would progress further with it and release but with an incomming official tool we'll evaulate that first.

    Could you summarise what features are brought by both tools and what architecture they are using (ie ordererd YAML?)

    Our main hurdle was getting the output YAML content in an order, so our SCM would reduce the number of changes. Additionally we mark GameObjects as root nodes, so that a scene is split into multiple YAML files.

    The main limitation with our system at the moment is that we do a full re-save of the scene as it is, so floats from m_localRotation (amount others) always show as changed but obviously haven't.
     
    Dave-Hampson likes this.
  4. jdrewsen

    jdrewsen

    Unity Technologies

    Joined:
    Mar 28, 2011
    Posts:
    153
    The tool is doing a three way merge of yaml trees (ie. base, incoming and local files). I does handle ordered yaml. It handles dependency cycles caused by merges. It knows which fields are coupled ie. if one is changed then a change to the other is actually also a conflict. It does not split the scene into multiple files but works directly on the scene/prefab files. It does other semantic fixes as well but this gives you an idea.