In mercurial 3.0, getbundle was moved to the changegroup module, and
gained a new argument. Due to this we cannot simply start using
getbundle(...) imported from either one unconditionally, as that would
cause errors in mercurial 3.0 without changing the syntax, and errors in
mercurial <3.0 if we do change it.

The try:except block at the beginning of tries first to
import mercurial.changegroup.getbundle, and if that fails we set the
function 'getbundle' to work correctly with mercurial.repo.getbundle by
removing the first argument.

Signed-off-by: William Giokas <>

So, what I had in there before would not work at all on repo.getbundle
because **kwargs only unpacks keyword args, not normal args. Sometimes my
brain works. | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/ b/
index 34cda02..32eeffb 100755
--- a/
+++ b/
@@ -14,6 +14,13 @@
 from mercurial import hg, ui, bookmarks, context, encoding, node, error, 
extensions, discovery, util
+    from mercurial.changegroup import getbundle
+except ImportError:
+    def getbundle(repo, **kwargs):
+        return repo.getbundle(**kwargs)
 import re
 import sys
 import os
@@ -985,7 +992,8 @@ def push_unsafe(repo, remote, parsed_refs, p_revs):
     if not checkheads(repo, remote, p_revs):
         return None
-    cg = repo.getbundle('push', heads=list(p_revs), common=common)
+    cg = getbundle(repo=repo, source='push', heads=list(p_revs),
+                   common=common)
     unbundle = remote.capable('unbundle')
     if unbundle:

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to