logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: [issue38] only one hook of any kind possible: msg#00511

Subject: Re: [issue38] only one hook of any kind possible
# HG changeset patch
# User Benoit Boissinot <benoit.boissinot@xxxxxxxxxxxx>
# Node ID 8ae6e720f3c11bb0032cef2acba519e8a0677550
# Parent  1a3c6689ef2b46442f87debae53584bdbb1bf6b1
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

diff -r 1a3c6689ef2b -r 8ae6e720f3c1 mercurial/localrepo.py
--- a/mercurial/localrepo.py    Fri Oct 28 17:18:50 2005 -0700
+++ b/mercurial/localrepo.py    Sat Oct 29 11:02:41 2005 +0200
@@ -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 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'''


<Prev in Thread] Current Thread [Next in Thread>