aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/update-svn-properties.py
diff options
context:
space:
mode:
Diffstat (limited to 'update-svn-properties.py')
-rwxr-xr-xupdate-svn-properties.py68
1 files changed, 37 insertions, 31 deletions
diff --git a/update-svn-properties.py b/update-svn-properties.py
index 99523e7..8cb564d 100755
--- a/update-svn-properties.py
+++ b/update-svn-properties.py
@@ -2,7 +2,7 @@
2 2
3import os, os.path, popen2, re, string, sys 3import os, os.path, popen2, re, string, sys
4 4
5def textfile(file): 5def text(file):
6 return { 6 return {
7 "svn:eol-style" : "native" 7 "svn:eol-style" : "native"
8 } 8 }
@@ -38,50 +38,54 @@ def binary_or_text(file):
38 if is_binary(file): 38 if is_binary(file):
39 return binary(file) 39 return binary(file)
40 else: 40 else:
41 return textfile(file) 41 return text(file)
42 42
43property_map = { 43property_map = {
44 ".bat" : script, 44 ".bat" : script,
45 ".cgi" : textfile, 45 ".build" : text,
46 ".config" : textfile, 46 ".cfg" : text,
47 ".cs" : textfile, 47 ".cgi" : text,
48 ".csproj" : textfile, 48 ".config" : text,
49 ".cs" : text,
50 ".csproj" : text,
49 ".dat" : binary_or_text, 51 ".dat" : binary_or_text,
50 ".dll" : binary, 52 ".dll" : binary,
51 ".dylib" : binary, 53 ".dylib" : binary,
52 ".example" : textfile, 54 ".example" : text,
53 ".exe" : executable, 55 ".exe" : executable,
54 ".fxcop" : textfile, 56 ".fxcop" : text,
57 ".hgignore" : text,
55 ".ico" : binary, 58 ".ico" : binary,
56 ".include" : textfile, 59 ".include" : text,
57 ".ini" : textfile, 60 ".ini" : text,
58 ".j2c" : binary, 61 ".j2c" : binary,
59 ".jp2" : binary, 62 ".jp2" : binary,
60 ".lsl" : textfile, 63 ".lsl" : text,
61 ".mdp" : textfile, 64 ".mdp" : text,
62 ".mds" : textfile, 65 ".mds" : text,
63 ".nsi" : textfile, 66 ".nsi" : text,
64 ".pdb" : binary, 67 ".pdb" : binary,
65 ".php" : script, 68 ".php" : script,
66 ".pidb" : binary, 69 ".pidb" : binary,
67 ".pl" : script, 70 ".pl" : script,
68 ".pm" : textfile, 71 ".plist" : text,
72 ".pm" : text,
69 ".png" : binary, 73 ".png" : binary,
70 ".py" : script, 74 ".py" : script,
71 ".rb" : script, 75 ".rb" : script,
72 ".resx" : textfile, 76 ".resx" : text,
73 ".settings" : textfile, 77 ".settings" : text,
74 ".stetic" : textfile, 78 ".stetic" : text,
75 ".sh" : script, 79 ".sh" : script,
76 ".snk" : binary, 80 ".snk" : binary,
77 ".so" : binary, 81 ".so" : binary,
78 ".sql" : textfile, 82 ".sql" : text,
79 ".txt" : textfile, 83 ".txt" : text,
80 ".user" : textfile, 84 ".user" : text,
81 ".userprefs" : textfile, 85 ".userprefs" : text,
82 ".usertasks" : textfile, 86 ".usertasks" : text,
83 ".xml" : textfile, 87 ".xml" : text,
84 ".xsd" : textfile 88 ".xsd" : text
85} 89}
86 90
87def propset(file, property, value): 91def propset(file, property, value):
@@ -125,7 +129,7 @@ def proplist(file):
125 else: 129 else:
126 return "" 130 return ""
127 131
128def update_file(file, properties): 132def update_file(file, properties, ignorelist):
129 current_props = proplist(file) 133 current_props = proplist(file)
130 134
131 if current_props is None: 135 if current_props is None:
@@ -133,23 +137,23 @@ def update_file(file, properties):
133 return 137 return
134 138
135 for p in current_props: 139 for p in current_props:
136 if not properties.has_key(p): 140 if p not in ignorelist and not properties.has_key(p):
137 propdel(file, p) 141 propdel(file, p)
138 142
139 for p in properties: 143 for p in properties:
140 if p not in current_props or propget(file, p) != properties[p]: 144 if p not in current_props or propget(file, p) != properties[p]:
141 propset(file, p, properties[p]) 145 propset(file, p, properties[p])
142 146
143def update(dir): 147def update(dir, ignorelist):
144 for f in os.listdir(dir): 148 for f in os.listdir(dir):
145 fullpath = os.path.join(dir, f) 149 fullpath = os.path.join(dir, f)
146 if os.path.isdir(fullpath): 150 if os.path.isdir(fullpath):
147 if not os.path.islink(fullpath): 151 if not os.path.islink(fullpath):
148 update(fullpath) 152 update(fullpath, ignorelist)
149 else: 153 else:
150 extension = os.path.splitext(fullpath)[1].lower() 154 extension = os.path.splitext(fullpath)[1].lower()
151 if property_map.has_key(extension): 155 if property_map.has_key(extension):
152 update_file(fullpath, property_map[extension](fullpath)) 156 update_file(fullpath, property_map[extension](fullpath), ignorelist)
153 elif extension != "" and proplist(fullpath) is not None: 157 elif extension != "" and proplist(fullpath) is not None:
154 print "Warning: No properties defined for %s files (%s)" % (extension, fullpath) 158 print "Warning: No properties defined for %s files (%s)" % (extension, fullpath)
155 159
@@ -157,7 +161,9 @@ def main(argv = None):
157 if argv is None: 161 if argv is None:
158 argv = sys.argv 162 argv = sys.argv
159 163
160 update(".") 164 ignorelist = ("svn:keywords",)
165
166 update(".", ignorelist)
161 167
162if __name__ == "__main__": 168if __name__ == "__main__":
163 sys.exit(main()) 169 sys.exit(main())