gpt4 book ai didi

python - pysvn 给出错误 : Not a working copy

转载 作者:太空宇宙 更新时间:2023-11-04 06:33:49 25 4
gpt4 key购买 nike

我正在尝试获取 svn 中一组文件的最后修改的作者姓名。

我已经在我的机器上检查了代码。

在我的脚本中,所有文件的绝对路径都是在列表中读取的。我正在尝试使用以下代码为每个文件提取最后编辑的作者。

for file in all_files:
dir = os.path.dirname(file)
entry = client.info(dir)
print "Folder:"+dir+" And author:"+entry['commit_author']

但是我收到以下错误:

File "test_main.py", line 110, in main
entry = client.info(dir)
pysvn._pysvn.ClientError: '.' is not a working copy

我尝试将整个文件名作为 client.info() 的参数,得到了相同的结果。

这可能是一个非常简单的问题,但我是 python 的新手,所以无法弄清楚。

编辑:

我尝试将文件夹路径硬编码为:

  temp = "/home/gajananh/scripts/test/repo/test_proj/src";
entry = client.info(temp)
print "Folder:"+dir+" And author:"+entry['commit_author']

而且有效!

在我的第一个脚本中,当我尝试在循环中打印 dir 变量时,它会打印出正确的路径。当我尝试在 shell 上运行 svn info 命令以获得输出时,我得到了正确的结果。

我无法理解这个奥秘。请帮忙。

最佳答案

我认为 for file in all_files: 返回具有相对路径的文件,如 ./file.txt

当您运行 os.path.dirname(file) 时,返回的路径将只是一个“.” (点)作为 svn 的参数给出。

尝试在调用函数时使用完整路径。

关于python - pysvn 给出错误 : Not a working copy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13918321/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com