git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] cvsimport: start adding cvsps 3.x support

From
Chris Rorvick <chris@rorvick.com>
Date
Jan 15, 2013, 06:19 UTC
Message-ID
<CAEUsAPZV6rdFz5R6NN55qYr5se4bFJftE0xGSPAtXLp8jcO0vw@mail.gmail.com>
In-Reply-To
<1358127629-7500-4-git-send-email-gitster@pobox.com>
On Sun, Jan 13, 2013 at 7:40 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 179 quoted lines
> 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 <gitster@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 0000000..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 <esr@thyrsus.com>, December 2012
> +# May be redistributed under the license of the git project.
> +
> +import sys
> +
> +if sys.hexversion < 0x02060000:
> +    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)
> +        sys.exit(1)
> +
> +class cvsps:
> +    "Method class for cvsps back end."
> +
> +    cvsps = "@@CVSPS3_PATH@@"
> +    def __init__(self):
> +        self.opts = ""
> +        self.revmap = None
> +    def set_repo(self, val):
> +        "Set the repository root option."
> +        if not val.startswith(":"):
> +            if not val.startswith(os.sep):
> +                val = os.path.abspath(val)
> +            val = ":local:" + val
> +        self.opts += " --root '%s'" % val
> +    def set_authormap(self, val):
> +        "Set the author-map file."
> +        self.opts += " -A '%s'" % val
> +    def set_fuzz(self, val):
> +        "Set the commit-similarity window."
> +        self.opts += " -z %s" % val
> +    def set_nokeywords(self):
> +        "Suppress CVS keyword expansion."
> +        self.opts += " -k"
> +    def add_opts(self, val):
> +        "Add options to the engine command line."
> +        self.opts += " " + val
> +    def set_exclusion(self, val):
> +        "Set a file exclusion regexp."
> +        self.opts += " -n -f '%s'" % val
> +    def set_after(self, val):
> +        "Set a date threshold for incremental import."
> +        self.opts += " -d '%s'" % val
> +    def set_revmap(self, val):
> +        "Set the file to which the engine should dump a reference map."
> +        self.revmap = val
> +        self.opts += " -R '%s'" % self.revmap
> +    def set_module(self, val):
> +        "Set the module to query."
> +        self.opts += " " + val
> +    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.

Chris
Previous: Junio C HamanoNext: Junio C Hamano
Message 25 of 37 in “cvsimport: rewrite to use cvsps 3.x to fix major bugs”
  1. cvsimport: rewrite to use cvsps 3.x to fix major bugsJunio C Hamano, Jan 11, 2013
  2. Junio C HamanoJan 11, 2013
  3. Eric S. RaymondJan 11, 2013
  4. Junio C HamanoJan 11, 2013
  5. Junio C HamanoJan 11, 2013
  6. Eric S. RaymondJan 12, 2013
  7. Junio C HamanoJan 12, 2013
  8. t/t960[123]: remove leftover scriptsJunio C Hamano, Jan 12, 2013
  9. Chris RorvickJan 12, 2013
  10. t/lib-cvs: cvsimport no longer works without Python >= 2.7Junio C Hamano, Jan 12, 2013
  11. Michael HaggertyJan 12, 2013
  12. John KeepingJan 13, 2013
  13. Eric S. RaymondJan 12, 2013
  14. Michael HaggertyJan 12, 2013
  15. Eric S. RaymondJan 12, 2013
  16. Jonathan NiederJan 12, 2013
  17. Jonathan NiederJan 12, 2013
  18. Junio C HamanoJan 13, 2013
  19. Junio C HamanoJan 13, 2013
  20. 0/3 A smoother transition plan for cvsimportJunio C Hamano, Jan 14, 2013
  21. 1/3 cvsimport: allow setting a custom cvsps (2.x) program nameJunio C Hamano, Jan 14, 2013
  22. 2/3 cvsimport: introduce a version-switch wrapperJunio C Hamano, Jan 14, 2013
  23. Junio C HamanoJan 14, 2013
  24. 3/3 cvsimport: start adding cvsps 3.x supportJunio C Hamano, Jan 14, 2013
  25. Chris RorvickJan 15, 2013
  26. Junio C HamanoJan 15, 2013
  27. Michael HaggertyJan 14, 2013
  28. 0/6 A smoother transition plan for cvsimportJunio C Hamano, Jan 14, 2013
  29. 1/6 Makefile: add description on PERL/PYTHON_PATHJunio C Hamano, Jan 14, 2013
  30. 2/6 cvsimport: allow setting a custom cvsps (2.x) program nameJunio C Hamano, Jan 14, 2013
  31. 3/6 cvsimport: introduce a version-switch wrapperJunio C Hamano, Jan 14, 2013
  32. 4/6 cvsimport: start adding cvsps 3.x supportJunio C Hamano, Jan 14, 2013
  33. 5/6 cvsimport: make tests reusable for cvsimport-3Junio C Hamano, Jan 14, 2013
  34. 6/6 cvsimport-3: add a sample testJunio C Hamano, Jan 14, 2013
  35. Jonathan NiederJan 14, 2013
  36. 7/6 t9600: further prepare for sharingJunio C Hamano, Jan 14, 2013
  37. 8/6 t9600: adjust for new cvsimportJunio C Hamano, Jan 14, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.