# HG changeset patch # User mpm@selenic.com # Date 2005-09-22 17:12:42 # Node ID b650bfdfc7ee1e2d3d596d9de8cbc5bfca30b832 # Parent 32f6cae83db75e0d1d30e3b562d0615245db3354 Hook fixups Pass the first new changeset node to the changegroup hook Call commit for each changeset in a pull changegroup Improve hook docs diff --git a/doc/hgrc.5.txt b/doc/hgrc.5.txt --- a/doc/hgrc.5.txt +++ b/doc/hgrc.5.txt @@ -122,10 +122,12 @@ hooks:: 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. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -987,7 +987,8 @@ class localrepository: 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 @@ class localrepository: 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,