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

Re: cvspurge subversio equivalent

From: Max Bowsher <maxb_at_ukf.net>
Date: 2004-09-09 00:00:01 CEST

> Edvard Majakari wrote:
>> Hi folks,
>> You'd imagine this is in the FAQ. Oftentimes when I wanted to make sure
>> there's no cruft lingering around eg. after building a system, I used to
>> run 'cvspurge', which removed every file from current dir and subdirs not
>> known to CVS. I can't find equivalent in Subversion after reading the
>> manual.

Helge Jensen wrote:
> You could use
> svn status --no-ignore | grep -e '^[I\?]' | cut -c 8-
> to get a list of those files and directories that SVN doesn't know or is
> ignoring.
> Then you could further pipe that into
> xargs rm -r
> But you'd need to think a bit about esacping whitespace if the
> file-names contain such. especially newlines would give you a hard time :)

Indeed, that's the correct principal. Here's my script:

#! /bin/bash

if [ "$1" = "-n" ]; then
  echo "DRYRUN MODE"

for i in `${SVN-svn} status --no-ignore "$@" | sed -n 's/^[I\?] //p'`
  if [ "${i/,//}" != "$i" -o "${i/%.swp//}" != "$i" ] ; then
    echo "SKIPPING: $i"
    echo "$i"
    if [ -z "$DRYRUN" ]; then
      rm -rf "$i"

I've made a few enhancements above the core functionality.

1. Dryrun (-n) mode

2. Handles whitespace in names (but not newlines)

3. Condenses the grep&cut into a single sed.

4. Skips *.swp files (vim swap).

5. Skips things with commas in the name. I use this to maintain unversioned
stores of scripts, notes, etc. within a working copy, and avoid accidentally
purging them.

I guess I should add this to tools/client-side/...


To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Sep 9 00:31:22 2004

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