Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8ff2120

Browse files
committed
Directly read working copy data to obtain list of properties.
1 parent 84457af commit 8ff2120

1 file changed

Lines changed: 34 additions & 8 deletions

File tree

Tools/scripts/svneol.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,50 @@
2828
and for a file with a binary mime-type property:
2929
3030
svn: File 'Lib\test\test_pep263.py' has binary mime type property
31-
32-
TODO: This is slow, and especially on Windows, because it invokes a new svn
33-
command-line operation for every file with the right extension.
3431
"""
3532

3633
import re
3734
import os
3835

36+
def proplist(root, fn):
37+
"Return a list of property names for file fn in directory root"
38+
path = os.path.join(root, ".svn", "props", fn+".svn-work")
39+
try:
40+
f = open(path)
41+
except IOError:
42+
# no properties file: not under version control
43+
return []
44+
result = []
45+
while 1:
46+
# key-value pairs, of the form
47+
# K <length>
48+
# <keyname>NL
49+
# V length
50+
# <value>NL
51+
# END
52+
line = f.readline()
53+
if line.startswith("END"):
54+
break
55+
assert line.startswith("K ")
56+
L = int(line.split()[1])
57+
key = f.read(L)
58+
result.append(key)
59+
f.readline()
60+
line = f.readline()
61+
assert line.startswith("V ")
62+
L = int(line.split()[1])
63+
value = f.read(L)
64+
f.readline()
65+
f.close()
66+
return result
67+
3968
possible_text_file = re.compile(r"\.([hc]|py|txt)$").search
4069

4170
for root, dirs, files in os.walk('.'):
4271
if '.svn' in dirs:
4372
dirs.remove('.svn')
4473
for fn in files:
4574
if possible_text_file(fn):
46-
path = os.path.join(root, fn)
47-
p = os.popen('svn proplist "%s"' % path)
48-
guts = p.read()
49-
p.close()
50-
if 'eol-style' not in guts:
75+
if 'svn:eol-style' not in proplist(root, fn):
76+
path = os.path.join(root, fn)
5177
os.system('svn propset svn:eol-style native "%s"' % path)

0 commit comments

Comments
 (0)