While somehow versed in VCS (regular svn, git and git-svn user) I can't seem to wrap my head around this peculiar SVN behavior.
Whenever I need to rename a directory in my SVN working copy from an otherwise 'clean' state - i.e svn status
returns nothing and all other modifications have been commited - like so (which is what the svn doc suggests):
svn mv foo bar
svn commit
SVN complains loudly:
Adding bar
Adding bar/toto
Deleting foo
svn: Commit failed (details follow):
svn: Item '/test/foo' is out of date
As you wish:
svn update
Which gives:
C foo
At revision 46.
Summary of conflicts:
Tree conflicts: 1
There's a tree conflict, while no third-party change happened. Obviously, the only way to get out of this tree conflict mess is generically (from the svn red book):
svn resolve --accept working -R .
svn commit
Renaming it remotely on the repo then updating my working copy seems quite braindead:
url=$(svn info | grep -e '^URL:' | sed 's/^URL: //') svn mv $url/foo $url/bar
svn update
Is there a sanctioned, more streamlined way to rename a folder that I'm missing? What is the root cause behind that particularly surprising tree conflict state?
This worked for me:
I suspect that there were various other possible ways round, and that ensuring there was a clean working directory before doing the svn mv would also have done the trick.
OK, I bumped into this - and can finally reconstruct the problem with a simple terminal session: the problem happens if you
svn mv
(move/rename) a file; then commit that change; then (without doing ansvn update
first),svn mv
the parent directory of the file whose move/rename was previously committed - and finally do ansvn commit
on the change of the directory name - or as accepted answer puts it: "you also need to update and commit a file contained in the folder, but not update the folder itself"; but all of this executed in a parent (or rather, ancestor) directory. Here's command line log demonstrating the problem:And this is how it should have been - doing an
svn up
after the file move/rename was comitted; note how the version numbers reported bysvn status -v
change after thesvn update
command:And as OP said - should one forget to do the
svn update
before a new move/rename+commit, and the "Commit failed" occured - then one can usesvn resolve --accept working -R .
to be able to finish the commit action.One could think of a scenario where the directory has been changed in the repository by an other user. Renaming the same folder in your working copy may trigger tree conflicts during commit.
Resolving conflicts shows how to resolve 'tree conflicts' in subversion.
svn mv
works for me:Sorry for the Swedish output of svn.
There must be something else that is wrong in your case.
Edit:
As pointed out in the comments by Lloeki
To reproduce the behavior you also need to update and commit a file contained in the folder, but not update the folder itself.
The behavior is "expected" and the "solution" is to update the working copy before issuing the
svn rename
command.