##// END OF EJS Templates
Add (pre)outgoing hooks for local clones.
Fred Wulff -
r8907:e9ef409e default
parent child Browse files
Show More
@@ -231,6 +231,7 b' def clone(ui, source, dest=None, pull=Fa'
231 231 copy = False
232 232
233 233 if copy:
234 src_repo.hook('preoutgoing', throw=True, source='clone')
234 235 hgdir = os.path.realpath(os.path.join(dest, ".hg"))
235 236 if not os.path.exists(dest):
236 237 os.mkdir(dest)
@@ -262,7 +263,7 b' def clone(ui, source, dest=None, pull=Fa'
262 263 # we need to re-init the repo after manually copying the data
263 264 # into it
264 265 dest_repo = repository(ui, dest)
265
266 src_repo.hook('outgoing', source='clone', node='0'*40)
266 267 else:
267 268 try:
268 269 dest_repo = repository(ui, dest, create=True)
@@ -107,6 +107,19 b' hg rollback'
107 107 echo 'preoutgoing.forbid = python ../printenv.py preoutgoing.forbid 1' >> ../a/.hg/hgrc
108 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 123 cat > hooktests.py <<EOF
111 124 from mercurial import util
112 125
@@ -107,6 +107,13 b' preoutgoing.forbid hook: HG_SOURCE=pull'
107 107 pulling from ../a
108 108 searching for changes
109 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 117 # test python hooks
111 118 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
112 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