Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Phantom" directories in an SVN repository

Tags:

I've somehow managed to get an SVN repository into a bad state. I've moved a directory and now I can't commit it in its new location.

As far as svn status is concerned, the directory is unknown (the name of the directory is type).

$ svn status
?      type

When I try to add the directory, the server says it already exists.

$ svn add type
svn: warning: 'type' is already under version control

If I try to update the directory, it's gone again.

$ svn update type
svn: '.' is not under version control

If I try to commit it, the server complains that it's old parent directory no longer exists.

$ svn commit type -m "Moving type"
svn: Commit failed (details follow):
svn: '/prior/trunk/src/nyu/prior/cvc3/theorem_prover/expression' path not found

To add to the mystery, the contents of the directory are marked as modified.

$ svn status type
A  +   type
M  +   type/IntegerType.java
M  +   type/BooleanType.java
M  +   type/Type.java
M  +   type/RationalRangeType.java
M  +   type/RationalType.java
M  +   type/IntegerRangeType.java

If I try to update from within the directory, I get this.

$ cd type
$ svn update
svn: Two top-level reports with no target

Committing from within the directory gives the same path not found error as above.

What's going on and how do I fix it?

EDIT: @Rob Oxspring caught me out: I got too aggressive moving things around in Eclipse.

UPDATE: I'm accepting @Rob Oxspring's answer of "don't do that/just start over" and taking his advice. I'd still be interested if anybody could tell me: (a) what the above error messages mean precisely and (b) how to actually fix the problem.

like image 924
Chris Conway Avatar asked Sep 05 '08 22:09

Chris Conway


People also ask

What are .svn folders?

In particular, each directory in your working copy contains a subdirectory named . svn, also known as the working copy's administrative directory. The files in each administrative directory help Subversion recognize which files contain unpublished changes, and which files are out of date with respect to others' work.

How do I find svn directory?

http:// or https:// This is svn over http or https. You need to find the virtual host in your apache configuration and look for a <Location> section that matches your url path and look for a SVNPath or SVNParentPath config line. This will tell you the location of your subversion repository.

How do I commit a directory in svn?

Right-click in an empty area of the folder and select Refresh. You'll see “+” icons on the folders/files, now. Right-click an empty area in the folder once again and select SVN Commit. Add a message regarding what you are committing and click OK.


2 Answers

It looks to me like type was created by some Subversion-aware copy command, then moved into the current directory using a Subversion-unaware copy. In my experience, this sort of thing typically occurs when package refactoring operations have been chained together in Eclipse without commits in between. Typically, Subversion doesn't handle it well when you copy/move a locally copied/moved file or folder, although I think version 1.5 may handle it better.

To avoid this in the future, commit between such steps. If you'd like to hide the intervening commits then I'd recommend doing the multi-step refactoring on a branch and then merging the changes back into the mainline in that single commit you were after.

If it's not too much work, then I'd recommend getting back to a clean working copy and redoing your changes, committing after each step. If you're happy to lose the history, i.e. allowing the new IntegerType.java to not be linked at all to the old IntegerType.java, then you could take the approach suggested by BCS:

  • Move your changed files into some temporary location, stripping out any .svn directories
  • Update your working copy into a clean working state
  • Copy your changes back to where you want them to be
  • Commit the resulting working copy
like image 152
Rob Oxspring Avatar answered Oct 08 '22 01:10

Rob Oxspring


The easy way to fix many SVN errors is to move the whole directory away via the OS, update to get another clean copy of it and then merge in anything you changed with some other tool, WinMerge or the like.

After that, you can do whatever you were trying to do, but do it correctly :).

like image 29
BCS Avatar answered Oct 08 '22 02:10

BCS