CVS remote helper
Subsystems (2)
v3 cover CVS remote helper
Hi,
Another iteration of the patch series implementing a CVS remote helper, as promised a couple of days ago. Changes from the previous iteration:
- Rebased on top of Daniel Barkalow's latest foreign VCS helpers work (aka. 'db/vcs-helper' (early part)). This means that all the "generic" foreign-scm patches that were part of the previous iteration are no longer needed, and only the CVS remote helper patches remain. Also, this series applies cleanly to current 'pu'.
- Replaced the "git-vcs-cvs" naming with "git-remote-cvs" throughout the code and documentation.
- Minor updates to the git-remote-cvs implementation in order to more closely follow the current remote helper API.
- Split up the patch series into somewhat smaller patches to (hopefully) be allowed onto [email protected].
Have fun! :)
...Johan
Johan Herland (4):
Basic build infrastructure for Python scripts Add Python support library for CVS remote helper Third draft of CVS remote helper program Add simple selftests of git-remote-cvs functionality
Documentation/git-remote-cvs.txt | 85 ++++ Makefile | 46 ++ configure.ac | 3 + git-remote-cvs.py | 697 ++++++++++++++++++++++++++++ git_remote_cvs/.gitignore | 2 + git_remote_cvs/Makefile | 27 ++ git_remote_cvs/changeset.py | 114 +++++ git_remote_cvs/commit_states.py | 52 +++ git_remote_cvs/cvs.py | 884 ++++++++++++++++++++++++++++++++++++ git_remote_cvs/cvs_revision_map.py | 362 +++++++++++++++ git_remote_cvs/cvs_symbol_cache.py | 283 ++++++++++++ git_remote_cvs/git.py | 586 ++++++++++++++++++++++++ git_remote_cvs/setup.py | 12 + git_remote_cvs/util.py | 147 ++++++ t/t9800-remote-cvs-basic.sh | 524 +++++++++++++++++++++ t/t9801-remote-cvs-fetch.sh | 291 ++++++++++++ t/test-lib.sh | 1 + 17 files changed, 4116 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 v3 1/4 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.rc3.138.ga6b98.dirty
RFC v3 2/4 Add Python support library for CVS remote helper
In reply to Johan HerlandThis patch introduces 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.
--- Makefile | 9 + git_remote_cvs/.gitignore | 2 + git_remote_cvs/Makefile | 27 ++ git_remote_cvs/changeset.py | 114 +++++ git_remote_cvs/commit_states.py | 52 +++ git_remote_cvs/cvs.py | 884 ++++++++++++++++++++++++++++++++++++ git_remote_cvs/cvs_revision_map.py | 362 +++++++++++++++ git_remote_cvs/cvs_symbol_cache.py | 283 ++++++++++++ git_remote_cvs/git.py | 586 ++++++++++++++++++++++++ git_remote_cvs/setup.py | 12 + git_remote_cvs/util.py | 147 ++++++ 11 files changed, 2478 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/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
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 +27 -0
@@ -0,0 +1,27 @@ +# +# Makefile for the git_remote_cvs python support modules +# +pysetupfile:=setup.py + +ifndef PYTHON_PATH + PYTHON_PATH = /usr/bin/python +endif +ifndef prefix + prefix = $(HOME) +endif +ifndef V + QUIET = @ + QUIETSETUP = --quiet +endif + +PYLIBDIR=`$(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 $(prefix) +instlibdir: $(pysetupfile) + @echo "$(prefix)/$(PYLIBDIR)" +clean: + $(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) clean -a + $(RM) *.pyo *.pyc
git_remote_cvs/__init__.py new file +0 -0
git_remote_cvs/changeset.py new file +114 -0
114 lines not on this page · raw message
git_remote_cvs/commit_states.py new file +52 -0
52 lines not on this page · raw message
git_remote_cvs/cvs.py new file +884 -0
884 lines not on this page · raw message
git_remote_cvs/cvs_revision_map.py new file +362 -0
362 lines not on this page · raw message
git_remote_cvs/cvs_symbol_cache.py new file +283 -0
283 lines not on this page · raw message
git_remote_cvs/git.py new file +586 -0
586 lines not on this page · raw message
git_remote_cvs/setup.py new file +12 -0
@@ -0,0 +1,12 @@ +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'], +)
git_remote_cvs/util.py new file +147 -0
147 lines not on this page · raw message
Signature · 1 line
1.6.4.rc3.138.ga6b98.dirty
Re: [RFCv3 2/4] Add Python support library for CVS remote helper
Quoted 3 lines · Johan Herland
This patch introduces 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.
Interesting...
Quoted 9 lines
git_remote_cvs/changeset.py new file +3
-0@@ -0,0 +1,114 @@ +#!/usr/bin/env python + +"""Functionality for collecting individual CVS revisions into "changesets"
git_remote_cvs/changeset.py line 13
Quoted 10 lines
git_remote_cvs/changeset.py new file +10
-0+ +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 util import *
Importing * is frowned upon in Python.
It's much easier to see where things are coming from if you 'import util' and use the namespaced util.foo() way of accessing the functions.
Furthermore, you're going to want to use absolute imports. Anyone can create 'util.py' and blindly importing 'util' is asking for trouble.
Instead use:
from git_remote_cvs import util
git_remote_cvs/changeset.py line 17
Quoted 2 lines
git_remote_cvs/changeset.py new file +2
-0+class Changeset (object): + """Encapsulate a single changeset/commit"""
I think it reads better as Changeset(object)
(drop the spaces before the parens).
That applies to the rest of this patch as well.
This also had me wondering about the following:
git uses tabs for indentation
BUT, the python convention is to use 4-space indents ala PEP-8
http://www.python.org/dev/peps/pep-0008/
It might be appealing to when-in-Rome (Rome being Python) here and do things the python way when we code in Python.
Consistency with pep8 is good if we expect to get python hackers to contribute to git_remote_cvs.
git_remote_cvs/changeset.py line 17
Quoted 2 lines
git_remote_cvs/changeset.py new file +2
-0+ + __slots__ = ('revs', 'date', 'author', 'message')
__slots__ is pretty esoteric in Python-land.
But, if your justification is to minimize memory usage, then yes, this is a good thing to do.
git_remote_cvs/changeset.py line 37
Quoted 5 lines
git_remote_cvs/changeset.py new file +5
-0+ def __init__ (self, date, author, message): + self.revs = {} # dict: path -> CvsRev object + self.date = date # CvsDate object + self.author = author + self.message = message # Lines of commit message
pep8 and other parts of the git codebase recommend against lining up the equals signs like that. Ya, sorry for the nits being that they're purely stylistic.
git_remote_cvs/changeset.py line 43
Quoted 3 lines
git_remote_cvs/changeset.py new file +3
-0+ if len(msg) > 25: msg = msg[:22] + "..." # Max 25 chars long + return "<Changeset @(%s) by %s (%s) updating %i files>" % ( + self.date, self.author, msg, len(self.revs))
Similar to the git coding style, this might be better written:
...
if len(msg) > 25:
msg = msg[:22] + '...' # Max 25 chars long
...
(aka avoid single-line ifs)
There's a few other instances of this in the patch as well.
git_remote_cvs/cvs.py line 127
Quoted 11 lines
git_remote_cvs/cvs.py new file +4
-0@@ -0,0 +1,884 @@ + + def enumerate (self): + """Return a list of integer components in this CVS number""" + return list(self.l)
enumerate has special meaning in Python.
items = (1, 2, 3, 4)
for idx, item in enumerate(items):
print idx, item
I'm not sure if this would cause confusion...
git_remote_cvs/cvs.py line 158
Quoted 3 lines
[...]
git_remote_cvs/cvs.py new file +2
-0+ else: # revision number + assert self.l[-1] > 0
asserts go away when running with PYTHONOPTIMIZE.
If this is really an error then we should we raise an exception instead?
git_remote_cvs/cvs.py line 248
Quoted 3 lines
git_remote_cvs/cvs.py new file +3
-0+ @classmethod + def test (cls): + assert cls("1.2.4") == cls("1.2.0.4")
Hmm.. Does it make more sense to use the unittest module?
e.g. self.assertEqual(foo, bar)
git_remote_cvs/cvs_revision_map.py line 7
Quoted 13 lines
git_remote_cvs/cvs_revision_map.py new file +7
-0@@ -0,0 +1,362 @@ +#!/usr/bin/env python + +"""Functionality for mapping CVS revisions to associated metainformation""" + +from util import * +from cvs import CvsNum, CvsDate +from git import GitFICommit, GitFastImport, GitObjectFetcher
We definitely need absolute imports here.
'import git' could find the git-python project's git module.
Nonetheless, interesting stuff.
Signature · 1 line
David
Re: [RFCv3 2/4] Add Python support library for CVS remote helper
First, thank you very much for the review. It is very helpful, and I really appreciate it.
Quoted 29 lines · David Aguilar
Quoted 3 lines · Johan Herland
This patch introduces 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.Interesting...
Quoted 17 lines
git_remote_cvs/changeset.py new file +3
-0@@ -0,0 +1,114 @@ +#!/usr/bin/env python + +"""Functionality 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.
+"""git_remote_cvs/changeset.py
Quoted 2 lines
git_remote_cvs/changeset.py new file +2
-0+ +from util import *Importing * is frowned upon in Python.
Quoted 3 lines
It's much easier to see where things are coming from if you 'import util' and use the namespaced
util.foo()way of accessing the functions.
I'd rather do "from util import X Y Z", as the util stuff is used all over the place.
Quoted 6 lines
Furthermore, you're going to want to use absolute imports. Anyone can create '
util.py' and blindly importing 'util' is asking for trouble.Instead use:
fromgit_remote_cvsimport util
I thought the python import rules specified that the current package was consulted first, and therefore the 'util' package would always come from the current package. However, I must confess that I don't know these rules very well, so I'll take your word for it and use absolute imports instead.
Quoted 7 lines
git_remote_cvs/changeset.py line 17
Quoted 2 lines
git_remote_cvs/changeset.py new file +2
-0+class Changeset (object): + """Encapsulate a single changeset/commit"""I think it reads better as Changeset(object)
(drop the spaces before the parens).That applies to the rest of this patch as well.
Ok. Will change.
Quoted 5 lines
This also had me wondering about the following:
git uses tabs for indentationBUT, the python convention is to use 4-space indents ala PEP-8
http://www.python.org/dev/peps/pep-0008/
Interesting. I have (obviously) never looked at PEP 8... :)
Quoted 5 lines
It might be appealing to when-in-Rome (Rome being Python) here and do things the python way when we code in Python.
Consistency with pep8 is good if we expect to get python hackers to contribute to
git_remote_cvs.
I see your point, but I believe that since git_remote_cvs is not an independent project (but very much coupled to git), its allegiance is with Git, and it should therefore follow the Git coding style. In other words, I claim exception (2) in PEP 8
Quoted 7 lines
git_remote_cvs/changeset.py
Quoted 2 lines
git_remote_cvs/changeset.py new file +2
-0+ + __slots__ = ('revs', 'date', 'author', 'message')
__slots__is pretty esoteric in Python-land.But, if your justification is to minimize memory usage, then yes, this is a good thing to do.
Yes, I only use __slots__ for classes that potentially have a large number of instances.
Quoted 9 lines
git_remote_cvs/changeset.py line 37
Quoted 5 lines
git_remote_cvs/changeset.py new file +5
-0+ def __init__ (self, date, author, message): + self.revs = {} # dict: path -> CvsRev object + self.date = date # CvsDate object + self.author = author + self.message = message # Lines of commit messagepep8 and other parts of the git codebase recommend against lining up the equals signs like that. Ya, sorry for the nits being that they're purely stylistic.
I can't find a good rationale for this rule in PEP8 (other than Guido's personal style), and I personally find the above much more readable (otherwise I wouldn't go through the trouble of lining them all up...). Can I claim exception (1) (readability)?
Quoted 6 lines
git_remote_cvs/changeset.py line 43
Quoted 3 lines
git_remote_cvs/changeset.py new file +3
-0+ if len(msg) > 25: msg = msg[:22] + "..." # Max 25 chars long + return "<Changeset @(%s) by %s (%s) updating %i files>" % ( + self.date, self.author, msg, len(self.revs))Similar to the git coding style, this might be better written:
Quoted 8 lines
...
if len(msg) > 25:msg = msg[:22] + '...' # Max 25 chars long...
(aka avoid single-line ifs)
There's a few other instances of this in the patch as well.
Ok. Will try to eliminate single-line ifs.
Quoted 14 lines
git_remote_cvs/cvs.py line 127
Quoted 11 lines
git_remote_cvs/cvs.py new file +4
-0@@ -0,0 +1,884 @@ + + def enumerate (self): + """Return a list of integer components in this CVS number""" + return list(self.l)enumerate has special meaning in Python.
Quoted 6 lines
items = (1, 2, 3, 4)
for idx, item in enumerate(items):
print idx, itemI'm not sure if this would cause confusion...
Good point, I should probably rename this method.
Quoted 8 lines
git_remote_cvs/cvs.py line 158
Quoted 3 lines
[...]
git_remote_cvs/cvs.py new file +2
-0+ else: # revision number + assert self.l[-1] > 0asserts go away when running with PYTHONOPTIMIZE.
If this is really an error then we should we raise an exception instead?
I use asserts to verify pre/post-conditions and other invariants. I believe that if this assert fails, it is indicative of something horribly wrong with the code itself. However, I now see that one can also trigger this case with bad input (e.g. CvsNum("1.2.3.0").parent()). I will keep the assert here, but will also add some input verification to the CvsNum class.
Quoted 7 lines
git_remote_cvs/cvs.py line 248
Quoted 3 lines
git_remote_cvs/cvs.py new file +3
-0+ @classmethod + def test (cls): + assert cls("1.2.4") == cls("1.2.0.4")Hmm.. Does it make more sense to use the unittest module?
e.g.
self.assertEqual(foo, bar)
Probably. I'm not familiar with 'unittest', but will take a look.
Quoted 16 lines
git_remote_cvs/cvs_revision_map.py line 7
Quoted 13 lines
(quoted diff) +0
-0
b/git_remote_cvs/cvs_revision_map.pynew file mode 100644 index 0000000..7d7810fgit_remote_cvs/cvs_revision_map.py new file +3
-0@@ -0,0 +1,362 @@ +#!/usr/bin/env python + +"""Functionality for mapping CVS revisions to associatedmetainformation""" +
git_remote_cvs/cvs_revision_map.py new file +3
-0+from util import * +from cvs import CvsNum, CvsDate +from git import GitFICommit, GitFastImport, GitObjectFetcherWe definitely need absolute imports here.
Quoted 1 line
'import git' could find the git-python project's git module.
Ok. Will fix.
Quoted 1 line
Nonetheless, interesting stuff.
Thanks for the review!
Have fun! :)
...Johan
Signature · 2 lines
Johan Herland, <[email protected]> www.herland.net
Re: [RFCv3 2/4] Add Python support library for CVS remote helper
Heya,
Quoted 4 lines · Johan Herland
I can't find a good rationale for this rule in PEP8 (other than Guido's personal style), and I personally find the above much more readable (otherwise I wouldn't go through the trouble of lining them all up...). Can I claim exception (1) (readability)?
Working with python a lot myself, if you want to claim readability _to python hackers_, then you should follow PEP8. If you want to follow your own personal style which is easily readable to you, then by all means; just know that people that read python a lot will have a hard time reading your code ;).
Signature · 3 lines
Cheers, Sverre Rabbelier
Re: [RFCv3 2/4] Add Python support library for CVS remote helper
In reply to Johan HerlandQuoted 11 lines · Johan Herland
Quoted 9 lines · David Aguilar
git_remote_cvs/changeset.py line 37
Quoted 5 lines · Johan Herland
git_remote_cvs/changeset.py new file +5
-0+ def __init__ (self, date, author, message): + self.revs = {} # dict: path -> CvsRev object + self.date = date # CvsDate object + self.author = author + self.message = message # Lines of commit messagepep8 and other parts of the git codebase recommend against lining up the equals signs like that. Ya, sorry for the nits being that they're purely stylistic.
Quoted 4 lines
I can't find a good rationale for this rule in PEP8 (other than Guido's personal style), and I personally find the above much more readable (otherwise I wouldn't go through the trouble of lining them all up...). Can I claim exception (1) (readability)?
I think you are missing the point. It may be true that the rules in PEP8 were *originally* written according to the unjustified whims of the BDFL, but now that they are established the reason for following them is not that Guido likes them but rather to be consistent with the bulk of other Python code on the planet.
With respect to the rule to use 4-space indents, there are serious practical problems with using tabs *in addition to* the consistency argument.
Michael
Re: [RFCv3 2/4] Add Python support library for CVS remote helper
Quoted 18 lines · Michael Haggerty
Quoted 12 lines · Johan Herland
Quoted 10 lines · David Aguilar
git_remote_cvs/changeset.py line 37
Quoted 5 lines · Johan Herland
git_remote_cvs/changeset.py new file +5
-0+ def __init__ (self, date, author, message): + self.revs = {} # dict: path -> CvsRev object + self.date = date # CvsDate object + self.author = author + self.message = message # Lines of commit messagepep8 and other parts of the git codebase recommend against lining up the equals signs like that. Ya, sorry for the nits being that they're purely stylistic.
Quoted 4 lines
I can't find a good rationale for this rule in PEP8 (other than Guido's personal style), and I personally find the above much more readable (otherwise I wouldn't go through the trouble of lining them all up...). Can I claim exception (1) (readability)?
Quoted 5 lines
I think you are missing the point. It may be true that the rules in PEP8 were *originally* written according to the unjustified whims of the BDFL, but now that they are established the reason for following them is not that Guido likes them but rather to be consistent with the bulk of other Python code on the planet.
Ok. I will try to follow PEP8 as closely as possible.
Quoted 3 lines
With respect to the rule to use 4-space indents, there are serious practical problems with using tabs *in addition to* the consistency argument.
There are? What arguments? Assuming I don't mix spaces and tabs (which I certainly don't), I can't see any "practical problems" with using tabs (except for the PEP8/consistency issue).
...Johan
Signature · 2 lines
Johan Herland, <[email protected]> www.herland.net
Re: [RFCv3 2/4] Add Python support library for CVS remote helper
In reply to David AguilarQuoted 2 lines · David Aguilar
This also had me wondering about the following:
git uses tabs for indentation
Not relevant. That is a rule for our "C" source code. We also use it in our Perl scripts and shell scripts because there is no single "one right way" that is strongly defined and everybody adheres to, like the 4-space rule Python folks have.
Quoted 5 lines
BUT, the python convention is to use 4-space indents ala PEP-8
http://www.python.org/dev/peps/pep-0008/It might be appealing to when-in-Rome (Rome being Python) here and do things the python way when we code in Python.
Yes, this is more important.
Quoted 5 lines
git_remote_cvs/changeset.py line 43
Quoted 3 lines
git_remote_cvs/changeset.py new file +3
-0+ if len(msg) > 25: msg = msg[:22] + "..." # Max 25 chars long + return "<Changeset @(%s) by %s (%s) updating %i files>" % ( + self.date, self.author, msg, len(self.revs))Similar to the git coding style, this might be better written:
So is this one. If experienced Python folks also frown on single-line conditionals, then by all means please update this. But if this suggestion is solely because we don't do a single-line conditional in our C source code, then please do not insist on it too strongly. The code should look familiar to Pythonistas with good tastes (if such a class of people exist, that is ;-)).
Re: [RFCv3 2/4] Add Python support library for CVS remote helper
Quoted 23 lines · Junio C Hamano
Quoted 2 lines · David Aguilar
This also had me wondering about the following:
git uses tabs for indentationNot relevant. That is a rule for our "C" source code. We also use it in our Perl scripts and shell scripts because there is no single "one right way" that is strongly defined and everybody adheres to, like the 4-space rule Python folks have.
Quoted 5 lines
BUT, the python convention is to use 4-space indents ala PEP-8
http://www.python.org/dev/peps/pep-0008/It might be appealing to when-in-Rome (Rome being Python) here and do things the python way when we code in Python.
Yes, this is more important.
Quoted 5 lines
git_remote_cvs/changeset.py line 43
Quoted 3 lines
git_remote_cvs/changeset.py new file +3
-0+ if len(msg) > 25: msg = msg[:22] + "..." # Max 25 chars long + return "<Changeset @(%s) by %s (%s) updating %i files>" % ( + self.date, self.author, msg, len(self.revs))Similar to the git coding style, this might be better written:
Quoted 6 lines
So is this one. If experienced Python folks also frown on single-line conditionals, then by all means please update this. But if this suggestion is solely because we don't do a single-line conditional in our C source code, then please do not insist on it too strongly. The code should look familiar to Pythonistas with good tastes (if such a class of people exist, that is ;-)).
Ok. Thanks. I will follow PEP8 as closely as possible, including the 4-space indent.
...Johan
Signature · 2 lines
Johan Herland, <[email protected]> www.herland.net
Re: [RFCv3 2/4] Add Python support library for CVS remote helper
In reply to Johan HerlandIt appears that the "make install" step with this patch is broken, trying to write into /usr/lib/python2.6/ without honoring DESTDIR.
It needs to be resolved before the series nears 'master', preferrably before it hits 'next', as "make rpm" step is one of the things that is broken by this.
I am sure people who are more savvy on Python can offer help.
Thanks.
PATCH 1/2 git_remote_cvs: Honor DESTDIR in the Makefile
This adds the --root=<path> flag to setup.py so that the user-provided DESTDIR is honored.
--- git_remote_cvs/Makefile | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-)
git_remote_cvs/Makefile +13 -1
@@ -3,6 +3,15 @@ # pysetupfile:=setup.py +# Setup the DESTDIR for Python. +ifeq ($(DESTDIR),) +PYTHON_DESTDIR = / +else +PYTHON_DESTDIR = $(DESTDIR) +endif +# Shell quote (do not use $(call) to accommodate ancient setups); +PYTHON_DESTDIR_SQ = $(subst ','\'',$(PYTHON_DESTDIR)) + ifndef PYTHON_PATH PYTHON_PATH = /usr/bin/python endif
@@ -19,7 +28,10 @@ PYLIBDIR=`$(PYTHON_PATH) -c "import sys; print 'lib/python%i.%i/site-packages' % all: $(pysetupfile) $(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) build install: $(pysetupfile) - $(PYTHON_PATH) $(pysetupfile) install --prefix $(prefix) + $(PYTHON_PATH) $(pysetupfile) install \ + --prefix $(prefix) \ + --root $(PYTHON_DESTDIR_SQ) + instlibdir: $(pysetupfile) @echo "$(prefix)/$(PYLIBDIR)" clean:
Signature · 1 line
1.6.4.169.g64d5
PATCH 2/2 git_remote_cvs: Use $(shell) in the Makefile
This updates the git_remote_cvs Makefile to use the same $(shell <cmd>) style used by the top-level git Makefile.
--- git_remote_cvs/Makefile | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
git_remote_cvs/Makefile +5 -1
@@ -23,10 +23,13 @@ ifndef V QUIETSETUP = --quiet endif -PYLIBDIR=`$(PYTHON_PATH) -c "import sys; print 'lib/python%i.%i/site-packages' % sys.version_info[:2]"` +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 $(prefix) \
@@ -34,6 +37,7 @@ install: $(pysetupfile) instlibdir: $(pysetupfile) @echo "$(prefix)/$(PYLIBDIR)" + clean: $(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) clean -a $(RM) *.pyo *.pyc
Signature · 1 line
1.6.4.169.g64d5
Re: [PATCH 2/2] git_remote_cvs: Use $(shell) in the Makefile
Quoted 5 lines · David Aguilar
This updates the
git_remote_cvsMakefileto use the same $(shell <cmd>) style used by the top-level gitMakefile.Signed-off-by David Aguilar <[email protected]>---
I should have mentioned here that I also spaced stuff out and chopped the long line so that it fits within 78 chars.
I intentionally broke this out as a 2nd patch in case using $(shell ...) was not the right thing to do.
Quoted 33 lines
git_remote_cvs/Makefile | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)git_remote_cvs/Makefile +5
-1@@ -23,10 +23,13 @@ ifndef V QUIETSETUP = --quiet endif -PYLIBDIR=`$(PYTHON_PATH) -c "import sys; print 'lib/python%i.%i/site-packages' % sys.version_info[:2]"` +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 $(prefix) \@@ -34,6 +37,7 @@ install: $(pysetupfile) instlibdir: $(pysetupfile) @echo "$(prefix)/$(PYLIBDIR)" + clean: $(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) clean -a $(RM) *.pyo *.pycSignature · 1 line
1.6.4.169.g64d5
Signature · 1 line
David
Re: [PATCH 1/2] git_remote_cvs: Honor DESTDIR in the Makefile
In reply to David AguilarHi,
git_remote_cvs/Makefile line 8
Quoted 11 lines · David Aguilar
git_remote_cvs/Makefile +3
-0@@ -3,6 +3,15 @@ # pysetupfile:=setup.py +# Setup the DESTDIR for Python. +ifeq ($(DESTDIR),) +PYTHON_DESTDIR = /
Hmm. I think this would break on msysGit. Not that anybody worked on getting Python to compile on msysGit.
(Just to make sure you understand the issue: on msysGit, we set prefix to "" (and I think DESTDIR somehow ends up taking on the same value). Now, when DESTDIR is set to "/" and something wants to be copied to $(DESTDIR)/something, the latter expands to //something, which tells MSys not to expand //something to the correct Windows path.
Ciao,
Dscho
PATCH v2 1/2 git_remote_cvs: Honor DESTDIR in the Makefile
This modifies the setup.py invocation so that user-defined DESTDIRs are taken into account.
---
setup.py gets confused if we use --root like in v1 of this patch. I think this is simpler. Thoughts?
git_remote_cvs/Makefile | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
git_remote_cvs/Makefile +5 -1
@@ -3,6 +3,9 @@ # 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
@@ -19,7 +22,8 @@ PYLIBDIR=`$(PYTHON_PATH) -c "import sys; print 'lib/python%i.%i/site-packages' % all: $(pysetupfile) $(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) build install: $(pysetupfile) - $(PYTHON_PATH) $(pysetupfile) install --prefix $(prefix) + $(PYTHON_PATH) $(pysetupfile) install --prefix $(DESTDIR_SQ)$(prefix) + instlibdir: $(pysetupfile) @echo "$(prefix)/$(PYLIBDIR)" clean:
Signature · 1 line
1.6.4.314.g034e1
PATCH v2 2/2 git_remote_cvs: Use $(shell) in the Makefile
This updates the git_remote_cvs Makefile to use the same $(shell <cmd>) style used by the top-level git Makefile.
--- git_remote_cvs/Makefile | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
git_remote_cvs/Makefile +5 -1
@@ -17,15 +17,19 @@ ifndef V QUIETSETUP = --quiet endif -PYLIBDIR=`$(PYTHON_PATH) -c "import sys; print 'lib/python%i.%i/site-packages' % sys.version_info[:2]"` +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
Signature · 1 line
1.6.4.314.g034e1
Re: [PATCH 1/2] git_remote_cvs: Honor DESTDIR in the Makefile
In reply to Johannes SchindelinQuoted 19 lines · Johannes Schindelin
Hi,
git_remote_cvs/Makefile line 8
Quoted 11 lines · David Aguilar
git_remote_cvs/Makefile +3
-0@@ -3,6 +3,15 @@ # pysetupfile:=setup.py +# Setup the DESTDIR for Python. +ifeq ($(DESTDIR),) +PYTHON_DESTDIR = /Hmm. I think this would break on msysGit. Not that anybody worked on getting Python to compile on msysGit.
Quoted 5 lines
(Just to make sure you understand the issue: on msysGit, we set prefix to "" (and I think DESTDIR somehow ends up taking on the same value). Now, when DESTDIR is set to "/" and something wants to be copied to $(DESTDIR)/something, the latter expands to //something, which tells MSys not to expand //something to the correct Windows path.
I see. Hmm.. setup.py is a real pain.
I'll see if we rework this so that we end up passing "" to --root instead of /. I'm going to be gone for a few hours so probably won't be able to try it out until tonight.
Another thing to consider --
Debian once submitted a bug against another Python app asking that we not place modules in site-packages unless we plan on having other applications importing those modules.
The more appropriate place for them if we don't plan on that is $(prefix)/share/git-core/git_remote_cvs or something like that.
I guess that's another thing to think about.
Signature · 1 line
David
Re: [PATCH 1/2] git_remote_cvs: Honor DESTDIR in the Makefile
Quoted 3 lines · David Aguilar
I'll see if we rework this so that we end up passing "" to --root instead of /. I'm going to be gone for a few hours so probably won't be able to try it out until tonight.
Thanks a lot for your work! I will send an updated series shortly which will include v2 of your DESTDIR/Makefile fixes, and also the fixes you suggested earlier (including _lots_ of PEP8 fixes).
Quoted 10 lines
Another thing to consider --
Debian once submitted a bug against another Python app asking that we not place modules in site-packages unless we plan on having other applications importing those modules.
The more appropriate place for them if we don't plan on that is $(prefix)/share/git-core/git_remote_cvs or something like that.
I guess that's another thing to think about.
Yes, Debian raises a valid point. I haven't thought much about making the git_remote_cvs package into something that would be useful for other applications. (I just assumed that the Python convention was to install it into site-packages regardless...) For now, I'll concentrate on git-remote- cvs, and leave it to others to figure out if anything in the git_remote_cvs package is useful for other programs.
Note that there's a small chicken-and-egg problem here as well: If Debian refuses us to install into site-packages, it will be harder for other Python programs to discover (and import) the git_remote_cvs package.
BTW, when we're on the subject of packaging: There are some variables in git_remote_cvs/setup.py where I'm not sure what the correct value should be:
- version - should this follow Git's version number, or is it independent?
- author (and author_email + url) - For now, I'm referring to the Git community. Should this be more specific/
Feedback welcome.
Have fun! :)
...Johan
Signature · 2 lines
Johan Herland, <[email protected]> www.herland.net
Re: [PATCH 1/2] git_remote_cvs: Honor DESTDIR in the Makefile
In reply to David AguilarHi,
Quoted 26 lines · David Aguilar
Quoted 17 lines · Johannes Schindelin
git_remote_cvs/Makefile line 8
Quoted 11 lines · David Aguilar
git_remote_cvs/Makefile +3
-0@@ -3,6 +3,15 @@ # pysetupfile:=setup.py +# Setup the DESTDIR for Python. +ifeq ($(DESTDIR),) +PYTHON_DESTDIR = /Hmm. I think this would break on msysGit. Not that anybody worked on getting Python to compile on msysGit.
Quoted 5 lines
(Just to make sure you understand the issue: on msysGit, we set prefix to "" (and I think DESTDIR somehow ends up taking on the same value). Now, when DESTDIR is set to "/" and something wants to be copied to $(DESTDIR)/something, the latter expands to //something, which tells MSys not to expand //something to the correct Windows path.
Quoted 5 lines
I see. Hmm..
setup.pyis a real pain.I'll see if we rework this so that we end up passing "" to --root instead of /. I'm going to be gone for a few hours so probably won't be able to try it out until tonight.
Thinking about it a bit more: you might not need to do anything. I think
that msysGit should move to prefix = /mingw anyway.
I hesitated to do that earlier, as all .perl and .sh scripts need MSys. But the Git .exe files are MinGW programs, so technically they belong into /mingw/bin/ anyway.
But the issue would only really become relevant if anybody supported Python on msysGit (and thereby git-remote-cvs, before that, we cannot make use of it).
Just a thing to keep in mind.
Ciao,
Dscho
RFC v3 3/4 Third draft of CVS remote helper program
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
--- Documentation/git-remote-cvs.txt | 85 +++++ Makefile | 24 ++ git-remote-cvs.py | 697 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 806 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 +697 -0
697 lines not on this page · raw message
Signature · 1 line
1.6.4.rc3.138.ga6b98.dirty
RFC v3 4/4 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.rc3.138.ga6b98.dirty