vcs-svn, svn-fe: add a couple of options
cover vcs-svn, svn-fe: add a couple of options
This patch set adds a few options for svn-fe that can be used in a svn remote helper and useful in general for vcs-svn/. The last three patches add the options, others prepare the ground for them.
The patch base is svn-fe branch at git://repo.or.cz/git/jrn.git
Dmitry Ivankov (8):
vcs-svn: move url parameter from _read to _init
svn-fe: add man target to Makefile
svn-fe: add EXTLIBS needed for parse-options
svn-fe: add usage and unpositional arguments versions
test-svn-fe: use parse-options
vcs-svn: allow to specify dump destination ref
vcs-svn: convert REPORT_FILENO to an option
vcs-svn: allow to disable 'progress' lines
contrib/svn-fe/Makefile | 18 ++++---- contrib/svn-fe/svn-fe.c | 42 +++++++++++++++++-- contrib/svn-fe/svn-fe.txt | 29 +++++++++++-- t/t9010-svn-fe.sh | 99 +++++++++++++++++++++++++++++++++++++-------- test-svn-fe.c | 50 ++++++++++++++++------- vcs-svn/fast_export.c | 13 +++++- vcs-svn/fast_export.h | 2 +- vcs-svn/svndump.c | 11 ++--- vcs-svn/svndump.h | 4 +- 9 files changed, 205 insertions(+), 63 deletions(-)
Signature · 1 line
1.7.3.4
PATCH 1/8 vcs-svn: move url parameter from _read to _init
svndump_read takes a url parameter that is used in git-svn-id: lines generation. Internally it is stored in dump_ctx which is initialized in svndump_init with reset_dump_ctx and then is reinitialized again in svndump_read.
Move url parameter to svndump_init so that reset_dump_ctx is done once per dump and in the same place as other resets. More parameters will arise and all will go to svndump_init to setup the module for dumping.
--- contrib/svn-fe/svn-fe.c | 4 ++-- test-svn-fe.c | 4 ++-- vcs-svn/svndump.c | 7 +++---- vcs-svn/svndump.h | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-)
contrib/svn-fe/svn-fe.c +2 -2
@@ -8,9 +8,9 @@int main (int argc,char **argv) { -if (svndump_init (NULL )) +if (svndump_init (NULL , (argc >1 ) ? argv[1 ] :NULL ))return 1 ; -svndump_read ((argc >1 ) ? argv[1 ] :NULL ); +svndump_read ();svndump_deinit ();svndump_reset ();return 0 ;
test-svn-fe.c +2 -2
@@ -40,9 +40,9 @@ static int apply_delta(int argc, char *argv[])int main (int argc,char *argv[]) {if (argc ==2 ) { -if (svndump_init (argv[1 ])) +if (svndump_init (argv[1 ],NULL ))return 1 ; -svndump_read (NULL ); +svndump_read ();svndump_deinit ();svndump_reset ();return 0 ;
vcs-svn/svndump.c +3 -4
@@ -313,14 +313,13 @@ static void end_revision(void)fast_export_end_commit (rev_ctx.revision); } -void svndump_read (const char *url) +void svndump_read (void ) {char *val;char *t;uint32_t active_ctx =DUMP_CTX ;uint32_t len; -reset_dump_ctx (url);while ((t =buffer_read_line (&input))) { val =strchr (t,':' );if (!val)
@@ -455,7 +454,7 @@ void svndump_read(const char *url)end_revision (); } -int svndump_init (const char *filename) +int svndump_init (const char *filename,const char *url) {if (buffer_init (&input, filename))return error ("cannot open %s: %s" , filename,strerror (errno));
@@ -466,7 +465,7 @@ int svndump_init(const char *filename)strbuf_init (&rev_ctx.author,4096 );strbuf_init (&node_ctx.src,4096 );strbuf_init (&node_ctx.dst,4096 ); -reset_dump_ctx (NULL ); +reset_dump_ctx (url);reset_rev_ctx (0 );reset_node_ctx (NULL );return 0 ;
vcs-svn/svndump.h +2 -2
@@ -1,8 +1,8 @@#ifndef SVNDUMP_H_ #define SVNDUMP_H_ -int svndump_init (const char *filename); -void svndump_read (const char *url); +int svndump_init (const char *filename,const char *url); +void svndump_read (void );void svndump_deinit (void );void svndump_reset (void );
Signature · 1 line
1.7.3.4
PATCH 2/8 svn-fe: add man target to Makefile
In reply to Dmitry IvankovThere already is a svn-fe.1 target. But 'man' being a standard target is easier to discover or type. It can also be reused if more manpages arise here.
--- contrib/svn-fe/Makefile | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
contrib/svn-fe/Makefile +3 -1
@@ -33,6 +33,8 @@ ifndef V endif endif +man: svn-fe.1 + svn-fe$X: svn-fe.o $(VCSSVN_LIB) $(GIT_LIB) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ svn-fe.o \ $(ALL_LDFLAGS) $(LIBS)
@@ -60,4 +62,4 @@ svn-fe.1: svn-fe.txt clean: $(RM) svn-fe$X svn-fe.o svn-fe.html svn-fe.xml svn-fe.1 -.PHONY: all clean FORCE +.PHONY: all man clean FORCE
Signature · 1 line
1.7.3.4
PATCH 3/8 svn-fe: add EXTLIBS needed for parse-options
In reply to Dmitry IvankovCurrently parse-options.o pull quite a big bunch of dependencies that are neither pulled in by svn-fe Makefile nor included in libgit.a.
Use a temporary hack: put hardcoded EXTLIBS, this may not work in all setups because /Makefile logic is not repeated.
For example, one may need -lcrypto instead of -lssl or no crypto library if BLK_SHA1 is set, also an additional -lz or -lpcre could be required.
--- contrib/svn-fe/Makefile | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
contrib/svn-fe/Makefile +5 -7
@@ -8,11 +8,12 @@ CFLAGS = -g -O2 -Wall LDFLAGS = ALL_CFLAGS = $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS) -EXTLIBS = +EXTLIBS = -lssl -lpthread GIT_LIB = ../../libgit.a VCSSVN_LIB = ../../vcs-svn/lib.a -LIBS = $(VCSSVN_LIB) $(GIT_LIB) $(EXTLIBS) +XDIFF_LIB = ../../xdiff/lib.a +LIBS = $(VCSSVN_LIB) $(GIT_LIB) $(XDIFF_LIB) $(EXTLIBS) QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir QUIET_SUBDIR1 =
@@ -53,11 +54,8 @@ svn-fe.1: svn-fe.txt ../contrib/svn-fe/$@ $(MV) ../../Documentation/svn-fe.1 . -../../vcs-svn/lib.a: FORCE - $(QUIET_SUBDIR0)../.. $(QUIET_SUBDIR1) vcs-svn/lib.a - -../../libgit.a: FORCE - $(QUIET_SUBDIR0)../.. $(QUIET_SUBDIR1) libgit.a +$(VCSSVN_LIB) $(GIT_LIB) $(XDIFF_LIB): ../../%.a: FORCE + $(QUIET_SUBDIR0)../.. $(QUIET_SUBDIR1) $*.a clean: $(RM) svn-fe$X svn-fe.o svn-fe.html svn-fe.xml svn-fe.1
Signature · 1 line
1.7.3.4
PATCH 4/8 svn-fe: add usage and unpositional arguments versions
In reply to Dmitry IvankovThere will be more command line options for svn-fe so support unpositional version for flexibility. Also clarify the meaning of url parameter.
$ svn-fe --git-svn-id-url=url does the same thing as $ svn-fe url i.e., url is used to generate git-svn-id: lines, if url is set.
--- contrib/svn-fe/Makefile | 2 +- contrib/svn-fe/svn-fe.c | 30 +++++++++++++++++++++++++++--- contrib/svn-fe/svn-fe.txt | 17 +++++++++++++---- 3 files changed, 41 insertions(+), 8 deletions(-)
contrib/svn-fe/Makefile +1 -1
@@ -41,7 +41,7 @@ svn-fe$X: svn-fe.o $(VCSSVN_LIB) $(GIT_LIB) $(ALL_LDFLAGS) $(LIBS) svn-fe.o: svn-fe.c ../../vcs-svn/svndump.h - $(QUIET_CC)$(CC) -I../../vcs-svn -o $*.o -c $(ALL_CFLAGS) $< + $(QUIET_CC)$(CC) -I../../vcs-svn -I../.. -o $*.o -c $(ALL_CFLAGS) $< svn-fe.html: svn-fe.txt $(QUIET_SUBDIR0)../../Documentation $(QUIET_SUBDIR1) \
contrib/svn-fe/svn-fe.c +27 -3
@@ -3,12 +3,36 @@* You may freely use, modify, distribute, and relicense it. */ -#include <stdlib.h> +#include "git-compat-util.h" +#include "parse-options.h" #include "svndump.h" -int main (int argc,char **argv) +static const char *const svn_fe_usage[] = { +"svn-fe [options] [git-svn-id-url] < dump | fast-import-backend" , +NULL +}; + +static const char *url; + +static struct option svn_fe_options[] = { +OPT_STRING (0 ,"git-svn-id-url" , &url,"url" , +"append git-svn metadata line to commit messages" ), +OPT_END () +}; + +int main (int argc,const char **argv) { -if (svndump_init (NULL , (argc >1 ) ? argv[1 ] :NULL )) + argc =parse_options (argc, argv,NULL , svn_fe_options, + svn_fe_usage,0 ); +if (argc ==1 ) { +if (url) +usage_msg_opt ("git-svn-id-url is set twice: as a " +"--parameter and as a [parameter]" , + svn_fe_usage, svn_fe_options); + url = argv[0 ]; + }else if (argc) +usage_with_options (svn_fe_usage, svn_fe_options); +if (svndump_init (NULL , url))return 1 ;svndump_read ();svndump_deinit ();
contrib/svn-fe/svn-fe.txt +13 -4
@@ -10,7 +10,7 @@ SYNOPSIS [verse] mkfifo backchannel && svnadmin dump --deltas REPO | - svn-fe [url] 3<backchannel | + svn-fe [options] [git-svn-id-url] 3<backchannel | git fast-import --cat-blob-fd=3 3>backchannel DESCRIPTION
@@ -25,6 +25,14 @@ command. Note: this tool is very young. The details of its commandline interface may change in backward incompatible ways. +OPTIONS +------- + +--git-svn-id-url=<url>:: + Url to be used in git-svn-id: lines in git-svn + metadata lines format. See NOTES for more detailed + description. + INPUT FORMAT ------------ Subversion's repository dump format is documented in full in
@@ -50,9 +58,10 @@ user <user@UUID> as committer, where 'user' is the value of the `svn:author` property and 'UUID' the repository's identifier. -To support incremental imports, 'svn-fe' puts a `git-svn-id` line at -the end of each commit log message if passed an url on the command -line. This line has the form `git-svn-id: URL@REVNO UUID`. +'svn-fe' can be used in preparing a repository for 'git-svn' as follows. +If `git-svn-id-url` is specified, 'svn-fe' will put `git-svn-id` line at +the end of each commit log message. +This line has the form `git-svn-id: URL@REVNO UUID`. The resulting repository will generally require further processing to put each project in its own repository and to separate the history
Signature · 1 line
1.7.3.4
PATCH 5/8 test-svn-fe: use parse-options
In reply to Dmitry IvankovThere was custom options parsing. As more options arise it will be easier to add and document new options with parse-options api.
--- test-svn-fe.c | 42 ++++++++++++++++++++++++++++-------------- 1 files changed, 28 insertions(+), 14 deletions(-)
test-svn-fe.c +28 -14
@@ -3,28 +3,38 @@*/ #include "git-compat-util.h" +#include "parse-options.h" #include "vcs-svn/svndump.h" #include "vcs-svn/svndiff.h" #include "vcs-svn/sliding_window.h" #include "vcs-svn/line_buffer.h" -static const char test_svnfe_usage[] = -"test-svn-fe (<dumpfile> | [-d] <preimage> <delta> <len>)" ; +static const char *const test_svnfe_usage[] = { +"test-svn-fe (<dumpfile> | -d <preimage> <delta> <len>)" , +NULL +}; -static int apply_delta (int argc,char *argv[]) +static int d; + +static struct option test_svnfe_options[] = { +OPT_SET_INT ('d' ,NULL , &d,"test apply_delta" ,1 ), +OPT_END () +}; + +static int apply_delta (int argc,const char *argv[]) {struct line_buffer preimage =LINE_BUFFER_INIT ;struct line_buffer delta =LINE_BUFFER_INIT ;struct sliding_view preimage_view =SLIDING_VIEW_INIT (&preimage,-1 ); -if (argc !=5 ) -usage (test_svnfe_usage); +if (argc !=3 ) +usage_with_options (test_svnfe_usage, test_svnfe_options); -if (buffer_init (&preimage, argv[2 ])) +if (buffer_init (&preimage, argv[0 ]))die_errno ("cannot open preimage" ); -if (buffer_init (&delta, argv[3 ])) +if (buffer_init (&delta, argv[1 ]))die_errno ("cannot open delta" ); -if (svndiff0_apply (&delta, (off_t )strtoull (argv[4 ],NULL ,0 ), +if (svndiff0_apply (&delta, (off_t )strtoull (argv[2 ],NULL ,0 ), &preimage_view, stdout))return 1 ;if (buffer_deinit (&preimage))
@@ -37,10 +47,16 @@ static int apply_delta(int argc, char *argv[])return 0 ; } -int main (int argc,char *argv[]) +int main (int argc,const char *argv[]) { -if (argc ==2 ) { -if (svndump_init (argv[1 ],NULL )) + argc =parse_options (argc, argv,NULL , test_svnfe_options, + test_svnfe_usage,0 ); + +if (d) +return apply_delta (argc, argv); + +if (argc ==1 ) { +if (svndump_init (argv[0 ],NULL ))return 1 ;svndump_read ();svndump_deinit ();
@@ -48,7 +64,5 @@ int main(int argc, char *argv[])return 0 ; } -if (argc >=2 && !strcmp (argv[1 ],"-d" )) -return apply_delta (argc, argv); -usage (test_svnfe_usage); +usage_with_options (test_svnfe_usage, test_svnfe_options); }
Signature · 1 line
1.7.3.4
PATCH 6/8 vcs-svn: allow to specify dump destination ref
In reply to Dmitry Ivankovsvn-fe produces fast-import stream for a fixed refs/heads/master ref. It is usually desired to write to a different ref. In a remote helper it would be a ref in private namespace. If svn-fe is used by someone directly it'll be more safe to remind where the commits can go. And in both cases it may be needed to import from two repos and hence to different refs.
Add a destination ref parameter to vcs-svn/, a corresponding parameter to svn-fe and a simple test for it.
$ svn-fe --ref=refs/heads/master ... is an explicit way to stay with the default destination.
--- contrib/svn-fe/svn-fe.c | 5 +++- contrib/svn-fe/svn-fe.txt | 3 ++ t/t9010-svn-fe.sh | 49 +++++++++++++++++++++++++++++--------------- test-svn-fe.c | 7 ++++- vcs-svn/fast_export.c | 8 +++++- vcs-svn/fast_export.h | 2 +- vcs-svn/svndump.c | 4 +- vcs-svn/svndump.h | 2 +- 8 files changed, 54 insertions(+), 26 deletions(-)
contrib/svn-fe/svn-fe.c +4 -1
@@ -13,10 +13,13 @@ static const char * const svn_fe_usage[] = { };static const char *url; +static const char *ref ="refs/heads/master" ;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_END () };
@@ -32,7 +35,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)) +if (svndump_init (NULL , url, ref))return 1 ;svndump_read ();svndump_deinit ();
contrib/svn-fe/svn-fe.txt +3 -0
@@ -32,6 +32,9 @@ OPTIONS Url to be used in git-svn-id: lines in git-svn metadata lines format. See NOTES for more detailed description. +--ref=<dst_ref>:: + Ref to be written by the generated stream. + Default is refs/heads/master. INPUT FORMAT ------------
t/t9010-svn-fe.sh +32 -17
81 lines not on this page · raw message
test-svn-fe.c +5 -2
@@ -10,14 +10,17 @@#include "vcs-svn/line_buffer.h" static const char *const test_svnfe_usage[] = { -"test-svn-fe (<dumpfile> | -d <preimage> <delta> <len>)" , +"test-svn-fe ([options] <dumpfile> | -d <preimage> <delta> <len>)" ,NULL }; +static const char *ref ="refs/heads/master" ;static int d;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_END () };
@@ -56,7 +59,7 @@ int main(int argc, const char *argv[])return apply_delta (argc, argv);if (argc ==1 ) { -if (svndump_init (argv[0 ],NULL )) +if (svndump_init (argv[0 ],NULL , ref))return 1 ;svndump_read ();svndump_deinit ();
vcs-svn/fast_export.c +6 -2
@@ -18,6 +18,7 @@static uint32_t first_commit_done;static struct line_buffer postimage =LINE_BUFFER_INIT ;static struct line_buffer report_buffer =LINE_BUFFER_INIT ; +static struct strbuf ref_name =STRBUF_INIT ;/* NEEDSWORK: move to fast_export_init() */ static int init_postimage (void )
@@ -29,15 +30,18 @@ static int init_postimage(void)return buffer_tmpfile_init (&postimage); } -void fast_export_init (int fd) +void fast_export_init (int fd,const char *dst_ref) { first_commit_done =0 ; +strbuf_reset (&ref_name); +strbuf_addstr (&ref_name, dst_ref);if (buffer_fdinit (&report_buffer, fd))die_errno ("cannot read from file descriptor %d" , fd); }void fast_export_deinit (void ) { +strbuf_release (&ref_name);if (buffer_deinit (&report_buffer))die_errno ("error closing fast-import feedback stream" ); }
@@ -89,7 +93,7 @@ void fast_export_begin_commit(uint32_t revision, const char *author, }else { *gitsvnline ='\0' ; } -printf ("commit refs/heads/master\n" ); +printf ("commit %s\n" , ref_name.buf);printf ("mark :%" PRIu32"\n" , revision); printf("committer %s <%s@%s> %ld +0000\n", *author ? author : "nobody",
vcs-svn/fast_export.h +1 -1
@@ -4,7 +4,7 @@struct strbuf ;struct line_buffer ; -void fast_export_init (int fd); +void fast_export_init (int fd,const char *dst_ref);void fast_export_deinit (void );void fast_export_reset (void );
vcs-svn/svndump.c +2 -2
@@ -454,11 +454,11 @@ void svndump_read(void)end_revision (); } -int svndump_init (const char *filename,const char *url) +int svndump_init (const char *filename,const char *url,const char *dst_ref) {if (buffer_init (&input, filename))return error ("cannot open %s: %s" , filename,strerror (errno)); -fast_export_init (REPORT_FILENO ); +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 );
vcs-svn/svndump.h +1 -1
@@ -1,7 +1,7 @@#ifndef SVNDUMP_H_ #define SVNDUMP_H_ -int svndump_init (const char *filename,const char *url); +int svndump_init (const char *filename,const char *url,const char *dst_ref);void svndump_read (void );void svndump_deinit (void );void svndump_reset (void );
Signature · 1 line
1.7.3.4
PATCH 7/8 vcs-svn: convert REPORT_FILENO to an option
In reply to Dmitry Ivankovsvn-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
--- 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(-)
contrib/svn-fe/svn-fe.c +4 -1
@@ -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 ();
contrib/svn-fe/svn-fe.txt +6 -2
@@ -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 ------------
t/t9010-svn-fe.sh +54 -4
84 lines not on this page · raw message
test-svn-fe.c +4 -1
@@ -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 ();
vcs-svn/svndump.c +2 -4
@@ -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 );
vcs-svn/svndump.h +1 -1
@@ -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 );
Signature · 1 line
1.7.3.4
Re: [PATCH 7/8] vcs-svn: convert REPORT_FILENO to an option
Hi again,
Quoted 9 lines · Dmitry Ivankov
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.
Quoted 5 lines
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
Except for the fact that you're changing the API to accommodate an extra option as I already pointed out earlier, I like this patch. This was one of the things that I'd wanted to do myself, but never actually got around to doing.
Thanks for working on this.
-- Ram
PATCH 8/8 vcs-svn: allow to disable 'progress' lines
In reply to Dmitry Ivankovvcs-svn/ writes a progress line after each processed revision. It is too noisy for big imports. That's a stress for a terminal and any other output can be lost or scrolled away among these lines.
For now just add a switch to turn progress lines off:
$ svn-fe --no-progress ...
--- contrib/svn-fe/svn-fe.c | 6 +++++- contrib/svn-fe/svn-fe.txt | 3 +++ test-svn-fe.c | 2 +- vcs-svn/fast_export.c | 7 +++++-- vcs-svn/fast_export.h | 2 +- vcs-svn/svndump.c | 4 ++-- vcs-svn/svndump.h | 2 +- 7 files changed, 18 insertions(+), 8 deletions(-)
contrib/svn-fe/svn-fe.c +5 -1
@@ -15,8 +15,12 @@ static const char * const svn_fe_usage[] = {static const char *url;static const char *ref ="refs/heads/master" ;static int backflow_fd =3 ; +static int progress =1 ;static struct option svn_fe_options[] = { +OPT_BIT (0 ,"progress" , &progress, +"write a progress line after each commit" , +1 ),OPT_STRING (0 ,"git-svn-id-url" , &url,"url" ,"append git-svn metadata line to commit messages" ), OPT_STRING(0, "ref", &ref, "dst_ref",
@@ -38,7 +42,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, backflow_fd)) +if (svndump_init (NULL , url, ref, backflow_fd, progress))return 1 ;svndump_read ();svndump_deinit ();
contrib/svn-fe/svn-fe.txt +3 -0
@@ -39,6 +39,9 @@ OPTIONS Integer number of file descriptor from which responses to 'ls' and 'cat-blob' requests will come. Default is fd=3. +--[no-]progress:: + Write 'progress' lines to fast-import stream. These + can be displayed by fast-import. INPUT FORMAT ------------
test-svn-fe.c +1 -1
@@ -62,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, backflow_fd)) +if (svndump_init (argv[0 ],NULL , ref, backflow_fd,1 ))return 1 ;svndump_read ();svndump_deinit ();
vcs-svn/fast_export.c +5 -2
@@ -19,6 +19,7 @@ static uint32_t first_commit_done;static struct line_buffer postimage =LINE_BUFFER_INIT ;static struct line_buffer report_buffer =LINE_BUFFER_INIT ;static struct strbuf ref_name =STRBUF_INIT ; +static int print_progress;/* NEEDSWORK: move to fast_export_init() */ static int init_postimage (void )
@@ -30,9 +31,10 @@ static int init_postimage(void)return buffer_tmpfile_init (&postimage); } -void fast_export_init (int fd,const char *dst_ref) +void fast_export_init (int fd,const char *dst_ref,int progress) { first_commit_done =0 ; + print_progress = progress;strbuf_reset (&ref_name);strbuf_addstr (&ref_name, dst_ref);if (buffer_fdinit (&report_buffer, fd))
@@ -112,7 +114,8 @@ void fast_export_begin_commit(uint32_t revision, const char *author,void fast_export_end_commit (uint32_t revision) { -printf ("progress Imported commit %" PRIu32".\n\n" , revision); +if (print_progress) +printf ("progress Imported commit %" PRIu32".\n\n" , revision); }static void ls_from_rev (uint32_t rev,const char *path)
vcs-svn/fast_export.h +1 -1
@@ -4,7 +4,7 @@struct strbuf ;struct line_buffer ; -void fast_export_init (int fd,const char *dst_ref); +void fast_export_init (int fd,const char *dst_ref,int progress);void fast_export_deinit (void );void fast_export_reset (void );
vcs-svn/svndump.c +2 -2
@@ -452,11 +452,11 @@ void svndump_read(void)end_revision (); } -int svndump_init (const char *filename,const char *url,const char *dst_ref,int report_fileno) +int svndump_init (const char *filename,const char *url,const char *dst_ref,int report_fileno,int progress) {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, progress);strbuf_init (&dump_ctx.uuid,4096 );strbuf_init (&dump_ctx.url,4096 );strbuf_init (&rev_ctx.log,4096 );
vcs-svn/svndump.h +1 -1
@@ -1,7 +1,7 @@#ifndef SVNDUMP_H_ #define SVNDUMP_H_ -int svndump_init (const char *filename,const char *url,const char *dst_ref,int report_fileno); +int svndump_init (const char *filename,const char *url,const char *dst_ref,int report_fileno,int progress);void svndump_read (void );void svndump_deinit (void );void svndump_reset (void );
Signature · 1 line
1.7.3.4
Re: [PATCH 8/8] vcs-svn: allow to disable 'progress' lines
Hi Dmitry,
Quoted 6 lines · Dmitry Ivankov
vcs-svn/ writes a progress line after each processed revision. It is too noisy for big imports. That's a stress for a terminal and any other output can be lost or scrolled away among these lines.
For now just add a switch to turn progress lines off:
$ svn-fe --no-progress ...
Agreed. Sounds like a good change.
contrib/svn-fe/svn-fe.c int main(int argc, const char **argv) · line 45
Quoted 10 lines
contrib/svn-fe/svn-fe.c +1
-1@@ -38,7 +42,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, backflow_fd)) + if (svndump_init(NULL, url, ref, backflow_fd, progress))
You're modifying the svndump_init API for every new option that's added. This'll clearly break down when you have many options -- how about wrapping it up in an options structure and then passing that?
Quoted 11 lines
contrib/svn-fe/svn-fe.txt +0
-0@@ -39,6 +39,9 @@ OPTIONSInteger number of file descriptor from which responses to 'ls' and 'cat-blob' requests will come. Default is fd=3.
+--[no-]progress::
+ Write 'progress' lines to fast-import stream. These
+ can be displayed by fast-import.
Hm, this will make it a little too silent for the end-user. What do you feel about printing something minimalistic like a '.' for each imported revision? Atleast it won't look like it's hung. Also, how does this interact with the 'progress' option of fast-import protocol?
Quoted 26 lines
INPUT FORMAT
------------test-svn-fe.c +1
-1@@ -62,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, backflow_fd)) + if (svndump_init(argv[0], NULL, ref, backflow_fd, 1)) return 1; svndump_read(); svndump_deinit();vcs-svn/fast_export.c +1
-0@@ -19,6 +19,7 @@ static uint32_t first_commit_done; static struct line_buffer postimage = LINE_BUFFER_INIT; static struct line_buffer report_buffer = LINE_BUFFER_INIT; static struct strbuf ref_name = STRBUF_INIT; +static int print_progress;
vcs-svn/fast_export.c static int init_postimage(void) · line 37
Quoted 8 lines
vcs-svn/fast_export.c +2
-1@@ -30,9 +31,10 @@ static int init_postimage(void) return buffer_tmpfile_init(&postimage); } -void fast_export_init (int fd,const char *dst_ref) +void fast_export_init (int fd,const char *dst_ref,int progress) { first_commit_done = 0; + print_progress = progress;
The only reason you're modifying the API of fast_export_init is so that it can set a global static variable? Also, this change seems more absurd because progress reporting isn't directly related to fast_export_init. How about having a dedicated function for option parsing that sets all the global statics?
I'm sorry I haven't been more involved with this project. Still, I hope this review helps.
-- Ram
Re: [PATCH 8/8] vcs-svn: allow to disable 'progress' lines
Hi!
[...]
Quoted 1 line
Quoted 1 line
contrib/svn-fe/svn-fe.c +0
-0
[...]
Quoted 6 lines
Quoted 2 lines
- if (
svndump_init(NULL, url, ref, backflow_fd))
+ if (svndump_init(NULL, url, ref, backflow_fd, progress))You're modifying the
svndump_initAPI for every new option that's added. This'll clearly break down when you have many options -- how about wrapping it up in an options structure and then passing that?
Well, there has to be a function to init that structure then. And the structure will become a part of API.
So don't know if it's worthy.
Quoted 7 lines
Quoted 7 lines
contrib/svn-fe/svn-fe.txt +0
-0@@ -39,6 +39,9 @@ OPTIONSInteger number of file descriptor from which responses to 'ls' and 'cat-blob' requests will come.
Quoted 8 lines
Quoted 4 lines
Default is fd=3.
+--[no-]progress::
+ Write 'progress' lines to fast-import stream. These
+ can be displayed by fast-import.Hm, this will make it a little too silent for the end-user. What do you feel about printing something minimalistic like a '.' for each imported revision? Atleast it won't look like it's hung.
For a medium 8k commit repo it is 100 lines - still too much. A single line for the first revision seem harmless and will indicate that the remote connection succeeded
(helps to see that it's not a connection timeout, probably caused by dns lookup or a firewall).
Quoted 1 line
Also, how does this interact with the 'progress' option of fast-import protocol?
git fast-import --quiet prints any progress line produced by a helper. transport-helper.c tries to set the option
but doesn't fail if it is not accepted or if helper doesn't support options at all.
For now the helper doesn't use this protocol option.
A better solution could be to use progress.o api to display progress. Or an ad-hoc hack with adaptive progress step, say report a progress on each "power of two"-th revision.
As a starting point for tests let there bust a simple switch-off.
[...]
Quoted 9 lines
Quoted 9 lines
vcs-svn/fast_export.c +1
-0@@ -19,6 +19,7 @@ static uint32_t first_commit_done; static struct line_buffer postimage = LINE_BUFFER_INIT; static struct line_buffer report_buffer = LINE_BUFFER_INIT; static struct strbuf ref_name = STRBUF_INIT; +static int print_progress;
[...]
Quoted 8 lines
Quoted 5 lines
vcs-svn/fast_export.c +1
-1-void fast_export_init (int fd,const char *dst_ref) +void fast_export_init (int fd,const char *dst_ref,int progress){
first_commit_done = 0;
+print_progress= progress;The only reason you're modifying the API of
fast_export_initis so that it can set a global static variable?
Looked once more at how these new variables are used. We can move progress lines generation to svndump.c. And also move ref_name from _init and being global static to a parameter in fast_export_begin_commit(), and to be more sane s/revision/target_mark/ s/revision - 1/from_mark/ and add a from_mark parameter, move first_commit_done logic to svndump.o. This way fast_export.o can operate on single commits and maybe it'll be easier to use it to apply svn branches layout in svn-fe in one run, though I'm not sure I'll use svn-fe to manage svn branches.
Quoted 7 lines
Also, this change seems
more absurd because progress reporting isn't directly related tofast_export_init. How about having a dedicated function for option parsing that sets all the global statics?I'm sorry I haven't been more involved with this project. Still, I hope this review helps.
This is very helpful, thanks.
Quoted 3 lines
-- Ram
Re: [PATCH 8/8] vcs-svn: allow to disable 'progress' lines
Hi again,
Quoted 9 lines · Dmitry Ivankov
Quoted 6 lines
Quoted 2 lines
- if (
svndump_init(NULL, url, ref, backflow_fd))
+ if (svndump_init(NULL, url, ref, backflow_fd, progress))You're modifying the
svndump_initAPI for every new option that's added. This'll clearly break down when you have many options -- how about wrapping it up in an options structure and then passing that?Well, there has to be a function to init that structure then. And the structure will become a part of API.
So don't know if it's worthy.
Well, you'll be wrapping up url, ref, backflow_fd, progress, and all other future command-line parameters in one variable. Think about it.
You can use the parse-options API to fill in default arguments
anyway.
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
contrib/svn-fe/svn-fe.txt +0
-0@@ -39,6 +39,9 @@ OPTIONSInteger number of file descriptor from which responses to 'ls' and 'cat-blob' requests will come.
Quoted 8 lines
Quoted 4 lines
Default is fd=3.
+--[no-]progress::
+ Write 'progress' lines to fast-import stream. These
+ can be displayed by fast-import.Hm, this will make it a little too silent for the end-user. What do you feel about printing something minimalistic like a '.' for each imported revision? Atleast it won't look like it's hung.
Quoted 5 lines
For a medium 8k commit repo it is 100 lines - still too much. A single line for the first revision seem harmless and will indicate that the remote connection succeeded
(helps to see that it's not a connection timeout, probably caused by dns lookup or a firewall).
Ah, right. I agree with you.
Quoted 11 lines
Quoted 1 line
Also, how does this interact with the 'progress' option of fast-import protocol?
git fast-import --quiet prints any progress line produced by a helper.
transport-helper.ctries to set the option
but doesn't fail if it is not accepted or if helper doesn't support options at all.
For now the helper doesn't use this protocol option.A better solution could be to use progress.o api to display progress. Or an ad-hoc hack with adaptive progress step, say report a progress on each "power of two"-th revision.
As a starting point for tests let there bust a simple switch-off.
Yeah, that makes sense -- would love to see that in future.
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
contrib/svn-fe/svn-fe.txt +1
-1-void fast_export_init(int fd, const char *dst_ref) +void fast_export_init(int fd, const char *dst_ref, int progress){
first_commit_done = 0;
+print_progress= progress;The only reason you're modifying the API of
fast_export_initis so that it can set a global static variable?
Quoted 8 lines
Looked once more at how these new variables are used. We can move progress lines generation to
svndump.c. And also moveref_namefrom_initand being global static to a parameter infast_export_begin_commit(), and to be more sane s/revision/target_mark/ s/revision - 1/from_mark/ and add afrom_markparameter, movefirst_commit_donelogic to svndump.o. This way fast_export.o can operate on single commits and maybe it'll be easier to use it to apply svn branches layout in svn-fe in one run, though I'm not sure I'll use svn-fe to manage svn branches.
Makes sense.
Thanks.
-- Ram
Heya,
[+Ram]
Quoted 29 lines · Dmitry Ivankov
This patch set adds a few options for svn-fe that can be used in a svn remote helper and useful in general for vcs-svn/. The last three patches add the options, others prepare the ground for them.
The patch base is svn-fe branch at
git://repo.or.cz/git/jrn.gitDmitry Ivankov (8):
vcs-svn: move url parameter from_readto_init
svn-fe: add man target toMakefile
svn-fe: add EXTLIBS needed for parse-options
svn-fe: add usage and unpositional arguments versions
test-svn-fe: use parse-options
vcs-svn: allow to specify dump destination ref
vcs-svn: convertREPORT_FILENOto an option
vcs-svn: allow to disable 'progress' linescontrib/svn-fe/Makefile | 18 ++++----
contrib/svn-fe/svn-fe.c | 42 +++++++++++++++++--contrib/svn-fe/svn-fe.txt| 29 +++++++++++--
t/t9010-svn-fe.sh | 99 +++++++++++++++++++++++++++++++++++++--------test-svn-fe.c| 50 ++++++++++++++++-------vcs-svn/fast_export.c| 13 +++++-
vcs-svn/fast_export.h | 2 +-
vcs-svn/svndump.c | 11 ++---
vcs-svn/svndump.h | 4 +-9 files changed, 205 insertions(+), 63 deletions(-)--
1.7.3.4
Signature · 3 lines
Cheers, Sverre Rabbelier