From: Dmitry Ivankov <divanorama@gmail.com>
To: git@vger.kernel.org
Cc: Jonathan Nieder <jrnieder@gmail.com>,
David Barr <davidbarr@google.com>,
Dmitry Ivankov <divanorama@gmail.com>
Subject: [PATCH 7/8] vcs-svn: convert REPORT_FILENO to an option
Date: Sun, 3 Jul 2011 23:57:56 +0600 [thread overview]
Message-ID: <1309715877-13814-8-git-send-email-divanorama@gmail.com> (raw)
In-Reply-To: <1309715877-13814-1-git-send-email-divanorama@gmail.com>
svn-fe needs to read fast-import's responses to "ls" and "cat-blob".
These come through a file descriptor number 3.
Sometimes it is easier to setup variable fd than a fixed one. It is
the case with pipe() call and even more fd=3 can be already taken.
On Windows file descriptors are not by default inherited by a child
process, nor there is an option to setup descriptors other than
standard stdin, stdout, stderr at a process creation time.
Add an option for this file descriptor number in vcs-svn/ and svn-fe,
add a simple test for it.
To be used like following:
$ svn-fe --read-blob-fd=7 ... 7<somewhere
Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
---
contrib/svn-fe/svn-fe.c | 5 +++-
contrib/svn-fe/svn-fe.txt | 8 ++++-
t/t9010-svn-fe.sh | 58 +++++++++++++++++++++++++++++++++++++++++---
test-svn-fe.c | 5 +++-
vcs-svn/svndump.c | 6 +---
vcs-svn/svndump.h | 2 +-
6 files changed, 71 insertions(+), 13 deletions(-)
diff --git a/contrib/svn-fe/svn-fe.c b/contrib/svn-fe/svn-fe.c
index 78c7cd0..32755b1 100644
--- a/contrib/svn-fe/svn-fe.c
+++ b/contrib/svn-fe/svn-fe.c
@@ -14,12 +14,15 @@ static const char * const svn_fe_usage[] = {
static const char *url;
static const char *ref = "refs/heads/master";
+static int backflow_fd = 3;
static struct option svn_fe_options[] = {
OPT_STRING(0, "git-svn-id-url", &url, "url",
"append git-svn metadata line to commit messages"),
OPT_STRING(0, "ref", &ref, "dst_ref",
"write to dst_ref instead of refs/heads/master"),
+ OPT_INTEGER(0, "read-blob-fd", &backflow_fd,
+ "read blobs and trees from this fd instead of 3"),
OPT_END()
};
@@ -35,7 +38,7 @@ int main(int argc, const char **argv)
url = argv[0];
} else if (argc)
usage_with_options(svn_fe_usage, svn_fe_options);
- if (svndump_init(NULL, url, ref))
+ if (svndump_init(NULL, url, ref, backflow_fd))
return 1;
svndump_read();
svndump_deinit();
diff --git a/contrib/svn-fe/svn-fe.txt b/contrib/svn-fe/svn-fe.txt
index 20c3315..a7ad368 100644
--- a/contrib/svn-fe/svn-fe.txt
+++ b/contrib/svn-fe/svn-fe.txt
@@ -8,9 +8,9 @@ svn-fe - convert an SVN "dumpfile" to a fast-import stream
SYNOPSIS
--------
[verse]
-mkfifo backchannel &&
+mkfifo backchannel && fd=3 &&
svnadmin dump --deltas REPO |
- svn-fe [options] [git-svn-id-url] 3<backchannel |
+ eval "svn-fe [options] [git-svn-id-url] $fd<backchannel" |
git fast-import --cat-blob-fd=3 3>backchannel
DESCRIPTION
@@ -35,6 +35,10 @@ OPTIONS
--ref=<dst_ref>::
Ref to be written by the generated stream.
Default is refs/heads/master.
+--read-blob-fd=<fd>::
+ Integer number of file descriptor from which
+ responses to 'ls' and 'cat-blob' requests will come.
+ Default is fd=3.
INPUT FORMAT
------------
diff --git a/t/t9010-svn-fe.sh b/t/t9010-svn-fe.sh
index 52efabe..6dcad94 100755
--- a/t/t9010-svn-fe.sh
+++ b/t/t9010-svn-fe.sh
@@ -18,20 +18,21 @@ reinit_git () {
try_dump_ext () {
args=$1 &&
- shift &&
+ fd=${2:-3} &&
+ shift 2 &&
input=$1 &&
maybe_fail_svnfe=${2:+test_$2} &&
maybe_fail_fi=${3:+test_$3} &&
{
- $maybe_fail_svnfe test-svn-fe $args "$input" >stream 3<backflow &
+ eval "$maybe_fail_svnfe test-svn-fe $args "$input" >stream $fd<backflow" &
} &&
$maybe_fail_fi git fast-import --cat-blob-fd=3 <stream 3>backflow &&
wait $!
}
try_dump () {
- try_dump_ext "" $@
+ try_dump_ext "" "" $@
}
properties () {
@@ -1120,10 +1121,59 @@ test_expect_success SVNREPO,PIPE 't9135/svn.dump' '
test_expect_success PIPE 'import to notmaster ref' '
reinit_git &&
- try_dump_ext "--ref=refs/heads/notmaster" emptyprop.dump &&
+ try_dump_ext "--ref=refs/heads/notmaster" 3 emptyprop.dump &&
git rev-parse --verify notmaster &&
test_must_fail git rev-parse --verify master
'
+test_expect_success PIPE 'use different backflow fd' '
+ reinit_git &&
+ echo hi >hi &&
+ {
+ properties \
+ svn:author author@example.com \
+ svn:date "1999-02-01T00:01:002.000000Z" \
+ svn:log "add directory with some files in it" &&
+ echo PROPS-END
+ } >props &&
+ {
+ echo Prop-content-length: $(wc -c <props) &&
+ echo Content-length: $(wc -c <props) &&
+ echo &&
+ cat props
+ } >revprops &&
+ {
+ cat <<-EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ EOF
+ cat revprops &&
+ cat <<-EOF &&
+ Node-path: directory
+ Node-kind: dir
+ Node-action: add
+ Node-path: directory/somefile
+ Node-kind: file
+ Node-action: add
+ EOF
+ text_no_props hi &&
+
+ echo "Revision-number: 2" &&
+ cat revprops &&
+ cat <<-\EOF
+ Node-path: otherfile
+ Node-kind: file
+ Node-action: add
+ Node-copyfrom-rev: 1
+ Node-copyfrom-path: directory/somefile
+ EOF
+ } >directory.dump &&
+ try_dump_ext "--read-blob-fd=7" 7 directory.dump &&
+
+ git checkout HEAD otherfile &&
+ test_cmp hi otherfile
+'
+
test_done
diff --git a/test-svn-fe.c b/test-svn-fe.c
index afa551c..7885eb1 100644
--- a/test-svn-fe.c
+++ b/test-svn-fe.c
@@ -16,11 +16,14 @@ static const char * const test_svnfe_usage[] = {
static const char *ref = "refs/heads/master";
static int d;
+static int backflow_fd = 3;
static struct option test_svnfe_options[] = {
OPT_SET_INT('d', NULL, &d, "test apply_delta", 1),
OPT_STRING(0, "ref", &ref, "dst_ref",
"write to dst_ref instead of refs/heads/master"),
+ OPT_INTEGER(0, "read-blob-fd", &backflow_fd,
+ "read blobs and trees from this fd instead of 3"),
OPT_END()
};
@@ -59,7 +62,7 @@ int main(int argc, const char *argv[])
return apply_delta(argc, argv);
if (argc == 1) {
- if (svndump_init(argv[0], NULL, ref))
+ if (svndump_init(argv[0], NULL, ref, backflow_fd))
return 1;
svndump_read();
svndump_deinit();
diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c
index f0df381..c52faf1 100644
--- a/vcs-svn/svndump.c
+++ b/vcs-svn/svndump.c
@@ -19,8 +19,6 @@
*/
#define constcmp(s, ref) memcmp(s, ref, sizeof(ref) - 1)
-#define REPORT_FILENO 3
-
#define NODEACT_REPLACE 4
#define NODEACT_DELETE 3
#define NODEACT_ADD 2
@@ -454,11 +452,11 @@ void svndump_read(void)
end_revision();
}
-int svndump_init(const char *filename, const char *url, const char *dst_ref)
+int svndump_init(const char *filename, const char *url, const char *dst_ref, int report_fileno)
{
if (buffer_init(&input, filename))
return error("cannot open %s: %s", filename, strerror(errno));
- fast_export_init(REPORT_FILENO, dst_ref);
+ fast_export_init(report_fileno, dst_ref);
strbuf_init(&dump_ctx.uuid, 4096);
strbuf_init(&dump_ctx.url, 4096);
strbuf_init(&rev_ctx.log, 4096);
diff --git a/vcs-svn/svndump.h b/vcs-svn/svndump.h
index 08922fb..85c82c5 100644
--- a/vcs-svn/svndump.h
+++ b/vcs-svn/svndump.h
@@ -1,7 +1,7 @@
#ifndef SVNDUMP_H_
#define SVNDUMP_H_
-int svndump_init(const char *filename, const char *url, const char *dst_ref);
+int svndump_init(const char *filename, const char *url, const char *dst_ref, int report_fileno);
void svndump_read(void);
void svndump_deinit(void);
void svndump_reset(void);
--
1.7.3.4
next prev parent reply other threads:[~2011-07-03 17:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-03 17:57 [PATCH 0/8] vcs-svn, svn-fe: add a couple of options Dmitry Ivankov
2011-07-03 17:57 ` [PATCH 1/8] vcs-svn: move url parameter from _read to _init Dmitry Ivankov
2011-07-03 17:57 ` [PATCH 2/8] svn-fe: add man target to Makefile Dmitry Ivankov
2011-07-03 17:57 ` [PATCH 3/8] svn-fe: add EXTLIBS needed for parse-options Dmitry Ivankov
2011-07-03 17:57 ` [PATCH 4/8] svn-fe: add usage and unpositional arguments versions Dmitry Ivankov
2011-07-03 17:57 ` [PATCH 5/8] test-svn-fe: use parse-options Dmitry Ivankov
2011-07-03 17:57 ` [PATCH 6/8] vcs-svn: allow to specify dump destination ref Dmitry Ivankov
2011-07-03 17:57 ` Dmitry Ivankov [this message]
2011-07-06 10:09 ` [PATCH 7/8] vcs-svn: convert REPORT_FILENO to an option Ramkumar Ramachandra
2011-07-03 17:57 ` [PATCH 8/8] vcs-svn: allow to disable 'progress' lines Dmitry Ivankov
2011-07-06 8:25 ` Ramkumar Ramachandra
2011-07-06 10:14 ` Dmitry Ivankov
2011-07-06 11:40 ` Ramkumar Ramachandra
2011-07-04 11:06 ` [PATCH 0/8] vcs-svn, svn-fe: add a couple of options Sverre Rabbelier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1309715877-13814-8-git-send-email-divanorama@gmail.com \
--to=divanorama@gmail.com \
--cc=davidbarr@google.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@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.
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).