Mercurial > hg-stable
changeset 8907:e9ef409e6399
Add (pre)outgoing hooks for local clones.
author | Fred Wulff <frew@cs.stanford.edu> |
---|---|
date | Fri, 17 Apr 2009 16:34:43 -0700 |
parents | bb255fe7c27e |
children | 288ba6d6c5c7 |
files | mercurial/hg.py tests/test-hook tests/test-hook.out |
diffstat | 3 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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 <<EOF from mercurial import util
--- a/tests/test-hook.out Tue Jun 23 14:14:48 2009 +0200 +++ b/tests/test-hook.out Fri Apr 17 16:34:43 2009 -0700 @@ -107,6 +107,13 @@ pulling from ../a searching for changes abort: preoutgoing.forbid hook exited with status 1 +preoutgoing hook: HG_SOURCE=clone +outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone +updating working directory +3 files updated, 0 files merged, 0 files removed, 0 files unresolved +preoutgoing hook: HG_SOURCE=clone +preoutgoing.forbid hook: HG_SOURCE=clone +abort: preoutgoing.forbid hook exited with status 1 # test python hooks error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict' error: preoutgoing.raise hook raised an exception: exception from hook