我正在尝试获取 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 的参数给出。
尝试在调用函数时使用完整路径。
我是一名优秀的程序员,十分优秀!