[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Adding forgotten files to a svn repository

From: Rafael Garcia-Suarez <rgarciasuarez_at_wanadoo.fr>
Date: 2002-11-05 22:43:38 CET

Colin D Bennett wrote:
> Here's a very simple script I hacked together one day so I could unpack a
> source tarball into a working copy, run the script, and then svn commit, and
> the repo should then be synced with my tarball.
>
>
> #!/usr/bin/perl -w
> # Syncronize an svn workspace by scheduling any files added or removed
> # from the working copy to be added/removed from svn.
> #
> use strict;
>
> my @added = ();
> my @removed = ();
>
> while (<>) {
> /^(.)(.) {5}(.*)$/ or do { print "line didn't match: $_"; next; };

(I'd warn() here instead of print().)

> my $status = $1;
> my $propstatus = $2;
> my $file = $3;
> $status eq "!" && push(@removed, $file);
> $status eq "?" && push(@added, $file);
> }
>
> @removed > 0 and print "svn rm " . join(' ', @removed) . "\n\n";
> @added > 0 and print "svn add " . join(' ', @added) . "\n\n";

This won't work to add files recursively in directories you've just added.
Ditto for the deleted files -- you may leave empty directories in
your repository -- or directories that only contain files that are
ignored by svn status.

In fact if you want to add all files you have to recurse into
subdirs. If you want to do this cleanly you may want to check their
names against a possible svn:ignore property set on the first parent
dir under version control.

Another tool that may be useful is a tool that takes a diff as
input, applies it with patch(1), and performs the relevant
svn add/svn rm commands that are needed to prepare a commit.
(This tool will need to predict the files and directories that will
be added and removed by patch(1).)

[sorry, meant to send this to the list]

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Nov 5 22:43:44 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.