Allow irkerhook to be used as a mecurial changegroup hook
authorNeil <neil@dip.sun.ac.za>
Tue, 3 Sep 2013 09:50:30 +0000 (11:50 +0200)
committerNeil <neil@dip.sun.ac.za>
Tue, 3 Sep 2013 09:50:30 +0000 (11:50 +0200)
irkerhook.py

index 4b243a20f63188e23d4c8d9850bd0b4bd704ec48..d09eb17d526f419b5023e3924cdc313694779eb1 100755 (executable)
@@ -393,12 +393,20 @@ class HgExtractor(GenericExtractor):
         return commit
 
 def hg_hook(ui, repo, **kwds):
-    # To be called from a Mercurial "commit" or "incoming" hook.  Example
-    # configuration:
+    # To be called from a Mercurial "commit", "incoming" or "changegroup" hook.
+    # Example configuration:
     # [hooks]
     # incoming.irker = python:/path/to/irkerhook.py:hg_hook
     extractor = HgExtractor([(ui, repo)])
-    ship(extractor, kwds['node'], False)
+    start = repo[kwds['node']].rev()
+    end = len(repo)
+    if start != end:
+        # changegroup with multiple commits, so we generate a notification
+        # for each one
+        for rev in range(start, end):
+            ship(extractor, rev, False)
+    else:
+        ship(extractor, kwds['node'], False)
 
 # The files we use to identify a Subversion repo might occur as content
 # in a git or hg repo, but the special subdirectories for those are more