我正在使用pysvn来监视Subversion目录中的更改.这是我从修订版中获取信息的方式:
(...)
svn_root = "http://svn/"
client = pysvn.Client()
from_revision = pysvn.Revision(pysvn.opt_revision_kind.number, 1500)
to_revision = pysvn.Revision( pysvn.opt_revision_kind.head )
revisions = client.log(svn_root, to_revision, to_revision, discover_changed_paths=True)
Run Code Online (Sandbox Code Playgroud)
现在,我想从一个特定的修订版本什么变化不一样,在我的例子,但在过去5次修订中的变化(从head - 5到head).我怎么能做到这一点?我如何获得头部修订的NUMBER?
我可以通过从Python调用Shell来实现.但我想使用pysvn有一种"Pythonic"方式.
得到它了.当提供检出的SVN源的路径时,我可以要求HEAD修订版如下:
headrev = client.info(svnroot).get("revision").number
Run Code Online (Sandbox Code Playgroud)
另一种选择是:
headrev = pysvn.Revision( pysvn.opt_revision_kind.head )
revlog = svnclient.log( url, revision_start=headrev, revision_end=headrev, discover_changed_paths=False)
headrev = revlog[0].revision.number
Run Code Online (Sandbox Code Playgroud)
(注意,后者仅在您使用SVN存储库的根目录时才有效.如果您提供repo的子URL(如果它不是HEAD本身),则revlog将为空)
小智 6
这是一个更好(更快)的方法:
client.revpropget("revision", url=svn_url)[0].number
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9163 次 |
| 最近记录: |