[PATCH] [issue1602] Make local clone activate preoutgoing and outgoing hooks

Fred Wulff frew at stanford.edu
Sat Apr 18 04:38:14 CDT 2009


Not sure whether replying makes it worse, but sorry for the spam. I thought
that I had waited long enough for smtp to filter through in debugging my
patchbomb setup but apparently not.

On Fri, Apr 17, 2009 at 5:03 PM, Fred Wulff <frew at cs.stanford.edu> wrote:

> # HG changeset patch
> # User Fred Wulff <frew at cs.stanford.edu>
> # Date 1240011283 25200
> # Node ID 1f5c062a7ab40a02b852f2cc5787384efd4eccaf
> # Parent  fc78313cba53d982b34a1516b81348a8b89bd867
> Add (pre)outgoing hooks for local clones.
>
> diff -r fc78313cba53 -r 1f5c062a7ab4 mercurial/hg.py
> --- a/mercurial/hg.py   Sat Apr 04 20:19:51 2009 -0500
> +++ b/mercurial/hg.py   Fri Apr 17 16:34:43 2009 -0700
> @@ -168,6 +168,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)
> @@ -199,7 +200,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 fc78313cba53 -r 1f5c062a7ab4 tests/test-hook
> --- a/tests/test-hook   Sat Apr 04 20:19:51 2009 -0500
> +++ 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
>
> diff -r fc78313cba53 -r 1f5c062a7ab4 tests/test-hook.out
> --- a/tests/test-hook.out       Sat Apr 04 20:19:51 2009 -0500
> +++ b/tests/test-hook.out       Fri Apr 17 16:34:43 2009 -0700
> @@ -106,6 +106,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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial-devel/attachments/20090418/f3ee9e88/attachment.htm 


More information about the Mercurial-devel mailing list