Re: cvs2git and CVS keywords
Reto Glauser <[email protected]>
| Newsgroups | gmane.comp.version-control.subversion.cvs2svn.user |
|---|---|
| Message-ID | <[email protected]> |
Michael Haggerty wrote: > Reto Glauser wrote: >> I do have the following question: is it possible to ignore the CVS >> keywords in each file during import or is it necessary to create the >> branching history? IIRC git just looks at the content of a file and >> creates the SHA1 from it - so, if the content changes (which does of >> course in CVS in each different branch due to the keywords), we miss >> that a commit is the same as another. This results in only 1 return from: >> >> $ git branch --contains <SHA1> >> >> even though the same commit/file exists in 5 branches. Maybe it's >> possible with some grep/sed-magic to rewrite each file before commiting >> it to git? > > Yes, it would be possible, with some minor changes to cvs2svn. There is > already code in cvs2svn that knows how to collapse or expand CVS > keywords (see cvs2svn_lib/checkout_internal.py, > InternalRevisionReader.get_content_stream()). The handling of CVS > keywords by cvs2git is not really thought out; see > cvs2svn_lib/git_output_option.py, > GitRevisionInlineWriter._modify_file(), so some work here would indeed > be welcome. > > Alternatively, one could use git-filter-branch with some random shell > commands *after* the conversion. > Turns out the default running operation for git is: ctx.revision_recorder = SimpleFulltextRevisionRecorderAdapter( ... ) which means, no GitRevisionInlineWriter is called. To *NOT* substitute the CVS keywords in this default mode, we can pass TRUE for suppress_keyword_substitution in the get_content_stream() call of record_text in SimpleFulltextRevisionRecorderAdapter which then passes '-kk' to CVS. This way, CVS won't hand over the files with expanded keywords and we're all set: > $ git diff master -- cvs2svn_lib/fulltext_revision_recorder.py > diff --git a/cvs2svn_lib/fulltext_revision_recorder.py b/cvs2svn_lib/fulltext_revision_recorder.py > index ad057b7..94068d3 100644 > --- a/cvs2svn_lib/fulltext_revision_recorder.py > +++ b/cvs2svn_lib/fulltext_revision_recorder.py > @@ -114,8 +113,9 @@ class SimpleFulltextRevisionRecorderAdapter(FulltextRevisionRecorderAdapter): > # FIXME: We have to decide what to do about keyword substitution > # and eol_style here: > fulltext = self.revision_reader.get_content_stream( > - cvs_rev, suppress_keyword_substitution=False > + cvs_rev, suppress_keyword_substitution=True > ).read() > return self.fulltext_revision_recorder.record_fulltext( > cvs_rev, log, fulltext > ) ------------------------------------------------------ http://cvs2svn.tigris.org/ds/viewMessage.do?dsForumId=1670&dsMessageId=2403240 To unsubscribe from this discussion, e-mail: [[email protected]].