[Bug 4983] New: post-init and post-clone hooks always crash (after hg init / hg clone)
mercurial-bugs at selenic.com
mercurial-bugs at selenic.com
Wed Dec 2 23:08:41 UTC 2015
https://bz.mercurial-scm.org/show_bug.cgi?id=4983
Bug ID: 4983
Summary: post-init and post-clone hooks always crash (after hg
init / hg clone)
Product: Mercurial
Version: 3.6.2
Hardware: PC
OS: Linux
Status: UNCONFIRMED
Keywords: regression
Severity: bug
Priority: urgent
Component: Mercurial
Assignee: bugzilla at selenic.com
Reporter: sbbrouwer at gmail.com
CC: mercurial-devel at selenic.com
Description
===========
Starting shortly before 3.6-rc, and still present: all post-init and post-clone
hooks always fail with an AttributeError when the hook is run. The bug lies in
hook.py. It is triggered when `_exthook(ui, repo, ...)` tries to access
repo.currenttransaction(), but `repo` is None -- which is apparently true for
post-init or post-clone hooks, and possibly others.
Expected behaviour
==================
That a hook like `post-init = echo "set your username"` does not crash.
Affected versions
=================
* changeset that introduced the bug: 520defbc0335 "hook: centralize passing
HG_PENDING to external hook process". Its parent, 9f9ec4abe700, does not
display the bug.
* last release without the bug: 3.5.2.
* first release with the bug: 3.6-rc.
* The bug is still present in 7e1fac6c0a9c (current tip).
Steps to reproduce (inc. traceback)
===================================
The shell commands below show that `hg init` works (so hg init is not the
problem), and that echoing 'hi' work as a post-status hook (so the hook
contents are not the problem), but that setting 'echo hi' as a post-init hook
causes a crash (so the post-init hook code must be the problem).
(The shell commands should be run sequentially, but the block with the problem
does not depend on the others.)
hg init works both for a new directory ...
HGRCPATH= hg init some_repo
... and for the current directory
mkdir other_repo && cd other_repo
HGRCPATH= hg init
cd ..
A post-status hook that echoes 'hi' works
HGRC_DIR=$(pwd)
echo '[hooks]' > hgrc--post-status-hi
echo 'post-status = echo hi' >> hgrc--post-status-hi
cd some_repo
HGRCPATH=$HGRC_DIR/hgrc--post-status-hi hg status
cd ..
*** Here is the problem: a post-init hook that echoes 'hi' does not work
HGRC_DIR=$(pwd)
echo '[hooks]' > hgrc--post-init-hi
echo 'post-init = echo hi' >> hgrc--post-init-hi
mkdir init_wont_work
cd init_wont_work
# Error occurs here
HGRCPATH=$HGRC_DIR/hgrc--post-init-hi hg init
cd ..
That fails with the following traceback:
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2]
** Mercurial Distributed SCM (version 3.6)
** Extensions loaded:
Traceback (most recent call last):
File "/home/sietse/lib/mercurial-main/hg", line 43, in <module>
mercurial.dispatch.run()
File "/home/sietse/lib/mercurial-main/mercurial/dispatch.py", line 54, in
run
sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
File "/home/sietse/lib/mercurial-main/mercurial/dispatch.py", line 116,
in dispatch
ret = _runcatch(req)
File "/home/sietse/lib/mercurial-main/mercurial/dispatch.py", line 187,
in _runcatch
return _dispatch(req)
File "/home/sietse/lib/mercurial-main/mercurial/dispatch.py", line 920,
in _dispatch
cmdpats, cmdoptions)
File "/home/sietse/lib/mercurial-main/mercurial/dispatch.py", line 682,
in runcommand
result=ret, pats=cmdpats, opts=cmdoptions)
File "/home/sietse/lib/mercurial-main/mercurial/hook.py", line 177, in
hook
res = runhooks(ui, repo, name, hooks, throw=throw, **args)
File "/home/sietse/lib/mercurial-main/mercurial/hook.py", line 221, in
runhooks
r = _exthook(ui, repo, hname, cmd, args, throw)
File "/home/sietse/lib/mercurial-main/mercurial/hook.py", line 123, in
_exthook
tr = repo.currenttransaction()
AttributeError: 'NoneType' object has no attribute 'currenttransaction'
The same error occurs on a post-clone hook.
HGRC_DIR=$(pwd)
echo '[hooks]' > hgrc--post-clone-hi
echo 'post-clone = echo hi' >> hgrc--post-clone-hi
mkdir init_wont_work
cd init_wont_work
HGRCPATH=$HGRC_DIR/hgrc--post-clone-hi hg clone some_repo
# traceback omitted
cd ..
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Mercurial-devel
mailing list