changeset 1480:ae0d8d632b83

allow multiples hook suggested by Vadim Gelfer This patch allows to have multiple hooks of the same kind: for example commit.email = /my/email/hook commit.autobuild = /my/build/hook
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 29 Oct 2005 13:44:05 -0700
parents 1a3c6689ef2b
children acd1832ebf31
files mercurial/localrepo.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Fri Oct 28 17:18:50 2005 -0700
+++ b/mercurial/localrepo.py	Sat Oct 29 13:44:05 2005 -0700
@@ -47,9 +47,8 @@
         except IOError: pass
 
     def hook(self, name, **args):
-        s = self.ui.config("hooks", name)
-        if s:
-            self.ui.note(_("running hook %s: %s\n") % (name, s))
+        def runhook(name, cmd):
+            self.ui.note(_("running hook %s: %s\n") % (name, cmd))
             old = {}
             for k, v in args.items():
                 k = k.upper()
@@ -59,7 +58,7 @@
             # Hooks run in the repository root
             olddir = os.getcwd()
             os.chdir(self.root)
-            r = os.system(s)
+            r = os.system(cmd)
             os.chdir(olddir)
 
             for k, v in old.items():
@@ -72,7 +71,14 @@
                 self.ui.warn(_("abort: %s hook failed with status %d!\n") %
                              (name, r))
                 return False
-        return True
+            return True
+
+        r = True
+        for hname, cmd in self.ui.configitems("hooks"):
+            s = hname.split(".")
+            if s[0] == name and cmd:
+                r = runhook(hname, cmd) and r
+        return r
 
     def tags(self):
         '''return a mapping of tag to node'''