Changes To Cookbook
Not logged in

Changes to "Cookbook" between 2011-06-09 00:33:45 and 2011-06-21 05:55:29

    24     24     <li><a href="#ticket-checkin-links">Link tickets to checkins</a></li>
    25     25     <li><a href="#th1-usage">Fossil and Th1</a></li>
    26     26     <li><a href="#versionCompressed">Versioning compressed files</a></li>
    27     27     <li><a href="#ColorPicker">Color selector in check-in properties</a></li>
    28     28     <li><a href="#SearchWiki">Searching wiki text</a></li>
    29     29     <li><a href="#HighlightDiff">Highlight diff's</a></li>
    30     30     <li><a href="#Mercurial">Importing from Mercurial</a></li>
           31  +  <li><a href="#SVN">Importing from SVN</a></li>
    31     32   </ul>
    32     33   
    33     34   <h2><a name="CGI">Using <cite>Fossil</cite>'s Built-In CGI</a></h2>
    34     35   <h3>Motivation</h3>
    35     36     *  You want to share a repository through your existing web infrastructure.
    36     37     *  You want to share more than one repository at the same time.
    37     38   
................................................................................
  1236   1237   hg push ../git-wpkg
  1237   1238   cd ../git-wpkg
  1238   1239   git fast-export --all | fossil import --git ~/wpkg.fossil
  1239   1240   cd ~
  1240   1241   rm -rf /tmp/moretmp
  1241   1242   fossil ui wpkg.fossil
  1242   1243   </verbatim>
         1244  +
         1245  +<h2><a name="SVN">Importing from SVN</a></h2>
         1246  +
         1247  +<h3>Problem</h3>
         1248  +
         1249  +Fossil supports [/doc/trunk/www/inout.wiki|importing from Git], but not from SVN.
         1250  +
         1251  +<h3>Solution</h3>
         1252  +
         1253  +  *  Ensure you have "git-svn" and "sed".
         1254  +  *  Save the following bash script somewhere, call it <tt>svn2fossil</tt>
         1255  +  *  Create an empty directory
         1256  +  *  In that directory, type <tt>svn2fossil username svnrepo fossilrepo</tt>
         1257  +
         1258  +In this case 'username' is the SVN user you wish to make changes as, 'svnrepo' is the full svn url (e.g. "svn+ssh://joe@someplace.org/svn/whatever"), and "fossilrepo" is the name you wish the resultant fossil repository to have.
         1259  +
         1260  +The "svn2fossil" script will first import the SVN repository into 'git'.  Then it will export from 'git' to fossil.  Then it will import all the SVN users who are listed in the SVN log, as 'developers' in the fossil repository, with a password consisting of the user name with '1234' appended to it.  Finally, the script will launch 'fossil ui' on the new repository so you can make any additional changes you want.
         1261  +
         1262  +I have successfully used this script to convert pretty large SVN repositories to fossil, in a corporate environment.  The script follows:
         1263  +<verbatim>
         1264  +#!/bin/bash
         1265  +
         1266  +die(){
         1267  +	echo $1
         1268  +	exit 1
         1269  +}
         1270  +
         1271  +authors='authors.txt'
         1272  +fossilusers='users.txt'
         1273  +
         1274  +# parameters:
         1275  +# 1 - username of admin
         1276  +# 2 - svn repository to convert
         1277  +# 3 - name of fossil repo
         1278  +# note: the repository will be created right here!
         1279  +
         1280  +if [ "$3" == "" ]
         1281  +then
         1282  +	echo "Syntax:"
         1283  +	echo "  svn2fossil username  svn-repo-url  fossil-repo-name"
         1284  +	die  "Please make sure you have all three parameters set!"
         1285  +fi
         1286  +
         1287  +echo "Getting user names..."
         1288  +
         1289  +svn log "$2" | grep '^r[0-9]' | cut -f3 -d' ' | sort -u > $fossilusers || die "Something went wrong getting user names"
         1290  +
         1291  +echo "Converting user names to usable format..."
         1292  +sed -e 's/.*/& = & <&>/' $fossilusers > $authors || die "Could not convert user names"
         1293  +
         1294  +echo "Importing from SVN to git.  This will take some time, be patient!"
         1295  +
         1296  +git svn clone --authors-file=$authors --username="$1" --no-metadata "$2" tmp || die "Unable to import to git"
         1297  +
         1298  +echo "Importing from git to fossil.  This will also take some time, sadly"
         1299  +
         1300  +(
         1301  +cd tmp
         1302  +git fast-export --full-tree --all | fossil import --git ../$3 || die "Unable to import into fossil"
         1303  +)
         1304  +
         1305  +echo "Adding users to fossil repository:"
         1306  +for user in `cat $fossilusers`
         1307  +do
         1308  +	fossil user new $user '' "${user}1234" -R $3
         1309  +	fossil user capabilities $user 'v' -R $3
         1310  +done
         1311  +
         1312  +echo "Done!.  Now launching 'fossil ui $3' to check out the new fossil repository"
         1313  +fossil ui $3
         1314  +</verbatim>