Commits

Brodie Rao committed 22bce08

gimport: fire precommit and commit hooks

  • Participants
  • Parent commits ed4cbf8
  • Branches hotfix/fire-commit-hooks

Comments (0)

Files changed (1)

File hggit/git_handler.py

 
         gparents = map(self.map_hg_get, commit.parents)
         p1, p2 = (nullid, nullid)
+        hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
         octopus = False
 
         if len(gparents) > 1:
                 ctx = context.memctx(self.repo, (p1, p2), text,
                                      list(files) + findconvergedfiles(p1, p2),
                                      getfilectx, author, date, {'hg-git': 'octopus'})
-                return hex(self.repo.commitctx(ctx))
+                hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
+                self.repo.hook('precommit', throw=True, parent1=hookp1,
+                               parent2=hookp2)
+                ret = hex(self.repo.commitctx(ctx))
+                self.repo.hook('commit', node=ret, parent1=hookp1,
+                               parent2=hookp2)
+                return ret
 
             octopus = len(gparents) > 2
             p2 = gparents.pop()
                              list(files) + findconvergedfiles(p1, p2),
                              getfilectx, author, date, extra)
 
+        self.repo.hook('precommit', throw=True, parent1=hookp1, parent2=hookp2)
         node = self.repo.commitctx(ctx)
+        self.repo.hook('commit', node=hex(node), parent1=hookp1, parent2=hookp2)
 
         self.swap_out_encoding(oldenc)