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
--- 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'''