blob: 68814e4cc7f0db0adeefdaca8bc7841b59177fe0 [file] [log] [blame]
Tim Petersd87f81f2006-03-09 01:42:24 +00001#! /usr/bin/env python
2
3"""
4SVN helper script.
5
6Try to set the svn:eol-style property to "native" on every .py and .txt file
7in the directory tree rooted at the current directory.
8
9Files with the svn:eol-style property already set (to anything) are skipped.
10
11svn will itself refuse to set this property on a file that's not under SVN
12control, or that has a binary mime-type property set. This script inherits
13that behavior, and passes on whatever warning message the failing "svn
14propset" command produces.
15
16In the Python project, it's safe to invoke this script from the root of
17a checkout.
18
19No output is produced for files that are ignored. For a file that gets
20svn:eol-style set, output looks like:
21
22 property 'svn:eol-style' set on 'Lib\ctypes\__init__.py'
23
24For a file not under version control:
25
26 svn: warning: 'patch-finalizer.txt' is not under version control
27
28and for a file with a binary mime-type property:
29
30 svn: File 'Lib\test\test_pep263.py' has binary mime type property
31
32TODO: This is slow, and especially on Windows, because it invokes a new svn
33command-line operation for every .py and .txt file.
34"""
35
36import os
37
38for root, dirs, files in os.walk('.'):
39 if '.svn' in dirs:
40 dirs.remove('.svn')
41 for fn in files:
42 if fn.endswith('.py') or fn.endswith('.txt'):
43 path = os.path.join(root, fn)
44 p = os.popen('svn proplist "%s"' % path)
45 guts = p.read()
46 p.close()
47 if 'eol-style' not in guts:
48 os.system('svn propset svn:eol-style native "%s"' % path)