CVS remote helper
Subsystems (2)
v4 cover CVS remote helper
Hi,
Another iteration of the patch series implementing a CVS remote helper. Changes from the previous iteration:
- Python coding style fixes suggested by PEP8, PyLint, David Aguilar, etc.
- Documentation/git-remote-cvs.txt compile fix
- git_remote_cvs/Makefile fixes from David Aguilar (his v2 series)
- rebased onto current 'pu' (minus jh/vcs-cvs)
- split up patch 2/4 into two parts to fit on the Git mailing list
Have fun! :)
...Johan
Johan Herland (5):
Basic build infrastructure for Python scripts 1/2: Add Python support library for CVS remote helper 2/2: Add Python support library for CVS remote helper
git-remote-cvs: Remote helper program for CVS repositories Add simple selftests of git-remote-cvs functionality
Documentation/git-remote-cvs.txt | 85 +++ Makefile | 46 ++ configure.ac | 3 + git-remote-cvs.py | 683 ++++++++++++++++++++++++ git_remote_cvs/.gitignore | 2 + git_remote_cvs/Makefile | 35 ++ git_remote_cvs/__init__.py | 27 + git_remote_cvs/changeset.py | 126 +++++ git_remote_cvs/commit_states.py | 62 +++ git_remote_cvs/cvs.py | 998 ++++++++++++++++++++++++++++++++++++ git_remote_cvs/cvs_revision_map.py | 418 +++++++++++++++ git_remote_cvs/cvs_symbol_cache.py | 313 +++++++++++ git_remote_cvs/git.py | 680 ++++++++++++++++++++++++ git_remote_cvs/setup.py | 17 + git_remote_cvs/util.py | 186 +++++++ t/t9800-remote-cvs-basic.sh | 524 +++++++++++++++++++ t/t9801-remote-cvs-fetch.sh | 291 +++++++++++ t/test-lib.sh | 1 + 18 files changed, 4497 insertions(+), 0 deletions(-) create mode 100644 Documentation/git-remote-cvs.txt create mode 100755 git-remote-cvs.py create mode 100644 git_remote_cvs/.gitignore create mode 100644 git_remote_cvs/Makefile create mode 100644 git_remote_cvs/__init__.py create mode 100644 git_remote_cvs/changeset.py create mode 100644 git_remote_cvs/commit_states.py create mode 100644 git_remote_cvs/cvs.py create mode 100644 git_remote_cvs/cvs_revision_map.py create mode 100644 git_remote_cvs/cvs_symbol_cache.py create mode 100644 git_remote_cvs/git.py create mode 100644 git_remote_cvs/setup.py create mode 100644 git_remote_cvs/util.py create mode 100755 t/t9800-remote-cvs-basic.sh create mode 100755 t/t9801-remote-cvs-fetch.sh
RFC v4 1/5 Basic build infrastructure for Python scripts
This patch adds basic boilerplate support (based on corresponding Perl sections) for enabling the building and installation Python scripts.
There are currently no Python scripts being built, and when Python scripts are added in future patches, their building and installation can be disabled by defining NO_PYTHON.
--- Makefile | 13 +++++++++++++ configure.ac | 3 +++ t/test-lib.sh | 1 + 3 files changed, 17 insertions(+), 0 deletions(-)
Makefile +13 -0
@@ -166,6 +166,8 @@ all:: # # Define NO_PERL if you do not want Perl scripts or libraries at all. # +# Define NO_PYTHON if you do not want Python scripts or libraries at all. +# # Define NO_TCLTK if you do not want Tcl/Tk GUI. # # The TCL_PATH variable governs the location of the Tcl interpreter
@@ -311,6 +313,7 @@ LIB_H = LIB_OBJS = PROGRAMS = SCRIPT_PERL = +SCRIPT_PYTHON = SCRIPT_SH = TEST_PROGRAMS =
@@ -349,6 +352,7 @@ SCRIPT_PERL += git-svn.perl SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ $(patsubst %.perl,%,$(SCRIPT_PERL)) \ + $(patsubst %.py,%,$(SCRIPT_PYTHON)) \ git-instaweb # Empty...
@@ -404,8 +408,12 @@ endif ifndef PERL_PATH PERL_PATH = /usr/bin/perl endif +ifndef PYTHON_PATH + PYTHON_PATH = /usr/bin/python +endif export PERL_PATH +export PYTHON_PATH LIB_FILE=libgit.a XDIFF_LIB=xdiff/lib.a
@@ -1259,6 +1267,10 @@ ifeq ($(PERL_PATH),) NO_PERL=NoThanks endif +ifeq ($(PYTHON_PATH),) +NO_PYTHON=NoThanks +endif + QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir QUIET_SUBDIR1 =
@@ -1306,6 +1318,7 @@ prefix_SQ = $(subst ','\'',$(prefix)) SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) +PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH)) TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH)) LIBS = $(GITLIBS) $(EXTLIBS)
configure.ac +3 -0
@@ -241,6 +241,9 @@ GIT_ARG_SET_PATH(shell) # Define PERL_PATH to provide path to Perl. GIT_ARG_SET_PATH(perl) # +# Define PYTHON_PATH to provide path to Python. +GIT_ARG_SET_PATH(python) +# # Define ZLIB_PATH to provide path to zlib. GIT_ARG_SET_PATH(zlib) #
t/test-lib.sh +1 -0
@@ -714,6 +714,7 @@ case $(uname -s) in esac test -z "$NO_PERL" && test_set_prereq PERL +test -z "$NO_PYTHON" && test_set_prereq PYTHON # test whether the filesystem supports symbolic links ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
Signature · 1 line
1.6.4.262.gca66a.dirty
RFC v4 2/5 1/2: Add Python support library for CVS remote helper
In reply to Johan HerlandThis patch introduces parts of a Python package called "git_remote_cvs" containing the building blocks of the CVS remote helper.
The CVS remote helper itself is NOT part of this patch.
This patch has been improved by the following contributions:
- David Aguilar: Lots of Python coding style fixes
---
This patch and the next patch belong together in the same commit, but the 100K limit (?) on the git mailing list forces me to split this patch in two.
...Johan
git_remote_cvs/changeset.py | 126 +++++ git_remote_cvs/cvs.py | 998 ++++++++++++++++++++++++++++++++++++ git_remote_cvs/cvs_symbol_cache.py | 313 +++++++++++ git_remote_cvs/util.py | 186 +++++++ 4 files changed, 1623 insertions(+), 0 deletions(-) create mode 100644 git_remote_cvs/changeset.py create mode 100644 git_remote_cvs/cvs.py create mode 100644 git_remote_cvs/cvs_symbol_cache.py create mode 100644 git_remote_cvs/util.py
git_remote_cvs/changeset.py new file +126 -0
@@ -0,0 +1,126 @@ +#!/usr/bin/env python + +"""Code for collecting individual CVS revisions into "changesets" + +A changeset is a collection of CVSRev objects that belong together in +the same "commit". This is a somewhat artificial construct on top of +CVS, which only stores changes at the per-file level. Normally, CVS +users create several CVS revisions simultaneously by applying the +"cvs commit" command to several files with related changes. This +module tries to reconstruct this notion of related revisions. + +""" + +from git_remote_cvs.util import debug, error, die + + +class Changeset(object): + + """Encapsulate a single changeset/commit.""" + + __slots__ = ('revs', 'date', 'author', 'message') + + # The maximum time between the changeset's date, and the date of a + # rev to included in that changeset. + MaxSecondsBetweenRevs = 8 * 60 * 60 # 8 hours + + @classmethod + def from_rev (cls, rev): + """Return a Changeset based on the given CVSRev object.""" + c = cls(rev.date, rev.author, rev.message) + result = c.add(rev) + assert result + return c + + def __init__ (self, date, author, message): + """Create a new Changeset with the given metadata.""" + self.revs = {} # dict: path -> CVSRev object + self.date = date # CVSDate object + self.author = author + self.message = message # Lines of commit message + + def __str__ (self): + """Stringify this Changeset object.""" + msg = self.message[0] # First line only + # Limit message to 25 chars + if len(msg) > 25: + msg = msg[:22] + "..." + return ("<Changeset @(%s) by %s (%s) updating %i files>" % + (self.date, self.author, msg, len(self.revs))) + + def __iter__ (self): + """Return iterator traversing the CVSRevs in this Changeset.""" + return self.revs.itervalues() + + def __getitem__ (self, path): + """Look up a specific CVSRev in this Changeset.""" + return self.revs[path] + + def within_time_window (self, rev): + """Return True iff the rev is within the time window of self.""" + return abs(rev.date.diff(self.date)) <= self.MaxSecondsBetweenRevs + + def add (self, rev): + """Add the given CVSRev to this Changeset. + + The addition will only succeed if the following holds: + - rev.author == self.author + - rev.message == self.message + - rev.path is not in self.revs + - rev.date is within MaxSecondsBetweenRevs of self.date + If the addition succeeds, True is returned; otherwise False. + + """ + if rev.author != self.author or \ + rev.message != self.message or \ + rev.path in self.revs or \ + not self.within_time_window(rev): + return False + + self.revs[rev.path] = rev + return True + + +def build_changesets_from_revs (cvs_revs): + """Organize CVSRev objects into a chronological list of Changesets.""" + # Construct chronological list of CVSRev objects + chron_revs = [] + for path, d in cvs_revs.iteritems(): + i = 0 # Current index into chronRevs + for revnum, cvsrev in sorted(d.iteritems()): + assert path == cvsrev.path + assert revnum == cvsrev.num + while i < len(chron_revs) and cvsrev.date > chron_revs[i].date: + i += 1 + # Insert cvsRev at position i in chronRevs + chron_revs.insert(i, cvsrev) + i += 1 + + changesets = [] # Chronological list of Changeset objects + while len(chron_revs): + # There are still more revs to be added to Changesets + # Create Changeset based on the first rev in chronRevs + changeset = Changeset.from_rev(chron_revs.pop(0)) + # Keep adding revs chronologically until MaxSecondsBetweenRevs + rejects = [] # Revs that cannot be added to this changeset + while len(chron_revs): + rev = chron_revs.pop(0) + reject = False + # First, if we have one of rev's parents in rejects, we + # must also reject rev + for r in rejects: + if r.path == rev.path: + reject = True + break + # Next, add rev to changeset, reject if add fails + if not reject: + reject = not changeset.add(rev) + if reject: + rejects.append(rev) + # stop trying when rev is too far in the future + if not changeset.within_time_window(rev): + break + chron_revs = rejects + chron_revs # Reconstruct remaining revs + changesets.append(changeset) + + return changesets
git_remote_cvs/cvs.py new file +998 -0
998 lines not on this page · raw message
git_remote_cvs/cvs_symbol_cache.py new file +313 -0
313 lines not on this page · raw message
git_remote_cvs/util.py new file +186 -0
186 lines not on this page · raw message
Signature · 1 line
1.6.4.262.gca66a.dirty
RFC v4 3/5 2/2: Add Python support library for CVS remote helper
In reply to Johan HerlandThis patch introduces the rest of a Python package called "git_remote_cvs" containing the building blocks of the CVS remote helper. The CVS remote helper itself is NOT part of this patch.
The patch includes the necessary Makefile additions to build and install the git_remote_cvs Python package along with the rest of Git.
This patch has been improved by the following contributions:
- David Aguilar: Lots of Python coding style fixes
- David Aguilar: DESTDIR support in Makefile
---
This patch and the previous patch belong together in the same commit, but the 100K limit (?) on the git mailing list forces me to split this patch in two.
...Johan
Makefile | 9 + git_remote_cvs/.gitignore | 2 + git_remote_cvs/Makefile | 35 ++ git_remote_cvs/__init__.py | 27 ++ git_remote_cvs/commit_states.py | 62 ++++ git_remote_cvs/cvs_revision_map.py | 418 ++++++++++++++++++++++ git_remote_cvs/git.py | 680 ++++++++++++++++++++++++++++++++++++ git_remote_cvs/setup.py | 17 + 8 files changed, 1250 insertions(+), 0 deletions(-) create mode 100644 git_remote_cvs/.gitignore create mode 100644 git_remote_cvs/Makefile create mode 100644 git_remote_cvs/__init__.py create mode 100644 git_remote_cvs/commit_states.py create mode 100644 git_remote_cvs/cvs_revision_map.py create mode 100644 git_remote_cvs/git.py create mode 100644 git_remote_cvs/setup.py
Makefile +9 -0
@@ -1350,6 +1350,9 @@ endif ifndef NO_PERL $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all endif +ifndef NO_PYTHON + $(QUIET_SUBDIR0)git_remote_cvs $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all +endif $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) please_set_SHELL_PATH_to_a_more_modern_shell:
@@ -1701,6 +1704,9 @@ install: all ifndef NO_PERL $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install endif +ifndef NO_PYTHON + $(MAKE) -C git_remote_cvs prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install +endif ifndef NO_TCLTK $(MAKE) -C gitk-git install $(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
@@ -1821,6 +1827,9 @@ ifndef NO_PERL $(RM) gitweb/gitweb.cgi $(MAKE) -C perl clean endif +ifndef NO_PYTHON + $(MAKE) -C git_remote_cvs clean +endif $(MAKE) -C templates/ clean $(MAKE) -C t/ clean ifndef NO_TCLTK
git_remote_cvs/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/build +/dist
git_remote_cvs/Makefile new file +35 -0
@@ -0,0 +1,35 @@ +# +# Makefile for the git_remote_cvs python support modules +# +pysetupfile:=setup.py + +# Shell quote (do not use $(call) to accommodate ancient setups); +DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) + +ifndef PYTHON_PATH + PYTHON_PATH = /usr/bin/python +endif +ifndef prefix + prefix = $(HOME) +endif +ifndef V + QUIET = @ + QUIETSETUP = --quiet +endif + +PYLIBDIR=$(shell $(PYTHON_PATH) -c \ + "import sys; \ + print 'lib/python%i.%i/site-packages' % sys.version_info[:2]") + +all: $(pysetupfile) + $(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) build + +install: $(pysetupfile) + $(PYTHON_PATH) $(pysetupfile) install --prefix $(DESTDIR_SQ)$(prefix) + +instlibdir: $(pysetupfile) + @echo "$(prefix)/$(PYLIBDIR)" + +clean: + $(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) clean -a + $(RM) *.pyo *.pyc
git_remote_cvs/__init__.py new file +27 -0
@@ -0,0 +1,27 @@ +#!/usr/bin/env python + +"""Support library package for git-remote-cvs. + +git-remote-cvs is a Git remote helper command that interfaces with a +CVS repository to provide automatic import of CVS history into a Git +repository. + +This package provides the support library needed by git-remote-cvs. +The following modules are included: + +- cvs - Interaction with CVS repositories + +- cvs_symbol_cache - Local CVS symbol cache + +- changeset - Collect individual CVS revisions into commits + +- git - Interaction with Git repositories + +- commit_states - Map Git commits to CVS states + +- cvs_revision_map - Map CVS revisions to various metainformation + +- util - General utility functionality use by the other modules in + this package, and also used directly by git-remote-cvs. + +"""
git_remote_cvs/commit_states.py new file +62 -0
62 lines not on this page · raw message
git_remote_cvs/cvs_revision_map.py new file +418 -0
418 lines not on this page · raw message
git_remote_cvs/git.py new file +680 -0
680 lines not on this page · raw message
git_remote_cvs/setup.py new file +17 -0
@@ -0,0 +1,17 @@ +#!/usr/bin/env python + +"""Distutils build/install script for the git_remote_cvs package.""" + +from distutils.core import setup + +setup( + name = 'git_remote_cvs', + version = '0.1.0', + description = 'Git remote helper program for CVS repositories', + license = 'GPLv2', + author = 'The Git Community', + author_email = '[email protected]', + url = 'http://www.git-scm.com/', + package_dir = {'git_remote_cvs': ''}, + packages = ['git_remote_cvs'], +)
Signature · 1 line
1.6.4.262.gca66a.dirty
Re: [RFCv4 3/5] 2/2: Add Python support library for CVS remote helper
Heya,
Quoted 3 lines · Johan Herland
This patch introduces the rest of a Python package called "
git_remote_cvs" containing the building blocks of the CVS remote helper. The CVS remote helper itself is NOT part of this patch.
Might I suggest that we pool our efforts and instead create a structure like:
git_remote_helpers/git_remote_helpers/__init__.py
git_remote_helpers/Makefilegit_remote_helpers/setup.pygit_remote_helpers/util.py
git_remote_helpers/gitgit_remote_helpers/git/__init__.py
git_remote_helpers/git/
git_remote_helpers/cvsgit_remote_helpers/cvs/__init__.pygit_remote_helpers/cvs/changeset.pygit_remote_helpers/cvs/commit_states.pygit_remote_helpers/cvs/cvs.pygit_remote_helpers/cvs/revision_map.pygit_remote_helpers/cvs/symbol_cache.py
git_remote_helpers/hggit_remote_helpers/hg/__init__.pygit_remote_helpers/hg/hg.pygit_remote_helpers/hg/export.py
I'm willing to spend some time to do the needed refactoring, but IIUC Daniel said that you need to reroll the cvs series anyway?
Signature · 3 lines
Cheers, Sverre Rabbelier
Re: [RFCv4 3/5] 2/2: Add Python support library for CVS remote helper
Quoted 19 lines · Sverre Rabbelier
Quoted 3 lines · Johan Herland
This patch introduces the rest of a Python package called "
git_remote_cvs" containing the building blocks of the CVS remote helper. The CVS remote helper itself is NOT part of this patch.Might I suggest that we pool our efforts and instead create a structure like:
git_remote_helpers/
git_remote_helpers/__init__.py
git_remote_helpers/Makefilegit_remote_helpers/setup.pygit_remote_helpers/util.py
git_remote_helpers/gitgit_remote_helpers/git/__init__.py
git_remote_helpers/git/
git_remote_helpers/cvsgit_remote_helpers/cvs/__init__.pygit_remote_helpers/cvs/changeset.py
Quoted 8 lines
git_remote_helpers/cvs/commit_states.pygit_remote_helpers/cvs/cvs.pygit_remote_helpers/cvs/revision_map.pygit_remote_helpers/cvs/symbol_cache.py
git_remote_helpers/hggit_remote_helpers/hg/__init__.pygit_remote_helpers/hg/hg.pygit_remote_helpers/hg/export.py
I like this. One couple of questions (for now):
- Are you planning to share directory structure only, or some of the Python code as well? From the above structure it seems like you want to make use of e.g. util.py and git.py. I'd be delighted if the code is reusable by other remote helpers.
- Do you plan to put the remote helpers into this structure as well, or keep them separate? (currently the cvs remote helper lives separately in git-remote-cvs.py in the project root directory)
Quoted 2 lines
I'm willing to spend some time to do the needed refactoring, but IIUC Daniel said that you need to reroll the cvs series anyway?
Yeah, a re-roll was planned once the sr/gfi-options work was finalized. (right now I'm mostly focused on the jh/notes work). Feel free to post the hg-specific and/or common parts as a separate patch, and I can rebase the CVS series on top of that before I submit the next iteration.
Nice to see people starting to pick up the foreign-vcs work. :)
Have fun! :)
...Johan
Signature · 2 lines
Johan Herland, <[email protected]> www.herland.net
Re: [RFCv4 3/5] 2/2: Add Python support library for CVS remote helper
Heya,
Quoted 4 lines · Johan Herland
- Are you planning to share directory structure only, or some of the Python code as well? From the above structure it seems like you want to make use of e.g.
util.pyandgit.py. I'd be delighted if the code is reusable by other remote helpers.
Yes, the main reason I suggested this was because I want to reuse util.py and git.py :). Of course, it'd probably be cleaner to move the little CVS-specific code that is in git.py atm out of it.
Quoted 3 lines
- Do you plan to put the remote helpers into this structure as well, or keep them separate? (currently the cvs remote helper lives separately in
git-remote-cvs.pyin the project root directory)
I think it's good where it is right now, and I've also placed git-remote-hg.py in the root directory.
Quoted 8 lines
Quoted 2 lines
I'm willing to spend some time to do the needed refactoring, but IIUC Daniel said that you need to reroll the cvs series anyway?
Yeah, a re-roll was planned once the sr/gfi-options work was finalized. (right now I'm mostly focused on the jh/notes work). Feel free to post the hg-specific and/or common parts as a separate patch, and I can rebase the CVS series on top of that before I submit the next iteration.
Yeah, I'm waiting on Shawn to decide what should be done with the whole options thing before I resubmit sr/gfi-options.
Quoted 1 line
Nice to see people starting to pick up the foreign-vcs work. :)
Now if only we could bribe Eric to write a svn helper :).
Signature · 3 lines
Cheers, Sverre Rabbelier
Re: [RFCv4 3/5] 2/2: Add Python support library for CVS remote helper
Quoted 9 lines · Sverre Rabbelier
Quoted 4 lines · Johan Herland
- Are you planning to share directory structure only, or some of the Python code as well? From the above structure it seems like you want to make use of e.g.
util.pyandgit.py. I'd be delighted if the code is reusable by other remote helpers.Yes, the main reason I suggested this was because I want to reuse
util.pyandgit.py:). Of course, it'd probably be cleaner to move the little CVS-specific code that is ingit.pyatm out of it.
Sure. Refactor away. :)
Quoted 6 lines
Quoted 3 lines
- Do you plan to put the remote helpers into this structure as well, or keep them separate? (currently the cvs remote helper lives separately in
git-remote-cvs.pyin the project root directory)I think it's good where it is right now, and I've also placed
git-remote-hg.pyin the root directory.
Ok.
...Johan
Signature · 2 lines
Johan Herland, <[email protected]> www.herland.net
RFC v4 4/5 git-remote-cvs: Remote helper program for CVS repositories
In reply to Johan HerlandImplements the import of objects from a local or remote CVS repository.
This helper program uses the "git_remote_cvs" Python package introduced earlier, and provides a working draft implementation of the remote helper API, as described in Documentation/git-remote-helpers.txt. Further details about this specific helper are described in the new Documentation/git-remote-cvs.txt.
This patch has been improved by the following contributions:
- Daniel Barkalow: Updates reflecting changes in remote helper API
- David Aguilar: Lots of Python coding style fixes
--- Documentation/git-remote-cvs.txt | 85 +++++ Makefile | 24 ++ git-remote-cvs.py | 683 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 792 insertions(+), 0 deletions(-) create mode 100644 Documentation/git-remote-cvs.txt create mode 100755 git-remote-cvs.py
Documentation/git-remote-cvs.txt new file +85 -0
@@ -0,0 +1,85 @@ +git-remote-cvs(1) +================= + +NAME +---- +git-remote-cvs - Helper program for interoperation with CVS repositories + +SYNOPSIS +-------- +'git remote-cvs' <remote> + +DESCRIPTION +----------- + +Please see the linkgit:git-remote-helpers[1] documentation for general +information about remote helper programs. + +CONFIGURATION +------------- + +remote.*.cvsRoot:: + The URL of the CVS repository (as found in a `CVSROOT` variable, or + in a `CVS/Root` file). + Example: "`:pserver:user@server/var/cvs/cvsroot`". + +remote.*.cvsModule:: + The path of the CVS module (as found in a `CVS/Repository` file) + within the CVS repository specified in `remote.*.cvsRoot`. + Example: "`foo/bar`" + +remote.*.cachedSymbolsOnly:: + When 'true', a cache of CVS symbols is used instead of querying the + CVS server for all existing symbols (potentially expensive). In this + mode, git-remote-cvs will not discover new CVS symbols unless you add + them explicitly with the "`addsymbol <symbol>`" command (on + git-remote-cvs's stdin), or request an explicit symbol cache update + from the CVS server with the "`syncsymbols`" command (on + git-remote-cvs's stdin). When 'false' (the default), the CVS server + will be queried whenever a list of CVS symbols is required. + +remote.*.usernameMap:: + The path (absolute, or relative to the repository (NOT the worktree)) + to the file that contains the mapping from CVS usernames to the + corresponding full names and email addresses, as used by Git in the + Author and Committer fields of commit objects. When this config + variable is set, CVS usernames will be resolved against this file. + If no match is found in the file, or if this config variable is unset, + or if the variable points to a non-existing file, the original CVS + username will be used as the Author/Committer name, and the + corresponding email address will be set to "`<username>@example.com`". ++ +The format of the usernameMap file is one entry per line, where each line is +of the form "`username: Full Name <email@address>`". +Example: `johndoe: John Doe <[email protected]>` +Blank lines and lines starting with '#' are ignored. + +COMMANDS +-------- + +In addition to the commands that constitute the git-remote-helpers API, the +following extra commands are supported for managing the local symbol cache when +the `remote.*.cachedSymbolsOnly` config variable is true. The following +commands can be given on the standard input of git-remote-cvs: + +'addsymbol':: + Takes one CVS symbol name as argument. The given CVS symbol is + fetched from the CVS server and stored into the local CVS symbol + cache. If `remote.*.cachedSymbolsOnly` is enabled, this can be used + to introduce a new CVS symbol to the CVS helper application. + +'syncsymbols':: + All CVS symbols that are available from the given remote are + fetched from the CVS server and stored into the local CVS symbol + cache. This is equivalent to disabling `remote.{asterisk}.cachedSymbolsOnly`, + running the "list" command, and then finally re-enabling the + `remote.*.cachedSymbolsOnly` config variable. I.e. this command can + be used to manually synchronize the CVS symbols available to the + CVS helper application. + +'verify':: + Takes one CVS symbol name as argument. Verifies that the CVS symbol + has been successfully imported be checking out the CVS symbol from + the CVS server, and comparing the CVS working tree against the Git + tree object identified by `refs/cvs/<remote>/<symbol>`. This can be + used to verify the correctness of a preceding 'import' command.
Makefile +24 -0
@@ -350,6 +350,8 @@ SCRIPT_PERL += git-relink.perl SCRIPT_PERL += git-send-email.perl SCRIPT_PERL += git-svn.perl +SCRIPT_PYTHON += git-remote-cvs.py + SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ $(patsubst %.perl,%,$(SCRIPT_PERL)) \ $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
@@ -1474,6 +1476,28 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh mv $@+ $@ endif # NO_PERL +ifndef NO_PYTHON +$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py + $(QUIET_GEN)$(RM) $@ $@+ && \ + INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_cvs -s --no-print-directory instlibdir` && \ + sed -e '1{' \ + -e ' s|#!.*python|#!$(PYTHON_PATH_SQ)|' \ + -e '}' \ + -e 's|^import sys.*|&; sys.path.insert(0, "@@INSTLIBDIR@@")|' \ + -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \ + [email protected] >$@+ && \ + chmod +x $@+ && \ + mv $@+ $@ +else # NO_PYTHON +$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : unimplemented.sh + $(QUIET_GEN)$(RM) $@ $@+ && \ + sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ + -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \ + unimplemented.sh >$@+ && \ + chmod +x $@+ && \ + mv $@+ $@ +endif # NO_PYTHON + configure: configure.ac $(QUIET_GEN)$(RM) $@ $<+ && \ sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
git-remote-cvs.py new file +683 -0
683 lines not on this page · raw message
Signature · 1 line
1.6.4.262.gca66a.dirty
RFC v4 5/5 Add simple selftests of git-remote-cvs functionality
In reply to Johan HerlandAdd two new selftests:
- t9800-remote-cvs-basic: Test the git-remote-cvs implementation of the remote helper API, by verifying the expected output of the git-remote-cvs program when invoking remote helper API commands while doing some simple CVS operations.
- t9801-remote-cvs-fetch: A more high-level test of the fetch/import-side of the git-remote-cvs implementation, by verifying the expected repository state after doing "git fetch" from a CVS remote where a variety of CVS operations are being performed.
--- t/t9800-remote-cvs-basic.sh | 524 +++++++++++++++++++++++++++++++++++++++++++ t/t9801-remote-cvs-fetch.sh | 291 ++++++++++++++++++++++++ 2 files changed, 815 insertions(+), 0 deletions(-) create mode 100755 t/t9800-remote-cvs-basic.sh create mode 100755 t/t9801-remote-cvs-fetch.sh
t/t9800-remote-cvs-basic.sh new file +524 -0
@@ -0,0 +1,524 @@ +#!/bin/sh + +test_description='git remote-cvs basic tests' +. ./test-lib.sh + +if ! test_have_prereq PYTHON; then + say 'skipping CVS foreign-vcs helper tests, python not available' + test_done +fi + +CVS_EXEC=cvs +CVS_OPTS="-f -q" +CVS="$CVS_EXEC $CVS_OPTS" + +CVSROOT=$(pwd)/cvsroot +export CVSROOT +unset CVS_SERVER + +CVSMODULE=cvsmodule +GITREMOTE=cvsremote + +if ! type $CVS_EXEC >/dev/null 2>&1 +then + say 'skipping remote-cvs tests, $CVS_EXEC not found' + test_done +fi + +test_expect_success 'setup cvsroot' '$CVS init' + +test_expect_success '#1: setup a cvs module' ' + + mkdir "$CVSROOT/$CVSMODULE" && + $CVS co -d module-cvs $CVSMODULE && + ( + cd module-cvs && + cat <<EOF >o_fortuna && +O Fortuna +velut luna +statu variabilis, + +semper crescis +aut decrescis; +vita detestabilis + +nunc obdurat +et tunc curat +ludo mentis aciem, + +egestatem, +potestatem +dissolvit ut glaciem. +EOF + $CVS add o_fortuna && + cat <<EOF >message && +add "O Fortuna" lyrics + +These public domain lyrics make an excellent sample text. +EOF + $CVS commit -f -F message o_fortuna + ) +' + +test_expect_success 'set up CVS repo as a foreign remote' ' + + git config "user.name" "Test User" + git config "user.email" "[email protected]" + git config "remote.$GITREMOTE.vcs" cvs + git config "remote.$GITREMOTE.cvsRoot" "$CVSROOT" + git config "remote.$GITREMOTE.cvsModule" "$CVSMODULE" + git config "remote.$GITREMOTE.fetch" \ + "+refs/cvs/$GITREMOTE/*:refs/remotes/$GITREMOTE/*" + +' + +test_expect_success '#1: git-remote-cvs "capabilities" command' ' + + echo "capabilities" | git remote-cvs "$GITREMOTE" > actual && + cat <<EOF >expect && +import +marks .git/info/cvs/$GITREMOTE/marks + +EOF + test_cmp expect actual + +' + +test_expect_success '#1: git-remote-cvs "list" command' ' + + echo "list" | git remote-cvs "$GITREMOTE" > actual && + cat <<EOF >expect && +? refs/cvs/$GITREMOTE/HEAD + +EOF + test_cmp expect actual + +' + +test_expect_success '#1: git-remote-cvs "import" command' ' + + echo "import refs/cvs/$GITREMOTE/HEAD" | git remote-cvs "$GITREMOTE" > actual && + cat <<EOF >expect && +# Importing CVS revision o_fortuna:1.1 +blob +mark :1 +data 180 +O Fortuna +velut luna +statu variabilis, + +semper crescis +aut decrescis; +vita detestabilis + +nunc obdurat +et tunc curat +ludo mentis aciem, + +egestatem, +potestatem +dissolvit ut glaciem. + +commit refs/cvs/$GITREMOTE/HEAD +mark :2 +data 82 +add "O Fortuna" lyrics + +These public domain lyrics make an excellent sample text. + +M 644 :1 o_fortuna + +# Importing note for object 2 +blob +mark :3 +data 14 +o_fortuna:1.1 + +commit refs/notes/cvs/$GITREMOTE +mark :4 +data 46 +Annotate commits imported by "git remote-cvs" + +N :3 :2 + +blob +mark :5 +data 32 +1 o_fortuna:1.1 +2 o_fortuna:1.1 + +blob +mark :6 +data 16 +blob 1 +commit 2 + +commit refs/cvs/$GITREMOTE/_metadata +mark :7 +data 42 +Updated metadata used by "git remote-cvs" + +M 644 :5 CVS/marks +M 644 :6 o_fortuna/1.1 + +EOF + grep -v "^committer " actual > actual.filtered && + test_cmp expect actual.filtered + +' + +test_expect_success '#1: Passing git-remote-cvs output to git-fast-import' ' + + git fast-import --quiet \ + --export-marks=".git/info/cvs/$GITREMOTE/marks" \ + < actual && + git gc + +' + +test_expect_success '#1: Verifying correctness of import' ' + + echo "verify HEAD" | git remote-cvs "$GITREMOTE" + +' + +test_expect_success '#2: update cvs module' ' + + ( + cd module-cvs && + cat <<EOF >o_fortuna && +O Fortune, +like the moon +you are changeable, + +ever waxing +and waning; +hateful life + +first oppresses +and then soothes +as fancy takes it; + +poverty +and power +it melts them like ice. +EOF + cat <<EOF >message && +translate to English + +My Latin is terrible. +EOF + $CVS commit -f -F message o_fortuna + ) +' + +test_expect_success '#2: git-remote-cvs "capabilities" command' ' + + echo "capabilities" | git remote-cvs "$GITREMOTE" > actual && + cat <<EOF >expect && +import +marks .git/info/cvs/$GITREMOTE/marks + +EOF + test_cmp expect actual + +' + +test_expect_success '#2: git-remote-cvs "list" command' ' + + echo "list" | git remote-cvs "$GITREMOTE" > actual && + cat <<EOF >expect && +? refs/cvs/$GITREMOTE/HEAD + +EOF + test_cmp expect actual + +' + +test_expect_success '#2: git-remote-cvs "import" command' ' + + echo "import refs/cvs/$GITREMOTE/HEAD" | git remote-cvs "$GITREMOTE" > actual && + cat <<EOF >expect && +# Importing CVS revision o_fortuna:1.2 +blob +mark :8 +data 179 +O Fortune, +like the moon +you are changeable, + +ever waxing +and waning; +hateful life + +first oppresses +and then soothes +as fancy takes it; + +poverty +and power +it melts them like ice. + +commit refs/cvs/$GITREMOTE/HEAD +mark :9 +data 44 +translate to English + +My Latin is terrible. + +from refs/cvs/$GITREMOTE/HEAD^0 +M 644 :8 o_fortuna + +# Importing note for object 9 +blob +mark :10 +data 14 +o_fortuna:1.2 + +commit refs/notes/cvs/$GITREMOTE +mark :11 +data 46 +Annotate commits imported by "git remote-cvs" + +from refs/notes/cvs/$GITREMOTE^0 +N :10 :9 + +blob +mark :12 +data 32 +8 o_fortuna:1.2 +9 o_fortuna:1.2 + +blob +mark :13 +data 94 + +blob +mark :14 +data 16 +blob 8 +commit 9 + +commit refs/cvs/$GITREMOTE/_metadata +mark :15 +data 42 +Updated metadata used by "git remote-cvs" + +from refs/cvs/$GITREMOTE/_metadata^0 +M 644 :12 CVS/marks +M 644 :13 o_fortuna/1.1 +M 644 :14 o_fortuna/1.2 + +EOF + grep -v -e "^committer " -e "\b[0-9a-f]\{40\}\b" actual > actual.filtered && + test_cmp expect actual.filtered + +' + +test_expect_success '#2: Passing git-remote-cvs output to git-fast-import' ' + + git fast-import --quiet \ + --import-marks=".git/info/cvs/$GITREMOTE/marks" \ + --export-marks=".git/info/cvs/$GITREMOTE/marks" \ + < actual && + git gc + +' + +test_expect_success '#2: Verifying correctness of import' ' + + echo "verify HEAD" | git remote-cvs "$GITREMOTE" + +' + +test_expect_success '#3: update cvs module' ' + + ( + cd module-cvs && + echo 1 >tick && + $CVS add tick && + $CVS commit -f -m 1 tick + ) + +' + +test_expect_success '#3: git-remote-cvs "capabilities" command' ' + + echo "capabilities" | git remote-cvs "$GITREMOTE" > actual && + cat <<EOF >expect && +import +marks .git/info/cvs/$GITREMOTE/marks + +EOF + test_cmp expect actual + +' + +test_expect_success '#3: git-remote-cvs "list" command' ' + + echo "list" | git remote-cvs "$GITREMOTE" > actual && + cat <<EOF >expect && +? refs/cvs/$GITREMOTE/HEAD + +EOF + test_cmp expect actual + +' + +test_expect_success '#3: git-remote-cvs "import" command' ' + + echo "import refs/cvs/$GITREMOTE/HEAD" | git remote-cvs "$GITREMOTE" > actual && + cat <<EOF >expect && +# Importing CVS revision tick:1.1 +blob +mark :16 +data 2 +1 + +commit refs/cvs/$GITREMOTE/HEAD +mark :17 +data 2 +1 + +from refs/cvs/$GITREMOTE/HEAD^0 +M 644 :16 tick + +# Importing note for object 17 +blob +mark :18 +data 23 +o_fortuna:1.2 +tick:1.1 + +commit refs/notes/cvs/$GITREMOTE +mark :19 +data 46 +Annotate commits imported by "git remote-cvs" + +from refs/notes/cvs/$GITREMOTE^0 +N :18 :17 + +blob +mark :20 +data 41 +16 tick:1.1 +17 tick:1.1 +17 o_fortuna:1.2 + +blob +mark :21 +data 104 +commit 17 + +blob +mark :22 +data 18 +blob 16 +commit 17 + +commit refs/cvs/$GITREMOTE/_metadata +mark :23 +data 42 +Updated metadata used by "git remote-cvs" + +from refs/cvs/$GITREMOTE/_metadata^0 +M 644 :20 CVS/marks +M 644 :21 o_fortuna/1.2 +M 644 :22 tick/1.1 + +EOF + grep -v -e "^committer " -e "\b[0-9a-f]\{40\}\b" actual > actual.filtered && + test_cmp expect actual.filtered + +' + +test_expect_success '#3: Passing git-remote-cvs output to git-fast-import' ' + + git fast-import --quiet \ + --import-marks=".git/info/cvs/$GITREMOTE/marks" \ + --export-marks=".git/info/cvs/$GITREMOTE/marks" \ + < actual && + git gc + +' + +test_expect_success '#3: Verifying correctness of import' ' + + echo "verify HEAD" | git remote-cvs "$GITREMOTE" + +' + +test_expect_success '#4: git-remote-cvs "capabilities" command' ' + + echo "capabilities" | git remote-cvs "$GITREMOTE" > actual && + cat <<EOF >expect && +import +marks .git/info/cvs/$GITREMOTE/marks + +EOF + test_cmp expect actual + +' + +commit=$(git rev-parse "refs/cvs/$GITREMOTE/HEAD") + +test_expect_success '#4: git-remote-cvs "list" command' ' + + echo "list" | git remote-cvs "$GITREMOTE" > actual && + cat <<EOF >expect && +$commit refs/cvs/$GITREMOTE/HEAD unchanged + +EOF + test_cmp expect actual + +' + +test_expect_success '#4: git-remote-cvs "import" command' ' + + echo "import refs/cvs/$GITREMOTE/HEAD" | git remote-cvs "$GITREMOTE" > actual && + cat <<EOF >expect && +blob +mark :24 +data 0 + +blob +mark :25 +data 142 + +blob +mark :26 +data 94 + +commit refs/cvs/$GITREMOTE/_metadata +mark :27 +data 42 +Updated metadata used by "git remote-cvs" + +from refs/cvs/$GITREMOTE/_metadata^0 +M 644 :24 CVS/marks +M 644 :25 o_fortuna/1.2 +M 644 :26 tick/1.1 + +EOF + grep -v -e "^committer " -e "\b[0-9a-f]\{40\}\b" actual > actual.filtered && + test_cmp expect actual.filtered + +' + +test_expect_success '#4: Passing git-remote-cvs output to git-fast-import' ' + + git fast-import --quiet \ + --import-marks=".git/info/cvs/$GITREMOTE/marks" \ + --export-marks=".git/info/cvs/$GITREMOTE/marks" \ + < actual && + git gc + +' + +test_expect_success '#4: Verifying correctness of import' ' + + echo "verify HEAD" | git remote-cvs "$GITREMOTE" + +' + +test_done
t/t9801-remote-cvs-fetch.sh new file +291 -0
291 lines not on this page · raw message
Signature · 1 line
1.6.4.262.gca66a.dirty
[RFCv4 6/5] Fix the Makefile-generated path to the git_remote_cvs package in git-remote-cvs
In reply to Johan HerlandJunio discovered that the installed git-remote-cvs executable is unable to find the installed git_remote_cvs Python package. This is due to the 'instlibdir' target of git_remote_cvs/Makefile being invoked with insufficient arguments (prefix and DESTDIR). This patch fixes that.
---
Sorry for the inconvenience.
...Johan
Makefile | 2 +- git_remote_cvs/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Makefile +1 -1
@@ -1479,7 +1479,7 @@ endif # NO_PERL ifndef NO_PYTHON $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py $(QUIET_GEN)$(RM) $@ $@+ && \ - INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_cvs -s --no-print-directory instlibdir` && \ + INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_cvs -s --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' instlibdir` && \ sed -e '1{' \ -e ' s|#!.*python|#!$(PYTHON_PATH_SQ)|' \ -e '}' \
git_remote_cvs/Makefile +1 -1
@@ -28,7 +28,7 @@ install: $(pysetupfile) $(PYTHON_PATH) $(pysetupfile) install --prefix $(DESTDIR_SQ)$(prefix) instlibdir: $(pysetupfile) - @echo "$(prefix)/$(PYLIBDIR)" + @echo "$(DESTDIR_SQ)$(prefix)/$(PYLIBDIR)" clean: $(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) clean -a
Signature · 6 lines
1.6.4.313.g38b9.dirty -- Johan Herland, <[email protected]> www.herland.net
[RFCv4 7/5] More fixes to the git-remote-cvs installation procedure
In reply to Johan Herland- Makefile: Make sure git-remote-cvs is rebuilt when 'prefix' changes (by adding a dependency on GIT-CFLAGS). This prevents a regular 'make' followed by a 'make prefix=/somewhere/else install' from installing a non-working git-remote-cvs.
- Makefile: When mangling git-remote-cvs to add the git_remote_cvs install location to the Python search path, _replace_ the initial 'current dir' entry in sys.path (instead of merely prepending the install location). Hence, if the git_remote_cvs package is not installed at the correct location (and also not present in any of Python's default package dirs), then git-remote-cvs will fail loudly instead of silently falling back on the git_remote_cvs subdir in git.git.
- Allow for the git_remote_cvs install path to be overridden by the $GITPYTHONLIB environment variable.
- t/test-lib.sh: Set $GITPYTHONLIB (unless $GIT_TEST_INSTALLED is enabled) so that we test the currently built version of git_remote_cvs (the one that is built in git_remote_cvs/build/lib) instead of a previously installed version.
- Another minor check and a line length fix.
---
Quoted 9 lines · Junio C Hamano
With your
Makefilepatch the test still failed. It turns out that I had a broken version from the previous round installed in my PATH, and the test failed until I removed the faulty ones manually from the installed location. This is not good.While running tests, we really should import from the build directory, preferrably ignoring the installed directory but at least giving precedence to the build directory over the installed directory, to avoid problems like this.
Agreed. This patch puts the build directory first in Python's search path when running the testsuite (unless $GIT_TEST_INSTALLED is enabled). The install directory is ignored (unless the install dir happens to be in Python's default search path, in which case the build dir will still have precedence).
Quoted 5 lines
In my case, it was a "bad installed version masking the version we are testing", but a more problematic would be the other way around. If you have a good version installed, and if somebody breaks it in the updated source, "make test" won't catch the breakage and then you "make install" a broken version without noticing.
Yes. This is also taken care of in this patch ('make test' sets $GITPYTHONLIB, which forces git-remote-cvs to look for its package in the build dir instead of the install dir).
This patch (and the previous 6/5) will be folded into the next iteration of the jh/cvs-helper patch series.
...Johan
Makefile | 11 +++++++++-- t/test-lib.sh | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-)
Makefile +9 -2
@@ -1477,13 +1477,20 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh endif # NO_PERL ifndef NO_PYTHON +$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py $(QUIET_GEN)$(RM) $@ $@+ && \ - INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_cvs -s --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' instlibdir` && \ + INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_cvs -s \ + --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \ + instlibdir` && \ sed -e '1{' \ -e ' s|#!.*python|#!$(PYTHON_PATH_SQ)|' \ -e '}' \ - -e 's|^import sys.*|&; sys.path.insert(0, "@@INSTLIBDIR@@")|' \ + -e 's|^import sys.*|&; \\\ + import os; \\\ + sys.path[0] = os.environ.has_key("GITPYTHONLIB") and \\\ + os.environ["GITPYTHONLIB"] or \\\ + "@@INSTLIBDIR@@"|' \ -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \ [email protected] >$@+ && \ chmod +x $@+ && \
t/test-lib.sh +9 -0
@@ -638,6 +638,15 @@ test -d ../templates/blt || { error "You haven't built things yet, have you?" } +if test -z "$GIT_TEST_INSTALLED" +then + GITPYTHONLIB="$(pwd)/../git_remote_cvs/build/lib" + export GITPYTHONLIB + test -d ../git_remote_cvs/build || { + error "You haven't built git_remote_cvs yet, have you?" + } +fi + if ! test -x ../test-chmtime; then echo >&2 'You need to build test-chmtime:' echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
Signature · 1 line
1.6.4.304.g1365c.dirty