It is very important that the
--result=$outputargument be present. Without this, DiffMerge will not set the exit status as Mercurial expects and it will save the merge result in the original file, which in this case is a Mercurial temporary file.
If you want, you can add:
-t1="Local Version" -t2=$output -t3="Other Version" --caption=$output
diffmerge.argsline. This will give you better window titles.