With hgsubversion, you can pick and choose.

Something that was not obvious (to me) in the hgsubversion documentation is that you can clone any part of a subversion repository.

#!/bin/bash
# 
# With hgsubversion, you can clone *ANY* folder in a subversion repository. 
# (Well, really any non-empty folder)
# Let me repeat, you do not have to clone the entire repository! It could be
# a branch or even a folder within a branch. If you clone a branch folder,
# your pushed changesets will go into the branch.
# 
# Requires:
#   subversion installed
#   rebase extension
#   hgsubversion extension
#
# We have the following repositories:
#     SVN repo  hg-svn
# 
# SVN repo:       company subversion repo on remote server, https://ip/svn
# hg-svn:         local developer copy of SVN repo using hgsubversion 
# 
# Our goal is to clone/checkout only a sub-folder, make changes, and see
# what happens.
# 
# Example:

# Turn on debugging so we can see the commands as they're issued.
set -x
# Clean up after any previous run.
rm -rf folder_test

mkdir folder_test
cd folder_test

# Create a "company" SVN repository.
svnadmin create SVN
svn co file://`pwd`/SVN SVN_temp

# Put something in the SVN repository or we won't be able
# to see why some of the steps are necessary.
cd SVN_temp/
svn mkdir trunk tags branches
svn ci -m "Initial folders"
echo "Company file" > trunk/company.txt
svn add trunk/company.txt
svn mkdir trunk/subfolder
echo "text" >> trunk/subfolder/anotherfile.txt
svn add trunk/subfolder/anotherfile.txt
svn ci -m "Added some files"
cd ..

# Create our clone of SVN. Just grab the folder you want. It could be
# a branch or even a folder in a branch.
hg clone file://`pwd`/SVN/trunk/subfolder hg-svn

# Make some changes
cd hg-svn
echo "more text" >> anotherfile.txt
echo "text" >> newfile.txt
hg add newfile.txt
hg com -m "Made some change in hg."
hg push
cd ..

# Look at the complete subversion repository to see what happened.
cd SVN_temp
svn up

# See that out line was added.
cat trunk/subfolder/anotherfile.txt

# See the new file.
set +x
echo "=========================="
echo "Results:"
find . | egrep -v '\.svn'
cd ..

# Use the following command to see the log of changes:
# svn log -v SVN_temp

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *