tags:

views:

397

answers:

7

In perforce you can issue a 'sync to none' command to remove files from the client, but leave them untouched in the depot (or repository in svn lingo).

p4 sync ...#none

Is there a similar command in svn?


Edit:

Thanks to those that have answered so far.

To clarify:

I don't want to use rm -rf on the directory, since it will remove all files, even those that are local only. I also don't want to have to go through by hand deleting individual files which are on the client and in the repository.

The 'p4 sync ...#none' command allows me to remove files from the client, which are in the depot/repository, and leaves local only files alone.

With a small set of files, this is not a big deal, but with numerous files it is painful to do by hand.

+3  A: 

You can simply delete the file locally (using the operating system's delete command). Although, the file will be re-created the next time you update your working copy.

Also, starting with version 1.5 you can make sparse checkouts, where you can omit some parts of the repository from being written to the working copy. But if I remember correctly, this works on directories, not on single files.

Here's the part of the release notes describing the sparse checkout feature: http://subversion.tigris.org/svn_1.5_releasenotes.html#sparse-checkouts

And here's the corresponding chapter of the SVN book: http://svnbook.red-bean.com/en/1.5/svn.advanced.sparsedirs.html

M4N
Thanks for the links. I updated my question to clarify exactly why I don't want to use delete or rm.
grieve
+1  A: 

So you basically want to remove all files that are versioned and unmodified?

You could cook up a script that iterates through all files and calls "svn status" on them, removing the files where "svn status" gives empty output...


EDIT: a naïve python script to remove files that are unmodified. Keeps unversioned and local-modified files... this is slow, would be better to issue a "svn stat -v" and parse that. The script only removes files, it doesn't touch folders.

import os
from subprocess import *

def isUnchangedInRepo(name):
    output = Popen(["svn","stat",name], stdout=PIPE).communicate()[0]
    return len(output) == 0

for dirname, dirnames, filenames in os.walk('.'):
    for filename in filenames:
     testfile = os.path.join(dirname, filename)
     if(testfile.find("\\.svn") == -1) and isUnchangedInRepo(testfile):
      print testfile
#     os.remove(testfile)
snemarch
A: 

With TortoiseSVN you can create an ignore pattern that is localized to that machine. Not sure if that fits your situation.

Good overview at http://arcware.net/tortoisesvn-global-ignore-pattern-vs-svn-ignore/.

AKeller
+1  A: 

If you want to delete only the files in the repository but not the ones only available locally, you could do so (on Linux/cygwin) with a simple shell-script, something along

 svn  st -v | cut -c '41-' | xargs echo rm

(Note: remove the echo to really delete anything).

This will, however, remove any file in the repository, regardless of local modification state.

Martin C.
A: 

Use

svn rm folderToDelete --keep-local

with TortoiseSVN, hold down the shift key while right-clicking on the folder to bring up the extended menu, then choose "Delete (keep local)".

Stefan
Wouldn't that do just the opposite of what he wants?
R. Bemrose
@ R. Bemrose: It does look like it does the opposite of what I want from reading the documentation.
grieve
Sorry, I've never used perforce, so I'm not sure what 'sync to none' really does. If it's the opposite of what I mentioned here, then:export the folder (or delete all .svn folders), then run 'svn update parentfolder --depth=files'
Stefan
+1  A: 

With Subversion 1.6.0

svn update --set-depth exclude <file>

This will remove the file from your working copy and marks that it shouldn't return on updating.

Bert Huijben
+1 you beat me by 47 seconds :-)
Wim Coenen
A: 

Alternatively create a patch. This will record all the local changes in a patch file.

In tortoise: right click->tortoiseSVN->create patch. You can later apply this patch file to a another working copy.

Ps. you didn't mentioned why you want to do it, but the above might end up being what you really needed.

eglasius