This is an old revision of the document!


Add Missing Files Recursively

svn status | grep "^\?" | awk '{print $2}' | xargs svn add

Delete or Filter Revisions

The generic procedure is the following:

  • dump the svn repository with svnadmin dump.
  • filter the dump file with svndumpfilter.
  • create a new repository.
  • load the modified dump file.

Delete Revisions

In order to delete revisions by number, say 1 through 500, the procedure is as follows:

  • dump the svn repository and select the revisions that you want to keep:
svnadmin dump /path/to/repo -r1:500 > repo.dump
  • create a new repository:
svnadmin create /path/to/newrepo 
  • import the dump:
svnadmin load /path/to/newrepo < repo.dump

Delete a Range of Revisions

Deleting a range of revisions involves dumping the exclusion set around those revisions and then importing both dumps. Suppose we wanted to delete revision 500 from a total of 1000 revisions, then we would:

  • dump revision 1 to 499 to a file dump_1.
  • dump revision 501 to 1000 by passing the –incremental option to the svnadmin dump command to a file dump_2.
  • create a new repository.
  • first load the first dump file dump_1 and then load the second dump file dump_2.

Note that removing intermediary revisions will fail if new files have been added in the revisions to be deleted and then altered in following revisions because svnadmin would, in that case, attempt to load changes to files that have not been created in the first place.

Filter Dump Files

In order to delete unwanted files or folders from a subversion repository, the svndumpfilter command is used that can pattern-match files or folders in a dump file and create a new dump with those files or folders excluded or included.

  • dump the repository:
svnadmin dump /path/to/repo > repo.dump
  • now we can exclude or include files that will be either removed, respectively kept in the new dump file.

Excluding can be performed by:

svndumpfilter exclude somefile < repo.dump > newrepo.dump

Including can be done by:

svndumpfilter include somefile < repo.dump > newrepo.dump

Both inclusion and exclusion can be performed by pattern matching, for example, to exclude pdf files:

svndumpfilter exclude --pattern '*.pdf' < repo.dump > newrepo.dump
  • now create the new repository:
svnadmin create /path/to/newrepo
  • and load the filtered dump:
svnadmin load /path/to/newrepo < newrepo.dump

Checkout Repository and Overwrite Files

Subversion can be made to checkout a repository on top of an existing directory structure that may contain files in the repository to be checked out. If the checkout is executed without any flags, then Subversion will throw errors such as An obstructing working copy was found.

To merge the copy being checked out with the local existing files, you would first clean all .svn folders from the directory structure and then issue:

svn --force co http://svn.server.tld/project

which, from the documentation, will check out the repository on top of existing files and consider the local files to be local changes, marking them as modified. However, we want to overwrite the local files with the files from the repository and we thus need to chuck away any local "modifications". In order to do that, issue:

svn revert -R project 

and the local files will be overwritten by the files from the repository.

Exporting Contents of Subversion Directory to Current Directory

Suppose that you have some configuration files in a Subversion repository:

/configuration-templates/samba/3/standalone/smb.conf
/configuration-templates/samba/3/standalone/smb.conf.local
/configuration-templates/samba/3/standalone/smb.conf.share

and that you wish to tell Subversion to download those files to /etc/samba but without creating the standalone directory and without creating a .svn directory (that is, without keeping them under version control).

In such cases, you can use the export feature of Subversion. Change to the destination directory:

cd /etc/samba/

and now export the Subversion directory:

svn export http://svn.grimore.org/configuration-templates/samba/3/standalone --force .

where:

  • –force will allow Subversion to overwrite any files in the current directory - this is necessary, otherwise Subversion will say that the current directory already exists - which is obviously the case since we are in /etc/samba/.
  • the dot . at the end of the command will export the contents of the standalone directory (ie: without ending up with /etc/samba/standalone) - thus, it will only pull the configuration files.

fuss/subversion.1488114225.txt.bz2 · Last modified: 2017/02/26 13:03 by office

Wizardry and Steamworks

© 2025 Wizardry and Steamworks

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.