pysvn:如何获取修订号?

pysvn: How to get revision number?

使用 pysvn 通过 Python 处理我的 SVN 源存储库。

path="C:/myrepository"
client = pysvn.Client()
revision = client.update(path)

如何打印 revision 号码?

这行不通:
print "updated to revision %d" % revision.number

Revision 文档 here

您可以执行以下操作:

print "Revision: ", str(rev[0]).split(" ")[-1][:-1]

修订作为包含格式化字符串的列表返回。上面的代码标记字符串并检索修订号作为字符串的最后一个标记。

希望对您有所帮助。

如您所料,该值在 .number 属性中以整数形式提供。

鉴于你没有包括我要猜测的问题的错误。

然而,根据 Client() 的设置。commit_info_style update() 的 return 值会发生变化。例如,它可以是 dict 或 udpate 详细信息的列表。

详情见http://pysvn.tigris.org/docs/pysvn_prog_ref.html#pysvn_client_variables

Barry Scott 作者 pysvn。