UnityYamlMerge

# 追記

http://labs.gree.jp/blog/2015/04/13836/

こっちにもうちょいまともなの書きました

# Unity5からはいったMergeTool

Macで調査したときのなんでほどよく脳内補完してください

http://docs.unity3d.com/Manual/SmartMerge.html


## 設定ファイルの例

UnytyYamlMergeはデフォルトの挙動ではautoという設定ファイルを見るようです(Mac)
必要に応じて設定してください。

設定の書式やルールはよくわからんので`/Applications/Unity/Unity.app/Contents/Tools/`らへんにある設定ファイルをよんだり、dtrussを仕掛けてどういう動きをするか見ましょう

```
echo ‘* use “/usr/bin/opendiff” %r %l -ancestor %b -merge %d’ > auto
```

はじめ試したときはautoファイルがなくて途方にくれました

## 使用方法

適当なYamlフォーマットのPrefabをコピって変更したものを手動でmergeしてみます。わざとコンフリクトした時にどうなるのか、といったところで手元のOSX版をやってみたところ5.04fの場合GUIのDiffツールの終了を待たずにexitしてしまいました。

コンフリクトしない場合はとても良い感じにmergeされています。

```
 /Applications/Unity/Unity.app/Contents/Tools/UnityYAMLMerge merge -p Ancester.prefab Remote.prefab Local.prefab Output.prefab
Conflicts:
Left  104950.GameObject.m_Name add as Cube 1
Right 104950.GameObject.m_Name add as Cube 3
Left  6570386.BoxCollider.m_Size.y add as 2
Right 6570386.BoxCollider.m_Size.y add as 3
Conflict handling:
```


-pはPremergeというオプションで

```
For doing a normal premerge use the -p option. This will create a new left
  (theirs) file that contains all non-conflicting merges and the left side
  values for where there are conflicts. The same will be done the base file and
  right file and put into a temporary file unless [premerge base dest] /
  [premerge right dest] is specified in which case that will be used instead.
  As a result the fallback merge tool will not show the original left,right or base
  files but the premerged ones which contains only conflicts that this tool
  could not handle.
```

ということらしいです。よくわからんけどうん、いい感じにmergeしてくれるってことですね。
（コンフリクトしないものに関してはさくっと先にmergeしつつ、ダメそうな部分はGUIツールに選択よろ、みたいなイメージだと思っています）

## Help

```
Unity YAML Merge Tool for scene or prefab files - version 1.0.1
usage: UnityYAMLMerge merge  [-l|-r|-p] [-i file] [-o file]
                             [--rules rulesfile]
                             [--fallback fallbackspecfile]
                             [--force] [--describe]
                             <base> <left> <right> [dest]
                             [premerge base dest] [premerge right dest]

       -l         Resolve merge conflicts using left  (theirs)
       -r         Resolve merge conflicts using right (mine)
       -i file    Resolve merge conflicts using merge file
       -o file    File to write merge conflicts into
       -p         Use premerging
       --rules    A files with merge rules
       --fallback Spec file defining fallback tools on conflicts if not using
                  builtin. Can be set to 'none' to disable fallback.
       --force    Force merging even on unknown file extensions
       --describe Include description of what has been done in the -o file.

  The -l and -r options will first try to use the -i file if provided to
  determine how to resolve and next fallback to either left, right
  or base (default).
  This is useful for using this tool as a first premerge pass before running
  another merge tool as fallback.

  For doing a normal premerge use the -p option. This will create a new left
  (theirs) file that contains all non-conflicting merges and the left side
  values for where there are conflicts. The same will be done the base file and
  right file and put into a temporary file unless [premerge base dest] /
  [premerge right dest] is specified in which case that will be used instead.
  As a result the fallback merge tool will not show the original left,right or b
ase
  files but the premerged ones which contains only conflicts that this tool
  could not handle.

  The fallback tool does not use any of the options. Unity ships with a default
  fallback specfile that is used if nothing else is specified. Unity also ships
  with a default rules file that is used if nothing else is specified.
  In order to be able to use this tool with subversion any invocation with 1st
  argument not 'merge' is taken as being called from subversion which
  hard codes parameters.
```

## ひとこと

UnityYamlMergeはとてもよさそうに見えるのですがいかんせんコマンド事例がすくなすぎますし、ドキュメントも少なすぎるので中の人何とかして！