diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -231,6 +231,7 @@ def clone(ui, source, dest=None, pull=Fa copy = False if copy: + src_repo.hook('preoutgoing', throw=True, source='clone') hgdir = os.path.realpath(os.path.join(dest, ".hg")) if not os.path.exists(dest): os.mkdir(dest) @@ -262,7 +263,7 @@ def clone(ui, source, dest=None, pull=Fa # we need to re-init the repo after manually copying the data # into it dest_repo = repository(ui, dest) - + src_repo.hook('outgoing', source='clone', node='0'*40) else: try: dest_repo = repository(ui, dest, create=True) diff --git a/tests/test-hook b/tests/test-hook --- a/tests/test-hook +++ b/tests/test-hook @@ -107,6 +107,19 @@ hg rollback echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc hg pull ../a +# outgoing hooks work for local clones +cd .. +echo '[hooks]' > a/.hg/hgrc +echo 'preoutgoing = python ../printenv.py preoutgoing' >> a/.hg/hgrc +echo 'outgoing = python ../printenv.py outgoing' >> a/.hg/hgrc +hg clone a c +rm -rf c + +# preoutgoing hook can prevent outgoing changes for local clones +echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> a/.hg/hgrc +hg clone a zzz +cd b + cat > hooktests.py <