Python 2.7 Notify钩子抛出一个整数是必需的错误。为什么?
我正在使用notCi钩子通知我的CI服务器。这不会给我任何问题 hg=版本2.2.1 OS=Linux Python 2.6.6 但是给我一个问题 hg=版本4.6.1 os=Linux Python 2.7.5 我看HG4.6.1版本有变化,知道吗Python 2.7 Notify钩子抛出一个整数是必需的错误。为什么?,python-2.7,mercurial,hook,Python 2.7,Mercurial,Hook,我正在使用notCi钩子通知我的CI服务器。这不会给我任何问题 hg=版本2.2.1 OS=Linux Python 2.6.6 但是给我一个问题 hg=版本4.6.1 os=Linux Python 2.7.5 我看HG4.6.1版本有变化,知道吗 22 def notci(ui, repo, node=None, **kwargs): 23 """Notify the continuous integration server about pushed changesets.
22 def notci(ui, repo, node=None, **kwargs):
23 """Notify the continuous integration server about pushed changesets.
24 """
25
26 (isRemote, uid) = __parse_url(kwargs['url'])
27 if not isRemote:
28 return False
29
30 ui.status(_('Not CI'))
31 rel_repo = repo.root[len('/test/repo/'):]
32 print rel_repo
33 for rev in xrange(repo[node], len(repo)):
34 cset = repo[rev]
35 print cset
36 curl = '/usr/bin/curl -d repo=/%s -d user=%s -d changeset=%s -d branch=%s http://jenkins.com'
37 curl = curl % (rel_repo, uid, cset, cset.branch())
38 print curl
39 ui.status(_(" %s pushed changeset %s\n" % (uid, cset)))
40 #ui.status(_("%s\n" % curl))
41 if subprocess.call(curl, shell=True):
42 ui.status(_("Could not notify service\n"))
43 return False
错误:notifyci中的第33行
对于xrange中的rev(repo[node],len(repo)):TypeError:整数为
必需的
我对此进行了更深入的研究,发现如果我从第33行删除repo[node],它会移动到下一行,但没有给我正确的更改集。问题似乎在于repo[node]repo[node]返回的对象无法再隐式转换为整数。您需要显式获取修订号user
repo[node].rev()
第33行变成:
for rev in xrange(repo[node].rev(), len(repo)):
(免责声明:我没有测试代码)这可能与本系列中的更改有关。您可以使用此处定义的
changecxdeprecwarn
函数,第380行。您知道notifyci
中的node
是哪种对象吗?谢谢您的回答。我也是这样做的。c=repo[node],适用于xrange中的rev(c.rev(),len(repo)):