Show More
@@ -0,0 +1,9 b'' | |||||
|
1 | #!/bin/sh -x | |||
|
2 | ||||
|
3 | hg init | |||
|
4 | echo "[hooks]" > .hg/hgrc | |||
|
5 | echo 'precommit = echo precommit hook' >> .hg/hgrc | |||
|
6 | echo 'commit = echo commit hook: $NODE' >> .hg/hgrc | |||
|
7 | echo a > a | |||
|
8 | hg add a | |||
|
9 | hg commit -t "test" -u test -d "0 0" |
@@ -0,0 +1,9 b'' | |||||
|
1 | + hg init | |||
|
2 | + echo '[hooks]' | |||
|
3 | + echo 'precommit = echo precommit hook' | |||
|
4 | + echo 'commit = echo commit hook: $NODE' | |||
|
5 | + echo a | |||
|
6 | + hg add a | |||
|
7 | + hg commit -t test -u test -d '0 0' | |||
|
8 | precommit hook | |||
|
9 | commit hook: acb14030fe0a21b60322c440ad2d20cf7685a376 |
@@ -328,30 +328,48 b' FILES' | |||||
328 | NAMED REPOSITORIES |
|
328 | NAMED REPOSITORIES | |
329 | ------------------ |
|
329 | ------------------ | |
330 |
|
330 | |||
331 |
|
|
331 | To give symbolic names to a repository, create a section in .hgrc | |
332 |
|
|
332 | or .hg/hgrc containing assignments of names to paths. Example: | |
333 |
|
333 | |||
334 | Example: |
|
334 | ----------------- | |
335 |
|
||||
336 | [paths] |
|
335 | [paths] | |
337 | hg = http://selenic.com/hg |
|
336 | hg = http://selenic.com/hg | |
338 | tah = http://hg.intevation.org/mercurial-tah/ |
|
337 | tah = http://hg.intevation.org/mercurial-tah/ | |
|
338 | ----------------- | |||
|
339 | ||||
|
340 | ||||
|
341 | HOOKS | |||
|
342 | ----- | |||
|
343 | ||||
|
344 | Mercurial supports a set of 'hook', commands that get automatically | |||
|
345 | executed by various actions such as starting or finishing a commit. To | |||
|
346 | specify a hook, simply create an hgrc section like the following: | |||
|
347 | ||||
|
348 | ----------------- | |||
|
349 | [hooks] | |||
|
350 | precommit = echo "this hook gets executed immediately before a commit" | |||
|
351 | commit = hg export $NODE | mail -s "new commit $NODE" commit-list | |||
|
352 | ----------------- | |||
|
353 | ||||
339 |
|
354 | |||
340 | NON_TRANSPARENT PROXY SUPPORT |
|
355 | NON_TRANSPARENT PROXY SUPPORT | |
341 | ----------------------------- |
|
356 | ----------------------------- | |
342 |
|
357 | |||
343 |
|
|
358 | To access a Mercurial repository through a proxy, create a file | |
344 |
|
|
359 | $HOME/.hgrc in the following format: | |
345 |
|
360 | |||
|
361 | -------------- | |||
346 | [http_proxy] |
|
362 | [http_proxy] | |
347 | host=myproxy:8080 |
|
363 | host=myproxy:8080 | |
348 | user=<username> |
|
364 | user=<username> | |
349 | passwd=<password> |
|
365 | passwd=<password> | |
350 | no=<localhost1>,<localhost2>,<localhost3>,... |
|
366 | no=<localhost1>,<localhost2>,<localhost3>,... | |
|
367 | -------------- | |||
351 |
|
368 | |||
352 |
|
|
369 | "user","passwd" fields are used for authenticating proxies, "no" is a | |
353 |
|
|
370 | comma-separated list of local host names for which proxy must be | |
354 | for which proxy must be bypassed. |
|
371 | bypassed. | |
|
372 | ||||
355 |
|
373 | |||
356 | BUGS |
|
374 | BUGS | |
357 | ---- |
|
375 | ---- |
@@ -371,6 +371,30 b' class localrepository:' | |||||
371 | if pat.search(f): return True |
|
371 | if pat.search(f): return True | |
372 | return False |
|
372 | return False | |
373 |
|
373 | |||
|
374 | def hook(self, name, **args): | |||
|
375 | s = self.ui.config("hooks", name) | |||
|
376 | if s: | |||
|
377 | self.ui.note("running hook %s: %s\n" % (name, s)) | |||
|
378 | old = {} | |||
|
379 | for k, v in args.items(): | |||
|
380 | k = k.upper() | |||
|
381 | old[k] = os.environ.get(k, None) | |||
|
382 | os.environ[k] = v | |||
|
383 | ||||
|
384 | r = os.system(s) | |||
|
385 | ||||
|
386 | for k, v in old.items(): | |||
|
387 | if v != None: | |||
|
388 | os.environ[k] = v | |||
|
389 | else: | |||
|
390 | del os.environ[k] | |||
|
391 | ||||
|
392 | if r: | |||
|
393 | self.ui.warn("abort: %s hook failed with status %d!\n" % | |||
|
394 | (name, r)) | |||
|
395 | return False | |||
|
396 | return True | |||
|
397 | ||||
374 | def tags(self): |
|
398 | def tags(self): | |
375 | '''return a mapping of tag to node''' |
|
399 | '''return a mapping of tag to node''' | |
376 | if not self.tagscache: |
|
400 | if not self.tagscache: | |
@@ -548,6 +572,9 b' class localrepository:' | |||||
548 | self.ui.status("nothing changed\n") |
|
572 | self.ui.status("nothing changed\n") | |
549 | return |
|
573 | return | |
550 |
|
574 | |||
|
575 | if not self.hook("precommit"): | |||
|
576 | return 1 | |||
|
577 | ||||
551 | p1, p2 = self.dirstate.parents() |
|
578 | p1, p2 = self.dirstate.parents() | |
552 | c1 = self.changelog.read(p1) |
|
579 | c1 = self.changelog.read(p1) | |
553 | c2 = self.changelog.read(p2) |
|
580 | c2 = self.changelog.read(p2) | |
@@ -603,6 +630,10 b' class localrepository:' | |||||
603 | text = edittext |
|
630 | text = edittext | |
604 |
|
631 | |||
605 | n = self.changelog.add(mn, new, text, tr, p1, p2, user, date) |
|
632 | n = self.changelog.add(mn, new, text, tr, p1, p2, user, date) | |
|
633 | ||||
|
634 | if not self.hook("commit", node=hex(n)): | |||
|
635 | return 1 | |||
|
636 | ||||
606 | tr.close() |
|
637 | tr.close() | |
607 |
|
638 | |||
608 | self.dirstate.setparents(n) |
|
639 | self.dirstate.setparents(n) |
General Comments 0
You need to be logged in to leave comments.
Login now