summaryrefslogtreecommitdiff
path: root/Tools/scripts/svneol.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-03-09 02:20:05 +0000
committerMartin v. Löwis <martin@v.loewis.de>2006-03-09 02:20:05 +0000
commit9f06772d45685b5127d9a1c5d44e0449298a54de (patch)
treeca0f995e2b726f9e9bcbcc6ebaeee49fe431f135 /Tools/scripts/svneol.py
parent00bb209e4aac9eddbc91fd392ba4b5cd35eb69fc (diff)
downloadcpython-9f06772d45685b5127d9a1c5d44e0449298a54de.tar.gz
Directly read working copy data to obtain list of properties.
Diffstat (limited to 'Tools/scripts/svneol.py')
-rw-r--r--Tools/scripts/svneol.py42
1 files changed, 34 insertions, 8 deletions
diff --git a/Tools/scripts/svneol.py b/Tools/scripts/svneol.py
index 9bab1750e0..d82b69f964 100644
--- a/Tools/scripts/svneol.py
+++ b/Tools/scripts/svneol.py
@@ -28,14 +28,43 @@ For a file not under version control:
and for a file with a binary mime-type property:
svn: File 'Lib\test\test_pep263.py' has binary mime type property
-
-TODO: This is slow, and especially on Windows, because it invokes a new svn
-command-line operation for every file with the right extension.
"""
import re
import os
+def proplist(root, fn):
+ "Return a list of property names for file fn in directory root"
+ path = os.path.join(root, ".svn", "props", fn+".svn-work")
+ try:
+ f = open(path)
+ except IOError:
+ # no properties file: not under version control
+ return []
+ result = []
+ while 1:
+ # key-value pairs, of the form
+ # K <length>
+ # <keyname>NL
+ # V length
+ # <value>NL
+ # END
+ line = f.readline()
+ if line.startswith("END"):
+ break
+ assert line.startswith("K ")
+ L = int(line.split()[1])
+ key = f.read(L)
+ result.append(key)
+ f.readline()
+ line = f.readline()
+ assert line.startswith("V ")
+ L = int(line.split()[1])
+ value = f.read(L)
+ f.readline()
+ f.close()
+ return result
+
possible_text_file = re.compile(r"\.([hc]|py|txt)$").search
for root, dirs, files in os.walk('.'):
@@ -43,9 +72,6 @@ for root, dirs, files in os.walk('.'):
dirs.remove('.svn')
for fn in files:
if possible_text_file(fn):
- path = os.path.join(root, fn)
- p = os.popen('svn proplist "%s"' % path)
- guts = p.read()
- p.close()
- if 'eol-style' not in guts:
+ if 'svn:eol-style' not in proplist(root, fn):
+ path = os.path.join(root, fn)
os.system('svn propset svn:eol-style native "%s"' % path)