git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remote-hg: getbundle changed in mercurial 3.0
@ 2014-05-13 19:12 William Giokas
  2014-05-13 20:21 ` [PATCH v2] " William Giokas
  2014-05-13 20:33 ` [PATCH] " Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: William Giokas @ 2014-05-13 19:12 UTC (permalink / raw)
  To: git; +Cc: William Giokas

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 git-remote-hg.py 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 <1007380@gmail.com>
---

I have tested this briefly with mercurial 3.0, but have not yet really run
through its paces. The tests that are included in next do pass with
mercurial 3.0.

 git-remote-hg.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/git-remote-hg.py b/git-remote-hg.py
index 34cda02..3dc9e11 100755
--- a/git-remote-hg.py
+++ b/git-remote-hg.py
@@ -14,6 +14,13 @@
 
 from mercurial import hg, ui, bookmarks, context, encoding, node, error, extensions, discovery, util
 
+try:
+    from mercurial.changegroup import getbundle
+
+except ImportError:
+    def getbundle(__empty__, **kwargs):
+        return repo.getbundle(**kwargs)
+
 import re
 import sys
 import os
@@ -985,7 +992,7 @@ 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, 'push', heads=list(p_revs), common=common)
 
     unbundle = remote.capable('unbundle')
     if unbundle:
-- 
2.0.0.rc3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-05-13 21:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-13 19:12 [PATCH] remote-hg: getbundle changed in mercurial 3.0 William Giokas
2014-05-13 20:21 ` [PATCH v2] " William Giokas
2014-05-13 21:00   ` Junio C Hamano
2014-05-13 20:33 ` [PATCH] " Junio C Hamano
2014-05-13 20:59   ` Felipe Contreras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).