Using rsync to 'push' and 'pull'

<!> This push script ignores locking issues - don't use it for pushing to a repository with multiple writers!

This script will perform a pull from an rsync path:

cd `hg root`
rm -rf .hg/rsync
hg clone -U . .hg/rsync # make an approximate copy to rsync over
rsync -ae ssh $1/.hg .hg/rsync # rsync over our copy
hg pull .hg/rsync # pull from our copy
rm -rf .hg/rsync

Use like this:

$ rsyncpull user@server:repo/foo
pulling from .hg/rsync
searching for changes
adding changesets
adding manifests
adding file changes
added 57 changesets with 153 changes to 65 files
(run 'hg update' to get a working copy)

Similarly, we can push with a script like this:

cd `hg root`
rm -rf .hg/rsync
hg clone -U . .hg/rsync
rsync -ae ssh $1/.hg .hg/rsync
hg push .hg/rsync
rsync -ae ssh .hg/rsync $1/.hg
rm -rf .hg/rsync


CategoryTipsAndTricks

UsingRsyncToPushAndPull (last edited 2009-05-19 19:31:01 by localhost)