Re: [PATCH 3/3] cvsimport: start adding cvsps 3.x support
On Sun, Jan 13, 2013 at 7:40 PM, Junio C Hamano gits...@pobox.com wrote: The new cvsps 3.x series lacks support of some options cvsps 2.x series had and used by cvsimport-2; add a replacement program from the author of cvsps 3.x and allow users to choose it by setting the GIT_CVSPS_VERSION environment variable to 3. We would later add support to auto-detect the version of installed cvsps to this code when the environment variable is not set. Note that in this step, cvsimport-3 that relies on cvsps 3.x does not have any test coverage. As cvsimport-3 supports most of the command line options cvsimport-2, we should be able to tweak some of t96xx tests and run them with GIT_CVSPS_VERSION set to both 2 and 3, but that is a topic of later patches that should come on top. Signed-off-by: Junio C Hamano gits...@pobox.com --- Makefile | 18 ++- git-cvsimport-3.py | 344 + git-cvsimport.sh | 4 +- 3 files changed, 359 insertions(+), 7 deletions(-) create mode 100755 git-cvsimport-3.py diff --git a/Makefile b/Makefile index b022db2..060cdc2 100644 --- a/Makefile +++ b/Makefile @@ -470,8 +470,9 @@ SCRIPT_PERL += git-relink.perl SCRIPT_PERL += git-send-email.perl SCRIPT_PERL += git-svn.perl -SCRIPT_PYTHON += git-remote-testpy.py +SCRIPT_PYTHON += git-cvsimport-3.py SCRIPT_PYTHON += git-p4.py +SCRIPT_PYTHON += git-remote-testpy.py SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ $(patsubst %.perl,%,$(SCRIPT_PERL)) \ @@ -575,8 +576,11 @@ endif ifndef CVSPS2_PATH CVSPS2_PATH = cvsps endif +ifndef CVSPS3_PATH + CVSPS3_PATH = cvsps +endif -export PERL_PATH PYTHON_PATH CVSPS2_PATH +export PERL_PATH PYTHON_PATH CVSPS2_PATH CVSPS3_PATH LIB_FILE = libgit.a XDIFF_LIB = xdiff/lib.a @@ -1515,6 +1519,7 @@ PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH)) TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH)) CVSPS2_PATH_SQ = $(subst ','\'',$(CVSPS2_PATH)) +CVSPS3_PATH_SQ = $(subst ','\'',$(CVSPS3_PATH)) DIFF_SQ = $(subst ','\'',$(DIFF)) LIBS = $(GITLIBS) $(EXTLIBS) @@ -1757,12 +1762,15 @@ ifndef NO_PYTHON $(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py $(QUIET_GEN)$(RM) $@ $@+ \ - INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \ + INSTLIBDIR_SQ=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \ --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \ - instlibdir` \ + instlibdir | \ + sed -e s/'/'\''/g` \ + echo InstLibDir is $$INSTLIBDIR_SQ \ sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \ -e 's|\(os\.getenv(GITPYTHONLIB\)[^)]*)|\1,@@INSTLIBDIR@@)|' \ - -e 's|@@INSTLIBDIR@@|'$$INSTLIBDIR'|g' \ + -e 's|@@CVSPS3_PATH@@|$(CVSPS3_PATH_SQ)|g' \ + -e 's|@@INSTLIBDIR@@|'$$INSTLIBDIR_SQ'|g' \ $@.py $@+ \ chmod +x $@+ \ mv $@+ $@ diff --git a/git-cvsimport-3.py b/git-cvsimport-3.py new file mode 100755 index 000..57f13b7 --- /dev/null +++ b/git-cvsimport-3.py @@ -0,0 +1,344 @@ +#!/usr/bin/env python +# +# Import CVS history into git +# +# Intended to be a near-workalike of Matthias Urlichs's Perl implementation. +# +# By Eric S. Raymond e...@thyrsus.com, December 2012 +# May be redistributed under the license of the git project. + +import sys + +if sys.hexversion 0x0206: +sys.stderr.write(git cvsimport: requires Python 2.6 or later.\n) +sys.exit(1) + +import os, getopt, subprocess, tempfile, shutil + +DEBUG_COMMANDS = 1 + +class Fatal(Exception): +Unrecoverable error. +def __init__(self, msg): +Exception.__init__(self) +self.msg = msg + +def do_or_die(dcmd, legend=): +Either execute a command or raise a fatal exception. +if legend: +legend =+ legend +if verbose = DEBUG_COMMANDS: +sys.stdout.write(git cvsimport: executing '%s'%s\n % (dcmd, legend)) +try: +retcode = subprocess.call(dcmd, shell=True) +if retcode 0: +raise Fatal(git cvsimport: child was terminated by signal %d. % -retcode) +elif retcode != 0: +raise Fatal(git cvsimport: child returned %d. % retcode) +except (OSError, IOError) as e: +raise Fatal(git cvsimport: execution of %s%s failed: %s % (dcmd, legend, e)) + +def capture_or_die(dcmd, legend=): +Either execute a command and capture its output or die. +if legend: +legend =+ legend +if verbose = DEBUG_COMMANDS: +sys.stdout.write(git cvsimport: executing '%s'%s\n % (dcmd, legend)) +try: +return subprocess.check_output(dcmd, shell=True) +except subprocess.CalledProcessError as e: +if e.returncode 0: +
Re: [PATCH 3/3] cvsimport: start adding cvsps 3.x support
Chris Rorvick ch...@rorvick.com writes: [jc: please elide parts you are not responding to, leaving enough lines to understand the context] +def command(self): +Emit the command implied by all previous options. +return self.cvsps + --fast-export + self.opts --fast-export string is missing a leading space. With this fix and the latest cvsps build I'm seeing 6 of 15 failures for t9650 which is what I was getting out of the patched t9600. Thanks; I'll amend it and push the result out, but I think we will need to rip this part out and form the command string in a saner way (e.g. if the path needs to have SP in it, e.g. /Program Files/cvsps3, the above would not work correctly anyway). -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] cvsimport: start adding cvsps 3.x support
The new cvsps 3.x series lacks support of some options cvsps 2.x series had and used by cvsimport-2; add a replacement program from the author of cvsps 3.x and allow users to choose it by setting the GIT_CVSPS_VERSION environment variable to 3. We would later add support to auto-detect the version of installed cvsps to this code when the environment variable is not set. Note that in this step, cvsimport-3 that relies on cvsps 3.x does not have any test coverage. As cvsimport-3 supports most of the command line options cvsimport-2, we should be able to tweak some of t96xx tests and run them with GIT_CVSPS_VERSION set to both 2 and 3, but that is a topic of later patches that should come on top. Signed-off-by: Junio C Hamano gits...@pobox.com --- Makefile | 18 ++- git-cvsimport-3.py | 344 + git-cvsimport.sh | 4 +- 3 files changed, 359 insertions(+), 7 deletions(-) create mode 100755 git-cvsimport-3.py diff --git a/Makefile b/Makefile index b022db2..060cdc2 100644 --- a/Makefile +++ b/Makefile @@ -470,8 +470,9 @@ SCRIPT_PERL += git-relink.perl SCRIPT_PERL += git-send-email.perl SCRIPT_PERL += git-svn.perl -SCRIPT_PYTHON += git-remote-testpy.py +SCRIPT_PYTHON += git-cvsimport-3.py SCRIPT_PYTHON += git-p4.py +SCRIPT_PYTHON += git-remote-testpy.py SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ $(patsubst %.perl,%,$(SCRIPT_PERL)) \ @@ -575,8 +576,11 @@ endif ifndef CVSPS2_PATH CVSPS2_PATH = cvsps endif +ifndef CVSPS3_PATH + CVSPS3_PATH = cvsps +endif -export PERL_PATH PYTHON_PATH CVSPS2_PATH +export PERL_PATH PYTHON_PATH CVSPS2_PATH CVSPS3_PATH LIB_FILE = libgit.a XDIFF_LIB = xdiff/lib.a @@ -1515,6 +1519,7 @@ PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH)) TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH)) CVSPS2_PATH_SQ = $(subst ','\'',$(CVSPS2_PATH)) +CVSPS3_PATH_SQ = $(subst ','\'',$(CVSPS3_PATH)) DIFF_SQ = $(subst ','\'',$(DIFF)) LIBS = $(GITLIBS) $(EXTLIBS) @@ -1757,12 +1762,15 @@ ifndef NO_PYTHON $(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py $(QUIET_GEN)$(RM) $@ $@+ \ - INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \ + INSTLIBDIR_SQ=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \ --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \ - instlibdir` \ + instlibdir | \ + sed -e s/'/'\''/g` \ + echo InstLibDir is $$INSTLIBDIR_SQ \ sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \ -e 's|\(os\.getenv(GITPYTHONLIB\)[^)]*)|\1,@@INSTLIBDIR@@)|' \ - -e 's|@@INSTLIBDIR@@|'$$INSTLIBDIR'|g' \ + -e 's|@@CVSPS3_PATH@@|$(CVSPS3_PATH_SQ)|g' \ + -e 's|@@INSTLIBDIR@@|'$$INSTLIBDIR_SQ'|g' \ $@.py $@+ \ chmod +x $@+ \ mv $@+ $@ diff --git a/git-cvsimport-3.py b/git-cvsimport-3.py new file mode 100755 index 000..57f13b7 --- /dev/null +++ b/git-cvsimport-3.py @@ -0,0 +1,344 @@ +#!/usr/bin/env python +# +# Import CVS history into git +# +# Intended to be a near-workalike of Matthias Urlichs's Perl implementation. +# +# By Eric S. Raymond e...@thyrsus.com, December 2012 +# May be redistributed under the license of the git project. + +import sys + +if sys.hexversion 0x0206: +sys.stderr.write(git cvsimport: requires Python 2.6 or later.\n) +sys.exit(1) + +import os, getopt, subprocess, tempfile, shutil + +DEBUG_COMMANDS = 1 + +class Fatal(Exception): +Unrecoverable error. +def __init__(self, msg): +Exception.__init__(self) +self.msg = msg + +def do_or_die(dcmd, legend=): +Either execute a command or raise a fatal exception. +if legend: +legend =+ legend +if verbose = DEBUG_COMMANDS: +sys.stdout.write(git cvsimport: executing '%s'%s\n % (dcmd, legend)) +try: +retcode = subprocess.call(dcmd, shell=True) +if retcode 0: +raise Fatal(git cvsimport: child was terminated by signal %d. % -retcode) +elif retcode != 0: +raise Fatal(git cvsimport: child returned %d. % retcode) +except (OSError, IOError) as e: +raise Fatal(git cvsimport: execution of %s%s failed: %s % (dcmd, legend, e)) + +def capture_or_die(dcmd, legend=): +Either execute a command and capture its output or die. +if legend: +legend =+ legend +if verbose = DEBUG_COMMANDS: +sys.stdout.write(git cvsimport: executing '%s'%s\n % (dcmd, legend)) +try: +return subprocess.check_output(dcmd, shell=True) +except subprocess.CalledProcessError as e: +if e.returncode 0: +sys.stderr.write(git cvsimport: child was terminated by signal %d. % -e.returncode) +elif e.returncode != 0: +sys.stderr.write(git cvsimport: child returned %d. % e.returncode)