Discussion:
svn add "already under version control"
Brian Bird
2006-07-19 13:14:57 UTC
Permalink
Is there any way to force subversion to ignore the fact that a locally
modified folder has been entirely replaced by something else and just tell
it to save the current working copy over the repository as a new version?

For example:



mkdir directory # the real directory has several files inside it too

svn add directory

svn ci



rm -rf directory # another program removes this directory

mkdir directory # it then creates an entirely new directory with
similar files to the original directory



svn add directory # At this point I want to ignore the fact that there
is an old version of directory already in the repository

svn: warning: 'directory' is already under version control



Subversion will not let me use the new directory because it already knows
about a previous one. The only solutions I've found from this list or from
google is to remove the directory and re-run svn update, but this loses any
changes from the new directory.

I want to be able to tell subversion to remove the old directory and add the
new one as a replacement, including any files inside. If any files have been
added/deleted then the files in the new directory should be taken as the
right thing. Something like a "svn add -force directory"



The best solution I can think of is to do the following:

mv directory directory.new

svn up

svn remove directory

svn ci

mv directory.new directory

svn add directory

svn ci

but this seems very long winded.



FYI, the 'other program' in this case is Firefox and the directory is where
it stores extensions. Whenever an extension is updated, the directory gets
replaced, but Firefox doesn't know anything about subversion so it deletes
the .svn directory too. However, this means I have no control over how the
old directory gets replaced by the new one.



Any suggestions appreciated.



Briann
Ulrich Eckhardt
2006-07-19 13:49:46 UTC
Permalink
Post by Brian Bird
Is there any way to force subversion to ignore the fact that a locally
modified folder has been entirely replaced by something else and just tell
it to save the current working copy over the repository as a new version?
mkdir directory # the real directory has several files inside it too
svn add directory
svn ci
rm -rf directory # another program removes this directory
mkdir directory # it then creates an entirely new directory with
similar files to the original directory
svn add directory # At this point I want to ignore the fact that there
is an old version of directory already in the repository
svn: warning: 'directory' is already under version control
OK, so you want to replace a dir which is already in the repository with
another dir, right?
Post by Brian Bird
Subversion will not let me use the new directory because it already knows
about a previous one. The only solutions I've found from this list or from
google is to remove the directory and re-run svn update, but this loses any
changes from the new directory.
I want to be able to tell subversion to remove the old directory and add
the new one as a replacement, including any files inside. If any files have
been added/deleted then the files in the new directory should be taken as
the right thing. Something like a "svn add -force directory"
There are two ways:
1. Just check out, overwrite with the new dir and checkin. You will have to
manually take care of added/removed files.
2. Use svn_load_dirs (mentioned in the book under 'tracking vendor sources' or
somesuch). This tries to automatically take care of added/deleted/moved files
when replacing a folder.

Uli


****************************************************
Visit our website at <http://www.domino-printing.com/>
****************************************************
This Email and any files transmitted with it are intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any reading, redistribution, disclosure or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient please contact the sender immediately and delete the material from your computer.

E-mail may be susceptible to data corruption, interception, viruses and unauthorised amendment and Domino UK Limited does not accept liability for any such corruption, interception, viruses or amendment or their consequences.
****************************************************
Erik Huelsmann
2006-07-19 17:13:05 UTC
Permalink
Post by Brian Bird
mkdir directory # the real directory has several files inside it too
svn add directory
svn ci
rm –rf directory # another program removes this directory
mkdir directory # it then creates an entirely new directory with
similar files to the original directory
But here you violate all rules about modifying working copies. See the
warning box in:
http://svnbook.red-bean.com/nightly/en/svn.tour.cycle.html#svn.tour.cycle.edit

You're not using svn commands!
Post by Brian Bird
svn add directory # At this point I want to ignore the fact that there
is an old version of directory already
Gale, David
2006-07-19 18:27:11 UTC
Permalink
Post by Erik Huelsmann
Post by Brian Bird
mkdir directory # the real directory has several files
inside it too
svn add directory
svn ci
rm -rf directory # another program removes this directory
mkdir directory # it then creates an entirely new directory
with similar files to the original directory
But here you violate all rules about modifying working copies. See the
http://svnbook.red-bean.com/nightly/en/svn.tour.cycle.html#svn.tour.cycl
e.edit
Post by Erik Huelsmann
You're not using svn commands!
HTH,
Erik.
Problem is, he's not in control of the process that's deleting &
recreating the directory--he said that it's FireFox (specifically, how
it handles the extensions folder). Now, would you suggest that he a)
hack FireFox to use subversion commands, or b) ask if there's an extant
"force" option for svn add to do what he needs? (Note: he chose option
b.)

I don't have a good solution for the original poster; my best thought
would be to have a separate working copy that is periodically rsync'd to
match the FF directory and any changes committed through a script. Not
ideal, but should work...

-David
Gavin Lambert
2006-07-19 22:53:41 UTC
Permalink
Post by Brian Bird
mkdir directory # the real directory has several files inside
it too svn add directory
svn ci
rm -rf directory # another program removes this directory
mkdir directory # it then creates an entirely new directory
with similar files to the original directory
svn add directory # At this point I want to ignore the fact that
there is an old version of directory already in the repository
svn: warning: 'directory' is already under version control
Ideally, you should use svn's own tree management commands. But it
sounds like in this case it's out of your control.

If they really are similar, then the main thing you need to do is to
preserve the '.svn' folder within (and all its contents). Make a backup
copy of it immediately following your original commit. Once the folder
has been deleted and recreated, copy the backup back in to the new
folder, then do any necessary 'svn rm'/'svn add' etc to account for
deleted/new files, then commit, and finally back up the .svn folder
again for next time.

If the folder contains subfolders, you will need to preserve all of
*those* .svn folders as well. And so forth.
Brian Bird
2006-07-20 08:11:17 UTC
Permalink
Thanks for the suggestions. I know my request is breaking the 'rules' of
svn, but I was hoping there would be a neat way to tell subversion "I'm
sorry I did it wrongly, but can you just believe that what I have now is
what I actually want".

I've ended up writing a little script to move the directories around until
subversion is happy. It's not perfect but I'm sure any of the other
solutions would work just as well.
-----Original Message-----
Sent: 19 July 2006 23:54
To: 'Brian Bird'
Subject: RE: svn add "already under version control"
Post by Brian Bird
mkdir directory # the real directory has several files inside
it too svn add directory
svn ci
rm -rf directory # another program removes this directory
mkdir directory # it then creates an entirely new directory
with similar files to the original directory
svn add directory # At this point I want to ignore the fact that
there is an old version of directory already in the repository
svn: warning: 'directory' is already under version control
Ideally, you should use svn's own tree management commands. But it
sounds like in this case it's out of your control.
If they really are similar, then the main thing you need to do is to
preserve the '.svn' folder within (and all its contents). Make a backup
copy of it immediately following your original commit. Once the folder
has been deleted and recreated, copy the backup back in to the new
folder, then do any necessary 'svn rm'/'svn add' etc to account for
deleted/new files, then commit, and finally back up the .svn folder
again for next time.
If the folder contains subfolders, you will need to preserve all of
*those* .svn folders as well. And so forth.
Continue reading on narkive:
Loading...