Show More
@@ -231,6 +231,7 b' def clone(ui, source, dest=None, pull=Fa' | |||||
231 | copy = False |
|
231 | copy = False | |
232 |
|
232 | |||
233 | if copy: |
|
233 | if copy: | |
|
234 | src_repo.hook('preoutgoing', throw=True, source='clone') | |||
234 | hgdir = os.path.realpath(os.path.join(dest, ".hg")) |
|
235 | hgdir = os.path.realpath(os.path.join(dest, ".hg")) | |
235 | if not os.path.exists(dest): |
|
236 | if not os.path.exists(dest): | |
236 | os.mkdir(dest) |
|
237 | os.mkdir(dest) | |
@@ -262,7 +263,7 b' def clone(ui, source, dest=None, pull=Fa' | |||||
262 | # we need to re-init the repo after manually copying the data |
|
263 | # we need to re-init the repo after manually copying the data | |
263 | # into it |
|
264 | # into it | |
264 | dest_repo = repository(ui, dest) |
|
265 | dest_repo = repository(ui, dest) | |
265 |
|
266 | src_repo.hook('outgoing', source='clone', node='0'*40) | ||
266 | else: |
|
267 | else: | |
267 | try: |
|
268 | try: | |
268 | dest_repo = repository(ui, dest, create=True) |
|
269 | dest_repo = repository(ui, dest, create=True) |
@@ -107,6 +107,19 b' hg rollback' | |||||
107 | echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc |
|
107 | echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc | |
108 | hg pull ../a |
|
108 | hg pull ../a | |
109 |
|
109 | |||
|
110 | # outgoing hooks work for local clones | |||
|
111 | cd .. | |||
|
112 | echo '[hooks]' > a/.hg/hgrc | |||
|
113 | echo 'preoutgoing = python ../printenv.py preoutgoing' >> a/.hg/hgrc | |||
|
114 | echo 'outgoing = python ../printenv.py outgoing' >> a/.hg/hgrc | |||
|
115 | hg clone a c | |||
|
116 | rm -rf c | |||
|
117 | ||||
|
118 | # preoutgoing hook can prevent outgoing changes for local clones | |||
|
119 | echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> a/.hg/hgrc | |||
|
120 | hg clone a zzz | |||
|
121 | cd b | |||
|
122 | ||||
110 | cat > hooktests.py <<EOF |
|
123 | cat > hooktests.py <<EOF | |
111 | from mercurial import util |
|
124 | from mercurial import util | |
112 |
|
125 |
@@ -107,6 +107,13 b' preoutgoing.forbid hook: HG_SOURCE=pull' | |||||
107 | pulling from ../a |
|
107 | pulling from ../a | |
108 | searching for changes |
|
108 | searching for changes | |
109 | abort: preoutgoing.forbid hook exited with status 1 |
|
109 | abort: preoutgoing.forbid hook exited with status 1 | |
|
110 | preoutgoing hook: HG_SOURCE=clone | |||
|
111 | outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone | |||
|
112 | updating working directory | |||
|
113 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
114 | preoutgoing hook: HG_SOURCE=clone | |||
|
115 | preoutgoing.forbid hook: HG_SOURCE=clone | |||
|
116 | abort: preoutgoing.forbid hook exited with status 1 | |||
110 | # test python hooks |
|
117 | # test python hooks | |
111 | error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict' |
|
118 | error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict' | |
112 | error: preoutgoing.raise hook raised an exception: exception from hook |
|
119 | error: preoutgoing.raise hook raised an exception: exception from hook |
General Comments 0
You need to be logged in to leave comments.
Login now