如何在通过ssh推送后强制rhodecode使缓存无效

时间:2013-01-08 08:50:18

标签: version-control mercurial paster rhodecode

我正在运行一个用于代码审查等的rhodecode实例。但是当我通过ssh推送时,rhodecode没有看到变更集(除非我从hgweb手动拉动)。

我是否需要在mercurial中使用传入钩子或者某些东西才能让rhodecode正常工作?

修改

通过添加钩子incoming.rhodecode = python:rhodecode.lib.hooks.log_push_action我得到了栈跟踪:

remote:   File "/usr/share/mercurial-server/hg-ssh", line 91, in <module>
remote:     dispatch.dispatch(request(['-R', repo, 'serve', '--stdio']))
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 65, in dispatch
remote:     return _runcatch(req)
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 88, in _runcatch
remote:     return _dispatch(req)
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 741, in _dispatch
remote:     cmdpats, cmdoptions)
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 514, in runcommand
remote:     ret = _runcommand(ui, options, cmd, d)
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 831, in _runcommand
remote:     return checkargs()
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 802, in checkargs
remote:     return cmdfunc()
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/dispatch.py", line 738, in <lambda>
remote:     d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/util.py", line 472, in check
remote:     return func(*args, **kwargs)
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/commands.py", line 5211, in serve
remote:     s.serve_forever()
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/sshserver.py", line 94, in serve_forever
remote:     while self.serve_one():
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/sshserver.py", line 112, in serve_one
remote:     rsp = wireproto.dispatch(self.repo, self, cmd)
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/wireproto.py", line 351, in dispatch
remote:     return func(repo, proto, *args)
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/wireproto.py", line 629, in unbundle
remote:     lock.release()
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/lock.py", line 143, in release
remote:     callback()
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/localrepo.py", line 2452, in runhooks
remote:     source=srctype, url=url)
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/localrepo.py", line 386, in hook
remote:     return hook.hook(self.ui, self, name, throw, **args)
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/hook.py", line 181, in hook
remote:     r = _pythonhook(ui, repo, name, hname, hookfn, args, throw) or r
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/hook.py", line 38, in _pythonhook
remote:     obj = __import__(modname)
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/demandimport.py", line 95, in _demandimport
remote:     return _import(name, globals, locals, fromlist, level)
remote:   File "/usr/local/lib/python2.7/dist-packages/rhodecode/lib/hooks.py", line 35, in <module>
remote:     from rhodecode.lib.utils import action_logger
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/demandimport.py", line 114, in _demandimport
remote:     mod = _origimport(name, globals, locals)
remote:   File "/usr/local/lib/python2.7/dist-packages/rhodecode/lib/utils.py", line 55, in <module>
remote:     from rhodecode.model.db import Repository, User, RhodeCodeUi, \
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/demandimport.py", line 114, in _demandimport
remote:     mod = _origimport(name, globals, locals)
remote:   File "/usr/local/lib/python2.7/dist-packages/rhodecode/model/db.py", line 147, in <module>
remote:     class RhodeCodeSetting(Base, BaseModel):
remote:   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative.py", line 1343, in __init__
remote:     _as_declarative(cls, classname, cls.__dict__)
remote:   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative.py", line 1082, in _as_declarative
remote:     class_mapped = _is_mapped_class(base)
remote:   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/util.py", line 696, in _is_mapped_class
remote:     manager = attributes.manager_of_class(cls)
remote:   File "/usr/local/lib/python2.7/dist-packages/mercurial/demandimport.py", line 87, in __getattribute__
remote:     return getattr(self._module, attr)
remote: AttributeError: 'module' object has no attribute 'manager_of_class'
abort: unexpected response: empty string

1 个答案:

答案 0 :(得分:3)

RhodeCode使用推后挂钩来使存储库的缓存无效,并在其日志中存储推/拉事件。你可以做一些事情来解决这个问题。

  • 禁用vcs_full_cache,并将缓存过期时间调低至某个较低的数字(例如60秒)
  • 在推送SSH时调用正确的RhodeCode挂钩,我认为这是最合适的解决方案