[RFC/PATCH git-remote-bzr] Adapt to new semantics of remote-helper "import" command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Git 1.7.7 (commit 9504bc9d, "transport-helper: change import
semantics", 2011-07-16) incompatibly changed the interface of the
"import" capability.

Before, git would always send a single import command, which the
remote helper would respond to with a fast-import stream, terminated
by end of file, meaning there was no way to fetch multiple refs in one
connection.  Nowadays, git instead sends a sequence of import lines:

	import refs/heads/foo
	import refs/heads/bar

terminated by a blank line.  The helper is to respond with a
fast-import stream terminated by the "done" command and process
further commands until another blank line indicates the end of the
command stream.
---
Hi Simon and Gabriel,

Here's a rough patch against git://github.com/lelutin/git-remote-bzr.git
master.

Without this patch, whenever I try to use "git clone bzr::<something>",
after doing all the work it removes the resulting repo and exits with
status 141 (SIGPIPE).  Maybe the transport-helper should mask SIGPIPE
when writing the final newline to avoid that.

I'd have prefered to write a patch for remote-bzr that works with
older versions of git fast-import, too, but it wasn't obvious how.
Hints welcome.

BTW, would you mind if I sent a patch to include git-remote-bzr in
git.git under contrib/?

Thanks for git remote-bzr!  I'd be happy for any thoughts you have.

Ciao,
Jonathan

[1] http://thread.gmane.org/gmane.comp.version-control.git/176002/focus=176606

 README.rst     |    2 +-
 git-remote-bzr |   33 ++++++++++++++++++++++++++++++---
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/README.rst b/README.rst
index 3eb3e476..f4dbbeb2 100644
--- a/README.rst
+++ b/README.rst
@@ -34,7 +34,7 @@ Relevant bug reports
 Requirements
 ------------
 
-- git 1.6.6 or later
+- git 1.7.7 or later
 - python 2.5 +
 - bzr 2.x
 - bzr-fastimport
diff --git a/git-remote-bzr b/git-remote-bzr
index 1e3a05f9..501fffe3 100755
--- a/git-remote-bzr
+++ b/git-remote-bzr
@@ -49,7 +49,7 @@ def do_list(repo, args):
     print  # end list
 
 
-def do_import(repo, args):
+def import_one_ref(repo, args):
     """Import a fast-import stream that is exported from Bazaar."""
     if len(args) != 1:
         die("Import needs exactly one ref")
@@ -65,6 +65,23 @@ def do_import(repo, args):
     if bzrp.wait():
         die("'bzr fast-export' returned unexpectedly with code %d",
             bzrp.returncode)
+    print "done"
+
+
+def do_import(repo,args):
+    import_one_ref(repo, args)
+
+    cmdline = True
+    while cmdline:
+        cmdline = next_command()
+        if not cmdline:
+            # Return to main processing loop
+            return True
+        cmd = cmdline.pop(0)
+        if cmd != "import":
+            warn("Unexpected command %s during import" % cmd)
+            return False
+        import_one_ref(repo, cmdline)
 
 
 def do_push(repo, args):
@@ -123,8 +140,8 @@ def sanitize(value):
     return value
 
 
-def read_one_line(repo):
-    """Read and process one command."""
+def next_command():
+    """Read one command."""
     line = sys.stdin.readline()
 
     cmdline = line
@@ -138,6 +155,16 @@ def read_one_line(repo):
         # Blank line means we're about to quit
         return False
 
+    return cmdline
+
+
+def read_one_line(repo):
+    """Read and process one command."""
+    cmdline = next_command()
+
+    if not cmdline:
+        return False
+
     cmd = cmdline.pop(0)
     debug("Got command '%s' with args '%s'", cmd, ' '.join(cmdline))
 
-- 
1.7.9.rc2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]