Import SVN project into gerrit?

1,138 views
Skip to first unread message

Gareth Huang

unread,
Dec 31, 2015, 3:59:52 AM12/31/15
to Repo and Gerrit Discussion
Guys

Now I have a SVN project and I wanna switch it into gerrit now. Do we have a guide for this?

Luca Milanesio

unread,
Dec 31, 2015, 5:24:18 AM12/31/15
to Gareth Huang, Repo and Gerrit Discussion
Hi Gareth,
just convert your SVN repo to Git (see [1]) and copy the bare repo into Gerrit's /git directory.

Luca.


On 31 Dec 2015, at 08:59, Gareth Huang <academi...@gmail.com> wrote:

Guys

Now I have a SVN project and I wanna switch it into gerrit now. Do we have a guide for this?

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gareth

unread,
Jan 1, 2016, 1:48:50 PM1/1/16
to Luca Milanesio, Repo and Gerrit Discussion
Thanks Luca,

I didn't make my case clear.

Now I have a big SVN project and I want Gerrit to manage it or to
replace. So I hope it is possible to 'upload' to Gerrit, to git-svn
and then to SVN.
--
Gareth (Kun Huang)

Cloud Computing, OpenStack, Distributed Storage, Fitness, Basketball
OpenStack contributor, kun_huang@freenode
My promise: if you find any spelling or grammar mistakes in my email
from Mar 1 2013, notify me
and I'll donate $1 or ¥1 to an open organization you specify.

luca.mi...@gmail.com

unread,
Jan 1, 2016, 5:44:45 PM1/1/16
to Gareth, Repo and Gerrit Discussion
Hi Gareth, Gerrit is build on top of JGit and does not support SVN.

If you wish to use Gerrit you have to migrate to Git first.

Luca

Sent from my iPhone

philipp...@gmail.com

unread,
Jan 3, 2016, 1:26:22 PM1/3/16
to Repo and Gerrit Discussion, academi...@gmail.com
We have recently migrated several projects in our organization and have automated most of the work.  
I've included some example commands here.
We also used a tool called "BFG" to remove large binary files from the project history before uploading to Gerrit (see https://rtyley.github.io/bfg-repo-cleaner/)

The steps we follow are:

0. cleanup your svn tree, in svn. svn rm any big files that people don't need.

1. generate the list of committers using something like

svn log | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2"@ingrooves.com>"}' | sort -u > authors-transform.txt

2. Use git-svn to convert your svn history into a git repository. The exact arguments will depend on your branch layout:

git svn clone --no-minimize-url -A ../authors-transform.txt \

    -r 88160:HEAD http://svn.INgrooves.com/svn/INgrooves/Apollo/UI \

    --prefix=origin/ --trunk=trunk --branches=branches \

    ./${GIT_SVN_REPO_NAME} 

3. Map the cloned repo into a bare git repo that will "look" like your final repo, and include the branches you want to keep:

rm -rf ./${IMPORTED_GIT_REPO_NAME}

git init --bare ${IMPORTED_GIT_REPO_NAME}

cd ${GIT_SVN_REPO_NAME}

git remote remove local-git

git remote add local-git ../${IMPORTED_GIT_REPO_NAME}

git config remote.local-git.push 'refs/remotes/origin/*:refs/heads/*'

git push local-git master

git push local-git remotes/origin/2.0


4. We use BFG to prune away deleted binary files from the repository's history. Note that this will change your repo history. This is OK for us because history is for people, not builds, and we keep our old svn repository. The size reductions are dramatic.


java -jar ../bfg/bfg.jar --strip-blobs-bigger-than 50M ${IMPORTED_GIT_REPO_NAME}

java -jar ../bfg/bfg.jar --delete-files '*.{aif,aiff,dll,epub,exe,jar,obj,mobi,mov,mpeg,mp3,mp4,nupkg,pdb,wav,wixpdb,wma,zip}' ${IMPORTED_GIT_REPO_NAME}


cd ${IMPORTED_GIT_REPO_NAME}


git reflog expire --expire=now --all && git gc --prune=now --aggressive

git repack -a -d -f --depth=250 --window=250


5. Upload the bare repository directly to the gerrit data directory. Restart the gerrit server or flush its caches.

Reply all
Reply to author
Forward
0 new messages