Conservatively restrict support to format 8 repositories.
This commit is contained in:
parent
49ac5aa2ef
commit
a6e02e8406
|
@ -33,48 +33,50 @@ and for a file with a binary mime-type property:
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def propfile(root, fn):
|
def propfiles(root, fn):
|
||||||
default = os.path.join(root, ".svn", "props", fn+".svn-work")
|
default = os.path.join(root, ".svn", "props", fn+".svn-work")
|
||||||
try:
|
try:
|
||||||
format = int(open(os.path.join(root, ".svn", "format")).read().strip())
|
format = int(open(os.path.join(root, ".svn", "format")).read().strip())
|
||||||
except IOError:
|
except IOError:
|
||||||
return default
|
return []
|
||||||
# XXX I don't know what version uses what format;
|
if format == 8:
|
||||||
# this condition is just anecdotal
|
# In version 8, committed props are stored in prop-base,
|
||||||
if format >= 8:
|
# local modifications in props
|
||||||
return os.path.join(root, ".svn", "prop-base", fn+".svn-base")
|
return [os.path.join(root, ".svn", "prop-base", fn+".svn-base"),
|
||||||
return default
|
os.path.join(root, ".svn", "props", fn+".svn-work")]
|
||||||
|
raise ValueError, "Unknown repository format"
|
||||||
|
|
||||||
def proplist(root, fn):
|
def proplist(root, fn):
|
||||||
"Return a list of property names for file fn in directory root"
|
"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 = []
|
result = []
|
||||||
while 1:
|
for path in propfiles(root, fn):
|
||||||
# key-value pairs, of the form
|
try:
|
||||||
# K <length>
|
f = open(path)
|
||||||
# <keyname>NL
|
except IOError:
|
||||||
# V length
|
# no properties file: not under version control,
|
||||||
# <value>NL
|
# or no properties set
|
||||||
# END
|
continue
|
||||||
line = f.readline()
|
while 1:
|
||||||
if line.startswith("END"):
|
# key-value pairs, of the form
|
||||||
break
|
# K <length>
|
||||||
assert line.startswith("K ")
|
# <keyname>NL
|
||||||
L = int(line.split()[1])
|
# V length
|
||||||
key = f.read(L)
|
# <value>NL
|
||||||
result.append(key)
|
# END
|
||||||
f.readline()
|
line = f.readline()
|
||||||
line = f.readline()
|
if line.startswith("END"):
|
||||||
assert line.startswith("V ")
|
break
|
||||||
L = int(line.split()[1])
|
assert line.startswith("K ")
|
||||||
value = f.read(L)
|
L = int(line.split()[1])
|
||||||
f.readline()
|
key = f.read(L)
|
||||||
f.close()
|
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
|
return result
|
||||||
|
|
||||||
possible_text_file = re.compile(r"\.([hc]|py|txt|sln|vcproj)$").search
|
possible_text_file = re.compile(r"\.([hc]|py|txt|sln|vcproj)$").search
|
||||||
|
|
Loading…
Reference in New Issue