[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: migration from svn to git



> Well, it preserves the edit history within /debian, which for me is
> enough.  In some cases there is probably a clever way to pull the
> upstream history from the svn repo using git-svn. For the packages
Just thought to share a piece of my experience although I doubt it would
generalize over any range of usecases ;)

I maintain fail2ban. Upstream sources used to be under CVS and then migrated
over to SVN. I kept my packaging in CVS and then in SVN (separate from
upstream). Then I decided to switch to git and at the end I ended up with
somewhat complicated beast (debcheckout fail2ban to see it), and it would fail
any collab standards out there,  but now the whole development (upstream) +
packaging (debian + released upstream sources) history is there, upstream's
SVN repository is linked via git-svn (thus I can cherry-pick needed commits to
fix bugs before upstream releases, and push/dcommit back into upstream
repository if needed).

Few obstacles I passed through on the way with might be worth mentioning and
sketching a solution:

* I switched to and them from the svn scheme to maintain only debian/, so some
upstream tags were pointing to bogus/empty directories. Thus I had to repopulate
upstream branch from the tarballs. I did it with smth like (upstream repository
tags them as X_Y_Z, but tarballs distributed are somewhat different, thus I
needed separate from original upstream branch, just for debian distributed
sources, it got taged upstream/X.Y.Z)

/bin/ls ../tarballs/fail2ban_0.*orig.tar.gz | \
 sed -e 's,.*fail.*_\(0.[.0-9]*\)\.orig.*,\1,g' |\
 sort | grep '^0' | \
  while read rev; do
    echo "Working on $rev"
    git merge --no-commit -s ours ${rev//./_}
        # remove everything (besides .git)
        rm * -rf
        # extract tarball
        tar -xzf ../tarballs/fail2ban_${rev}.orig.tar.gz
        mv fail2ban-0.*/* .
        rmdir fail2ban-0.*
        # add files
        git add `git ls-files -o`
        git commit -m "Upgraded to fresh upstream ${rev}" -a
        git tag upstream/${rev}
    git status
  done

* git-svn pulls in tags from svn as branches, so you would need to tag
appropriately and remove those bogus branches for the sake of sanity   

git branch -r | sed -rne 's, *upstream-repo/tags/FAIL2BAN-([^@]+)$,\1,p' | \
while read tag; do
git tag $tag upstream-repo/tags/FAIL2BAN-${tag}^ && \
  git branch -r -d upstream-repo/tags/FAIL2BAN-$tag;
done

-- 
Yaroslav Halchenko
Research Assistant, Psychology Department, Rutgers-Newark
Student  Ph.D. @ CS Dept. NJIT
Office: (973) 353-5440x263 | FWD: 82823 | Fax: (973) 353-1171
        101 Warren Str, Smith Hall, Rm 4-105, Newark NJ 07102
WWW:     http://www.linkedin.com/in/yarik        


Reply to: