changeset 495:e94cebc60d96

Pull from TAH -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Pull from TAH manifest hash: 08b55e07198b8a4272753895fe3727d9f52ebb75 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCwO5YywK+sNU5EO8RArUtAJ9gsYYNbZH22COOz9B7ppwgCDxM8ACfYWcl n9Dim3Z7qepGUXvRDEeFZ9c= =JMQx -----END PGP SIGNATURE-----
author mpm@selenic.com
date Mon, 27 Jun 2005 22:29:44 -0800
parents a636f7d2cd5b (diff) 6020bde714e4 (current diff)
children 6ce95a04999d
files TODO doc/hg.1.txt mercurial/bdiff.c mercurial/commands.py mercurial/hg.py mercurial/mpatch.c tests/run-tests tests/test-bad-pull tests/test-flags tests/test-flags.out tests/test-pull tests/test-rawcommit1.out tests/test-tags.out tests/test-up-local-change.out
diffstat 8 files changed, 94 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/doc/hg.1.txt	Tue Jun 28 07:05:55 2005 +0100
+++ b/doc/hg.1.txt	Mon Jun 27 22:29:44 2005 -0800
@@ -328,30 +328,48 @@
 NAMED REPOSITORIES
 ------------------
 
-    To give symbolic names to a repository, create a section in .hgrc
-    or .hg/hgrc containing assignments of names to paths.
+To give symbolic names to a repository, create a section in .hgrc
+or .hg/hgrc containing assignments of names to paths. Example:
 
-    Example:
-
+-----------------
 [paths]
 hg = http://selenic.com/hg
 tah = http://hg.intevation.org/mercurial-tah/
+-----------------
+
+
+HOOKS
+-----
+
+Mercurial supports a set of 'hook', commands that get automatically
+executed by various actions such as starting or finishing a commit. To
+specify a hook, simply create an hgrc section like the following:
+
+-----------------
+[hooks]
+precommit = echo "this hook gets executed immediately before a commit"
+commit = hg export $NODE | mail -s "new commit $NODE" commit-list
+-----------------
+
 
 NON_TRANSPARENT PROXY SUPPORT
 -----------------------------
 
-    To access a Mercurial repository through a proxy,
-    create a file $HOME/.hgrc in the following format:
+To access a Mercurial repository through a proxy, create a file
+$HOME/.hgrc in the following format:
 
+--------------
 [http_proxy]
 host=myproxy:8080
 user=<username>
 passwd=<password>
 no=<localhost1>,<localhost2>,<localhost3>,...
+--------------
 
-    "user","passwd" fields are used for authenticating proxies,
-    "no" is a comma-separated list of local host names
-    for which proxy must be bypassed.
+"user","passwd" fields are used for authenticating proxies, "no" is a
+comma-separated list of local host names for which proxy must be
+bypassed.
+
 
 BUGS
 ----
--- a/mercurial/bdiff.c	Tue Jun 28 07:05:55 2005 +0100
+++ b/mercurial/bdiff.c	Mon Jun 27 22:29:44 2005 -0800
@@ -12,7 +12,6 @@
 #include <Python.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdint.h>
 #ifdef _WIN32
 static uint32_t htonl(uint32_t x)
 {
--- a/mercurial/hg.py	Tue Jun 28 07:05:55 2005 +0100
+++ b/mercurial/hg.py	Mon Jun 27 22:29:44 2005 -0800
@@ -371,6 +371,30 @@
             if pat.search(f): return True
         return False
 
+    def hook(self, name, **args):
+        s = self.ui.config("hooks", name)
+        if s:
+            self.ui.note("running hook %s: %s\n" % (name, s))
+            old = {}
+            for k, v in args.items():
+                k = k.upper()
+                old[k] = os.environ.get(k, None)
+                os.environ[k] = v
+
+            r = os.system(s)
+
+            for k, v in old.items():
+                if v != None:
+                    os.environ[k] = v
+                else:
+                    del os.environ[k]
+
+            if r:
+                self.ui.warn("abort: %s hook failed with status %d!\n" %
+                             (name, r))
+                return False
+        return True
+
     def tags(self):
         '''return a mapping of tag to node'''
         if not self.tagscache:
@@ -548,6 +572,9 @@
             self.ui.status("nothing changed\n")
             return
 
+        if not self.hook("precommit"):
+            return 1
+
         p1, p2 = self.dirstate.parents()
         c1 = self.changelog.read(p1)
         c2 = self.changelog.read(p2)
@@ -603,6 +630,10 @@
             text = edittext
 
         n = self.changelog.add(mn, new, text, tr, p1, p2, user, date)
+
+        if not self.hook("commit", node=hex(n)):
+            return 1
+
         tr.close()
 
         self.dirstate.setparents(n)
--- a/mercurial/mpatch.c	Tue Jun 28 07:05:55 2005 +0100
+++ b/mercurial/mpatch.c	Mon Jun 27 22:29:44 2005 -0800
@@ -23,7 +23,6 @@
 #include <Python.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdint.h>
 #ifdef _WIN32
 static uint32_t ntohl(uint32_t x)
 {
--- a/tests/run-tests	Tue Jun 28 07:05:55 2005 +0100
+++ b/tests/run-tests	Mon Jun 27 22:29:44 2005 -0800
@@ -2,6 +2,23 @@
 
 set -e
 
+export LANG=C
+export LC_CTYPE="C"
+export LC_NUMERIC="C"
+export LC_TIME="C"
+export LC_COLLATE="C"
+export LC_MONETARY="C"
+export LC_MESSAGES="C"
+export LC_PAPER="C"
+export LC_NAME="C"
+export LC_ADDRESS="C"
+export LC_TELEPHONE="C"
+export LC_MEASUREMENT="C"
+export LC_IDENTIFICATION="C"
+export LC_ALL=""
+
+umask 022
+
 tests=0
 failed=0
 H=$PWD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-hook	Mon Jun 27 22:29:44 2005 -0800
@@ -0,0 +1,9 @@
+#!/bin/sh -x
+
+hg init
+echo "[hooks]" > .hg/hgrc
+echo 'precommit = echo precommit hook' >> .hg/hgrc
+echo 'commit = echo commit hook: $NODE' >> .hg/hgrc
+echo a > a
+hg add a
+hg commit -t "test" -u test -d "0 0"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-hook.out	Mon Jun 27 22:29:44 2005 -0800
@@ -0,0 +1,9 @@
++ hg init
++ echo '[hooks]'
++ echo 'precommit = echo precommit hook'
++ echo 'commit = echo commit hook: $NODE'
++ echo a
++ hg add a
++ hg commit -t test -u test -d '0 0'
+precommit hook
+commit hook: acb14030fe0a21b60322c440ad2d20cf7685a376
--- a/tests/test-tags.out	Tue Jun 28 07:05:55 2005 +0100
+++ b/tests/test-tags.out	Mon Jun 27 22:29:44 2005 -0800
@@ -43,5 +43,5 @@
 + hg id
 c8edf04160c7+b9154636be93+ tip
 + hg status
+C a
 C .hgtags
-C a