Hi everybody,
I was reading a thread about flaws with Unity on Reddit, particularly this comment: Reddit - Dive into anything 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:
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