68

I have a problem that seems very simple but is hard to solve. I get the mentioned error after deleting a directory. I did not find a solution yet to solve the conflict. This is how it occurs:

 svn add dir svn add dir/file1 svn commit svn add dir/file2 svn commit svn delete dir svn commit --> commit failed --> Directory '/dir' is out of date 

The obvious solution 'svn update'does not work. After svn update a next commit fails with:

 Commit failed Directory '/dir' remains in conflict. 

In the meanwhile I found a solution but it is a bit cumbersome:

 svn resolve --accept working dir svn commit --> still fails svn update svn commit --> still fails svn resolve --accept working dir svn commit --> NO PROBLEM! 

Two questions: - can anyone explain this behaviour because I am very curious about it - this problem occurs in a perl script in a far more complex situation. Can anyone give me a simple solution with is 'doable' in the perl script?

10 Answers 10

114

Just make a svn update and then your commit should work.

Sign up to request clarification or add additional context in comments.

5 Comments

Beat me to it. And to add to that, an update should be part of your normal workflow. I typically update before commits.
That was one of the obvious solution I thought about. But after svn update I get: svn commit --> '\dir' remains in conflict
but 'svn update' removes changes in your working directory, so all your work will be deleted and nothing then to commit. Am I right?
svn update does not remove any changes. It will merge the changes from the repository with your local changes to be able to commit later. But it will never remove any change.
In case you're wondering: I was the one who did the last commit 5 minutes ago, and no one has commit access, but svn update still worked... Whatever.
64

If I understand subversion correctly, the problem is this:

Subversion tracks the current revision for each file and directory separately. Whenever a change on a file is committed, the revision of the parent directory changes in the repo, but you working copy still has the directory in its old revision.

So in your scenario after adding the file the parent directory in the repo has a higher revision than your working copy. When you try to delete the directory you working on an outdated version.

To resolve:

Do an svn update after adding the file, but before deleting the dir.

In general if you do not want to pull in anybody else's changes, you can restrict the update to the directory itself: svn up --depth empty dir.

1 Comment

Many thanks for that, @Stephen Friedrich - just wanted to note that when doing svn mv of a whole directory (which is what brought me to this post), the add and the delete occurs in one step; and unfortunately it seems that "do an svn update after adding the file, but before deleting the dir" cannot be applied in that case. However, what worked for me was to manually delete the 'old' directory (with rm -rf) and then commit again. Cheers!
5

Make update, cleanup and then commit.

Comments

4

I've figured out an easy way to solve the problem on Eclipse:

Right click on your project -> Team -> Update to HEAD 

and then follow the same way for commiting.

Right click on your project -> Team -> Commit 

Comments

1

You just need to update and then commit

1 Comment

That was one of the obvious solution I thought about. But after svn update I get: svn commit --> '\dir' remains in conflict
1

Have you tried svn up dir before doing the final commit?

1 Comment

That was one of the obvious solutions I thought about. But after svn update I get: svn commit --> '\dir' remains in conflict
0

To get around this problem I used 'svn revert ' then do the commit again, which should get rid of the contents in the then do 'svn delete ' and commit again. I got this problem trying to rename a directory but hopefully this will work.

Comments

0

Similar problem I faced with fresh workspace:

$ svn delete dir/file D dir/file $ svn ci -m "comment1" Deleting dir/file $ svn delete dir/ D dir $ svn ci -m "comment2" Deleting dir svn: Commit failed (details follow): svn: Item 'dir' is out of date 

To resolve the issue I re-updated the sources and used 'delete URL' command:

$ svn delete --force https://server/path.../dir $ svn update 

Comments

0

This happens when you are going to commit a file and the same file is updated in the SVN as well. Then it is going to conflict.So what you have to do is just take a copy of your changes and revert the file. then again paste your code. Then you can commit without any issues.

3 Comments

In a situation like that you shouldn't need to paste your code back, the update should append any changes without disrupting your working copy (Unless there is a conflict)
@Prodigle yeh you are correct but some times conflict can occur when two people d=change same line of the code
That's why you have a diff tool ;P
0

Try committing one test directory on the server. generally when you delete any repository from SVN and if contains multiple files, SVN note the changes but it's in on-hold state or changes will take time to reflect. No worries just wait for few minutes and it will start reflecting. try committing test directory. cheers.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.