From: Jonathan Nieder <jrnieder@gmail.com>
To: Gabriel Filion <lelutin@gmail.com>
Cc: git@vger.kernel.org, Simon Poirier <spoirier@rlnx.com>,
Sverre Rabbelier <srabbelier@gmail.com>,
Jeff King <peff@peff.net>, David Barr <davidbarr@google.com>,
Dmitry Ivankov <divanorama@gmail.com>
Subject: [RFC/PATCH git-remote-bzr] Adapt to new semantics of remote-helper "import" command
Date: Sat, 21 Jan 2012 23:46:57 -0600 [thread overview]
Message-ID: <20120122054657.GA25103@burratino> (raw)
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
next reply other threads:[~2012-01-22 5:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-22 5:46 Jonathan Nieder [this message]
2012-01-22 23:35 ` [RFC/PATCH git-remote-bzr] Adapt to new semantics of remote-helper "import" command Jelmer Vernooij
2012-01-23 0:12 ` Jonathan Nieder
2012-02-03 9:43 ` Gabriel Filion
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120122054657.GA25103@burratino \
--to=jrnieder@gmail.com \
--cc=davidbarr@google.com \
--cc=divanorama@gmail.com \
--cc=git@vger.kernel.org \
--cc=lelutin@gmail.com \
--cc=peff@peff.net \
--cc=spoirier@rlnx.com \
--cc=srabbelier@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).