source: scm_utilities/svn/trunk/desvn.py @ 3

Last change on this file since 3 was 3, checked in by TonyB, 11 years ago

Initial import - svn utilities

File size: 1.3 KB
Line 
1#! /usr/bin/python
2# Remove .svn directories from a directory tree; only tested under Windows (but might work under *nix)
3# Usage:
4#  desvn.py --> GUI directory selector
5#  desvn.py dir1 dir2 ... dir n --> removes .svn directories from dir1 tree, dir2 tree, etc
6
7import Tkinter, tkFileDialog, os, shutil, os.path, sys, stat
8
9# get list of directories to remove .svn subdirectories
10if len(sys.argv) == 1:
11    root = Tkinter.Tk()
12    dirList = [tkFileDialog.askdirectory(parent=root,
13               initialdir="/",title='Please select Directory:', mustexist=1)]
14    root.destroy()
15else:
16    dirList = sys.argv[1:]
17
18# now walk the directory tree and remove all .svn directories
19for treeTop in dirList:
20    for dir, subdir, files in os.walk(treeTop, True):
21        if os.path.basename(dir) == ".svn":
22            # remove any read-only attributes from the .svn directory tree
23            for svnDir, svnSubs, svnFiles in os.walk(dir, True):
24                os.chmod(svnDir, stat.S_IREAD | stat.S_IWRITE)
25                for filePath in svnFiles:
26                    os.chmod(os.path.join(svnDir, filePath), stat.S_IREAD | stat.S_IWRITE)
27            # remove .svn directory tree
28            shutil.rmtree(dir)
29            subdir = []
30            print 'Removed %s' % (dir)
31           
Note: See TracBrowser for help on using the repository browser.