diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-06-14 06:24:44 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-06-14 06:24:44 (GMT) |
commit | a6e02e84069b5311d145c6e342c13f393c734d5b (patch) | |
tree | 34b49124310d8df2a2e9681d1d6a81523f445434 /Tools | |
parent | 49ac5aa2efc7bf2798057df0298f3ea8400dc01f (diff) | |
download | cpython-a6e02e84069b5311d145c6e342c13f393c734d5b.zip cpython-a6e02e84069b5311d145c6e342c13f393c734d5b.tar.gz cpython-a6e02e84069b5311d145c6e342c13f393c734d5b.tar.bz2 |
Conservatively restrict support to format 8 repositories.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/scripts/svneol.py | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/Tools/scripts/svneol.py b/Tools/scripts/svneol.py index 5864cdc..9e57bb4 100644 --- a/Tools/scripts/svneol.py +++ b/Tools/scripts/svneol.py @@ -33,48 +33,50 @@ and for a file with a binary mime-type property: import re import os -def propfile(root, fn): +def propfiles(root, fn): default = os.path.join(root, ".svn", "props", fn+".svn-work") try: format = int(open(os.path.join(root, ".svn", "format")).read().strip()) except IOError: - return default - # XXX I don't know what version uses what format; - # this condition is just anecdotal - if format >= 8: - return os.path.join(root, ".svn", "prop-base", fn+".svn-base") - return default + return [] + if format == 8: + # In version 8, committed props are stored in prop-base, + # local modifications in props + return [os.path.join(root, ".svn", "prop-base", fn+".svn-base"), + os.path.join(root, ".svn", "props", fn+".svn-work")] + raise ValueError, "Unknown repository format" def proplist(root, fn): "Return a list of property names for file fn in directory root" - path = propfile(root, fn) - 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() + for path in propfiles(root, fn): + try: + f = open(path) + except IOError: + # no properties file: not under version control, + # or no properties set + continue + 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|sln|vcproj)$").search |