python - 有没有办法让 Mercurial 给我更详细的错误消息?

标签 python mercurial

当 Mercurial 进程在本地运行时,我的 Hook 在远程服务器上运行时遇到问题。错误消息信息不是很丰富,但我很确定这是一个 Python 路径问题。当我尝试提交变更集时收到错误。

有没有办法获得完整的堆栈跟踪?以下输出都没有堆栈跟踪那么有用。

这是常规错误消息:

C:\workspaces\test_next>hg commit -m "test"
Exception AttributeError: "'PPReleaseProject' object has no attribute '_projectname'" in <bound method PPReleaseProject.
__del__ of <testtrack.interface.PPReleaseProject object at 0x01BE35F0>> ignored

abort: precommit.fix_in_progress hook failed

这是带有 --traceback 的输出:

C:\workspaces\test_next>hg --traceback commit -m "test"
Exception AttributeError: "'PPReleaseProject' object has no attribute '_projectname'" in <bound method PPReleaseProject.
__del__ of <testtrack.interface.PPReleaseProject object at 0x01C065F0>> ignored

Traceback (most recent call last):
  File "mercurial\dispatch.pyo", line 54, in _runcatch
  File "mercurial\dispatch.pyo", line 494, in _dispatch
  File "mercurial\dispatch.pyo", line 355, in runcommand
  File "mercurial\dispatch.pyo", line 545, in _runcommand
  File "mercurial\dispatch.pyo", line 499, in checkargs
  File "mercurial\dispatch.pyo", line 492, in <lambda>
  File "mercurial\util.pyo", line 420, in check
  File "mercurial\commands.pyo", line 769, in commit
  File "mercurial\cmdutil.pyo", line 1209, in commit
  File "mercurial\commands.pyo", line 764, in commitfunc
  File "mercurial\localrepo.pyo", line 892, in commit
  File "mercurial\localrepo.pyo", line 153, in hook
  File "mercurial\hook.pyo", line 142, in hook
  File "mercurial\hook.pyo", line 84, in _pythonhook
Abort: precommit.fix_in_progress hook failed
abort: precommit.fix_in_progress hook failed

使用 --debug 的输出:

C:\workspaces\test_next>hg --debug commit -m "test"
calling hook precommit.branch_check: <function precommit_bad_branch at 0x01C585F0>
calling hook precommit.debug_code_check: <function precommit_contains_debug_code at 0x01C4A830>
calling hook precommit.fix_in_progress: <function precommit_fix_in_progress at 0x01C09270>
Exception AttributeError: "'PPReleaseProject' object has no attribute '_projectname'" in <bound method PPReleaseProject.
__del__ of <testtrack.interface.PPReleaseProject object at 0x01C5D5D0>> ignored

abort: precommit.fix_in_progress hook failed

最佳答案

修改您的钩子(Hook)脚本以捕获异常(将其包装在 try... except block 中),并在 except 子句中使用 traceback 模块来格式化全长回溯并将其写出到 stderr/stdout?

关于python - 有没有办法让 Mercurial 给我更详细的错误消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4122392/

相关文章:

python - 程序将数组分成N个连续的子数组,使得每个子数组的和为奇数

Mercurial 每个功能工作流程,单个开发人员

eclipse - Eclipse 中带有 mercurial 的红色感叹号

带单行的 Mercurial 日志

python - 使用 node-celery(MeteorJS) 和 ampq 后端时,Celery 不返回结果

Python facebook-sdk 发布到页面

python - 给定模型的 Django GenericForeignKey 查找

python - 如何获取&lt;script&gt;标签内的文本

Mercurial : user friendly way to display exact revision number of files?

windows - Mercurial 中不区分大小写的文件名处理