# # Install devel/mercurial port # cd /usr/ports/devel/mercurial ; make install clean # # Configure your personal hg settings # cat << EOF >> ~/.hgrc [extensions] convert = keyword= [ui] username = [keyword] **.c = **.h = **.s = **.S = **.cc = **.cpp = **.cxx = **.sh = **.pl = **.pm = **.py = **.rb = **.awk = **.sed = **.txt = **.conf = Makefile** = [keywordmaps] FreeBSD = {file} {node|short} {date|utcdate} {author} EOF # # Convert a local FreeBSD svn repo to hg. This gets you head and all stable/* # branches with full history as a ~800MB hg repository # "bm.txt" should have lines of the form: # 8 8_stable # 7 7_stable # ... # The branchmap is used to change the names of the branches in the svn repo # as they are imported into hg. This is useful because having a branch # named as a number can unnecessarily complicate certain hg commands. # # You should be able to ommit branches you dont want using the --filemap option (untested). # # Assumes you have a local svn mirror repo (*not* working copy) at /path/to/freebsd/svn/mirror # hg convert --branchmap=bm.txt --config convert.svn.trunk='head' \ --config convert.svn.branches='stable' --config convert.svn.tags='' \ file:///path/to/freebsd/svn/mirror /path/to/hg/freebsd/mirror # # The conversion will grind for some time (likely hours). If all went well you # should be able to do the following: # root@lstewart3# cd /path/to/hg/freebsd/mirror ; hg branches 2.1 196829:a3508a8f9db0 2.2 194655:f1a7c550ee16 3_stable 189352:eb1d41ddccb0 6_stable 185696:7730c98aed73 7_stable 178631:bf0552777da4 8_stable 173578:91daa48fd6eb head 171275:7584517f6012 5_stable 123714:fd6ff81a261c 4_stable 60516:d863ff4664c0 2.0.5 8462:ead256fff02c # # Install a hook to ensure you don't commit or pull anything into your pristine branches # mkdir /path/to/hg/freebsd/mirror/.hg/hooks cat << EOF >> /path/to/hg/freebsd/mirror/.hg/hooks/notouchy.sh #!/bin/sh HG="/usr/local/bin/hg" NOTOUCHY="head 9 8 7 6 5 4 3 2.2 2.1 2.0.5" NODES="`${HG} log -r ${HG_NODE}:tip --template '{node}\n'`" for NODE in ${NODES} ; do for NOTOUCH in ${NOTOUCHY} ; do NODE_BRANCH="`${HG} id --branch -r ${NODE}`" if [ "${NODE_BRANCH}" = "${NOTOUCH}" ] ; then echo "No changes allowed on the '${NOTOUCH}' branch." exit 1 fi done done exit 0 EOF chmod +x /path/to/hg/freebsd/mirror/.hg/hooks/notouchy.sh cat << EOF >> /path/to/hg/freebsd/mirror/.hg/hgrc [hooks] pretxnchangegroup.notouchy = .hg/hooks/notouchy.sh pretxncommit.notouchy = .hg/hooks/notouchy.sh EOF # # Create a project branch off head. "hg clone" when used on the local filesystem # uses hard links so cloning once per project branch is a good idea to keep each # working copy in a separate directory. # hg clone -U /path/to/hg/freebsd/mirror /path/to/hg/freebsd/blah_head cd /path/to/hg/freebsd/blah_head hg up -r head hg branch blah_head hg ci # # Sync your pristine branches with latest FreeBSD svn # hg convert --branchmap=bm.txt --config convert.svn.trunk='head' \ --config convert.svn.branches='stable' --config convert.svn.tags='' \ file:///path/to/freebsd/svn/mirror /path/to/hg/freebsd/mirror # # Merge latest changes from head with your project branch # cd /path/to/hg/freebsd/blah_head hg pull hg merge -r head hg ci