Montag, 2. August 2010

Repair Subversion

There are dozens of error conditions which Subversion can detect but leaves you with absolutely no indication on how to repair the mess again. This Article show how to do just that: Repair Subversion. ...

I don't know why but i am constantly repairing Subversion. Subversion is relay is a pain. For one i think that putting the meta data together with the source code was a huge mistake.

For example a global search and replace might change a “*.java.svn-base” and then the checksum test will make your work-tree un-usable. The checksum is pretty useless without a repair function to repair faulty files. What did they thing of it.

svn: Checksum mismatch for 'FX-603P-SE/.settings/org.eclipse.jdt.core.prefs'; expected: '33f9638b66b5ab7e7a2885626ebfd0c0', actual: '8f9117c1dc39a48270c6f17d2142a044'

And this is only one example. There are dozens of error conditions which Subversion can detect but leaves you with absolutely no indication on how to repair the mess again. For example:
[/FONT]

>svn cleanup FX-603P-SE
svn: In directory 'FX-603P-SE'
svn: Error processing command 'committed' in 'FX-603P-SE'
svn: Working copy '.' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)

I just did a clean-up so why do you want one again. But this one is also easy a «grm --verbose **/".svn/lock"» will do the trick.

But there are worse and often the only fix there is, is to delete the directory tree and get a new fresh version from the archive. But often you have changed files as well which you don't want to lose. Since this happens to my far to often I created a repair script. It is designed for ZShell and MacPorts on Mac OS X.

#!/opt/local/bin/zsh
########################################################### {{{1 ###########
# Copyright © 2005…2010 Martin Krischik
############################################################################
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
########################################################### }}}1 ###########

setopt Extended_Glob;
setopt CSH_Null_Glob;
setopt No_X_Trace;
setopt Err_Exit;

typeset -r in_Directory=${1}

svn cleanup
gmv --verbose "${in_Directory}" "${in_Directory}.Fix_Directory"
svn cleanup
svn update "${in_Directory}"

pushd "${in_Directory}.Fix_Directory"
for I in **/".svn"; do
grm --recursive --force "${I}"
done; unset I
gcp --verbose --archive "." "../${in_Directory}"
popd

svn commit -m"Fixed Directory" "${in_Directory}"
grm --recursive --force "${in_Directory}.Fix_Directory"

############################################################ {{{1 ###########
# vim: set nowrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab :
# vim: set textwidth=0 filetype=zsh foldmethod=marker nospell :

The script takes a single parameter, the directory to repair. It renames the offensive directory, gets a new copy from Subversion and then copies all the (non Subversion) files to the new working copy.

Afterwards you should be fine again.

Keine Kommentare:

Kommentar veröffentlichen