我尝试使用一个临时目录来重复 check out 和删除,如下所示:
client = pysvn.Client()
url = "..."
path = "\tmp\temp_dir"
client.checkout(url, path) # it's ok here
# clear dir and checkout again
shutil.rmtree(path)
os.makedirs(path) # ok until here
assert not os.listdir(path)
client.checkout(url, path) # EXCEPTION!
在执行最后一行时,它引发异常pysvn.ClientError: Working copy '/tmp/temp_dir' locked with additional errors:sqlite[S8]: attempt to write a readonly database .
我尝试在终端中使用 svn checkou
结帐,它工作正常。但即使在我删除了命令行 check out 的文件之后,我仍然无法通过 pysvn 在代码中 check out 相同的异常。
一些附加信息:
- 我在 Linux 上使用 python3.4 和 pysvn 1.8.0。
- 在 Windows 上使用 python3.5 和 pysvn 1.9.9 不会触发同样的问题。
谁能帮我解决这个问题?
问候
我通过获取一个新的 pysvn.Client
实例解决了这个问题。换句话说,通过使用以下代码:
client = pysvn.Client()
client.checkout(url, path) # it's ok here
# clear dir and checkout again
shutil.rmtree(path)
os.makedirs(path) # ok until here
assert not os.listdir(path)
client = pysvn.Client() # obtain another instance
client.checkout(url, path) # ok
pysvn.Client
实例中似乎缓存了一些信息,使我无法再次结账,但我不知道为什么。
我是一名优秀的程序员,十分优秀!