Skip to content
guyboltonking edited this page Sep 14, 2010 · 3 revisions
#!/bin/bash -ex

# Merging the 2.1 and 2.2 CVS webmacro CVS repositories
# =====================================================

# The webmacro CVS repository was recently rearranged: the old
# webmacro module was moved to original, and the RCS files copied into
# a new hierarchy.  Of course, this completely breaks history: this is
# an attempt to recreate the history using git.  Done mainly to see
# whether it was possible to track upstream CVS through a repository
# re-org: I don't know whether I'll ever get around to submitting any
# changes myself, but if I do, here's the place I can do it without
# disturbing CVS HEAD...

# rsync existing CVS repo from sourceforge (for speed)
rsync -az --chmod u+w --delete \
  webmacro.cvs.sourceforge.net::cvsroot/webmacro/* webmacro-cvsroot/

# Checkout the original repo layout
cvs -q -d $(pwd)/webmacro-cvsroot co -P -kk -d webmacro-2.1-CVS original
cd webmacro-2.1-CVS

# Create a git repository based on it, killing all keyword
# substitution, and putting all the branches and tags into a CVS-2.1
# namespace:
git cvsimport -k -r CVS-2.1

for tag in $(git tag | grep -v CVS-2.1); do
  date=$(git show --pretty=format:"%ct" $tag | head -1)
  GIT_COMMITTER_DATE="$date" git tag CVS-2.1/$tag $tag
  git tag -d $tag
done

git branch -r | grep CVS-2.1 | fgrep -v -- '->' | \
  xargs -n 1 -I {} git branch {} {}

cd ..

# Checkout the new repo layout
cvs -q -d $(pwd)/webmacro-cvsroot co -P -kk -d webmacro-2.2-CVS webmacro
cd webmacro-2.2-CVS

# Tag the last change to be made prior to the layout change, and
# change to that tag
#cvs -q up -kk -D "2010-02-20 23:30:07" -Pd
#cvs -q tag -R webmacro-2_2-repo-layout-change
cvs -q up -kk -rwebmacro-2_2-repo-layout-change -Pd
cd ..

# In our git repo, create a branch that the 2.2 CVS import will live
# on, and then populate it with the contents of the new layout
cd webmacro-2.1-CVS
git checkout -b CVS-2.2/master
rm -fr *
rsync -a --exclude 'CVS/' ../webmacro-2.2-cvs/ ./
git add .

# Set a time after the last commit on the branch we want to import to
# and before the first patchset that we want cvsimport to pull in
GIT_AUTHOR_DATE="2010-02-20 23:30:07" \
GIT_COMMITTER_DATE="2010-02-20 23:30:07" \
  git commit -a -m 'Manual merge of v2.2 repository layout'
git tag CVS-2.2/repo-layout-change

# Import the post-layout-change changesets, ignoring keywords (-k),
# adding the changesets to CVS-2.2/master, and only pulling changesets
# since the layout change on the HEAD branch (-p).  We only pull from
# HEAD because the layout change terminally confuses correct merge
# detection; it's safe to do this because the only committer to the
# CVS repo won't use branches.
git cvsimport -d $(pwd)/../webmacro-cvsroot webmacro \
  -k -o CVS-2.2/master -p -b,HEAD,-r,webmacro-2_2-repo-layout-change

cd ..

# Check that changes have been made
cd webmacro-2.2-CVS
cvs -q up -kk -A -Pd
cd ..

diff -r --exclude CVS --exclude .git webmacro-2.1-CVS webmacro-2.2-CVS

# Clean up
rm -fr webmacro-2.2-CVS
mv webmacro-2.1-CVS webmacro-git
Clone this wiki locally