# HG changeset patch # User Fred Wulff # Date 1240011283 25200 # Node ID e9ef409e63992b047964619fb585731b9c48f5ad # Parent bb255fe7c27eed4ad421df27c676e3cc41470ff4 Add (pre)outgoing hooks for local clones. diff -r bb255fe7c27e -r e9ef409e6399 mercurial/hg.py --- a/mercurial/hg.py Tue Jun 23 14:14:48 2009 +0200 +++ b/mercurial/hg.py Fri Apr 17 16:34:43 2009 -0700 @@ -231,6 +231,7 @@ 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 @@ # 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 -r bb255fe7c27e -r e9ef409e6399 tests/test-hook --- a/tests/test-hook Tue Jun 23 14:14:48 2009 +0200 +++ b/tests/test-hook Fri Apr 17 16:34:43 2009 -0700 @@ -107,6 +107,19 @@ 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 <