If you update to a branch and move a file to a directory that doesn't exist in the mainline tree, a merge will fail.

In a new repository (in tcsh(1): <code>alias fs fossil</code>):

<pre>echo "hello" > bar.txt
fs add bar.txt
fs ci -m "Creating a branch" --branch rename_bug bar.txt
mkdir foo
fs mv bar.txt foo/bar.txt
mv bar.txt foo/bar.txt
fs ci -m "Moved bar.txt to foo/"
fs up master
fs merge rename_bug</pre>

The expected error output is:

<pre>fossil: SQLITE_BUSY: statement aborts at 2: [ROLLBACK] cannot rollback transaction - SQL statements in progress</pre>

If you pipe the merge to a file and don't capture stderr, you should be able to spot the problem:

<pre>fossil: cannot open for writing</pre>

I think it should be pretty easy to replicate the problem.

I'm speculating, but it looks like the easiest fix is to update src/file.c:file_copy() to be updated to create the destination directory if it doesn't exist.  On the flip side, given the directory permissions, maybe it's better to just append an error message to the output when the command finishes rolling back the merge?  Food for though I suppose.