changeset 1316:b650bfdfc7ee

Hook fixups Pass the first new changeset node to the changegroup hook Call commit for each changeset in a pull changegroup Improve hook docs
author mpm@selenic.com
date Thu, 22 Sep 2005 10:12:42 -0700
parents 32f6cae83db7
children 008d3666bf41
files doc/hgrc.5.txt mercurial/localrepo.py
diffstat 2 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/doc/hgrc.5.txt	Thu Sep 22 09:47:27 2005 -0700
+++ b/doc/hgrc.5.txt	Thu Sep 22 10:12:42 2005 -0700
@@ -122,10 +122,12 @@
   Commands that get automatically executed by various actions such as
   starting or finishing a commit.
   changegroup;;
-    Run after a changegroup has been added via push or pull.
+    Run after a changegroup has been added via push or pull. Passed
+    the ID of the first new changeset in $NODE.
   commit;;
-    Run after a changeset has been created. Passed the ID of the newly
-    created changeset.
+    Run after a changeset has been created or for each changeset
+    pulled. Passed the ID of the newly created changeset in
+    environment variable $NODE.
   precommit;;
     Run before starting a commit.  Exit status 0 allows the commit to
     proceed.  Non-zero status will cause the commit to fail.
--- a/mercurial/localrepo.py	Thu Sep 22 09:47:27 2005 -0700
+++ b/mercurial/localrepo.py	Thu Sep 22 10:12:42 2005 -0700
@@ -987,7 +987,8 @@
         self.ui.status("adding changesets\n")
         co = self.changelog.tip()
         cn = self.changelog.addgroup(getgroup(), csmap, tr, 1) # unique
-        changesets = self.changelog.rev(cn) - self.changelog.rev(co)
+        cnr, cor = map(self.changelog.rev, (cn, co))
+        changesets = cnr - cor
 
         # pull off the manifest group
         self.ui.status("adding manifests\n")
@@ -1017,9 +1018,13 @@
 
         tr.close()
 
-        if not self.hook("changegroup"):
+        if not self.hook("changegroup", node=hex(self.changelog.node(cor+1))):
+            self.ui.warn("abort: changegroup hook returned failure!\n")
             return 1
 
+        for i in range(cor + 1, cnr + 1):
+            self.hook("commit", node=hex(self.changelog.node(i)))
+
         return
 
     def update(self, node, allow=False, force=False, choose=None,