Remote Sync

This extension is not distributed with Mercurial.

Author: Ryan Seto

Repository: http://bitbucket.org/MrWerewolf/hg-rsync

Overview

Mercurial Remote Sync (hg-rsync) provides some methods to your working directory in sync with remote files, that exist outside of the repository.

Currently only supports WinSCP.

Configuration

Configure your .hgrc or mercurial.ini to enable the extension by adding the following lines:

[extensions]
rsync = /path/to/hg-rsync

All of hg-rsync's configuration are set under [rsync].

Here is an example:

[rsync]
script = sync/winscp.txt
path = ssh://your.login@remote.host:22/remote/path/to/sync #Optional
cmd = /path/to/winscp.exe #Optional

script

The script file that will be used by WinSCP.

This can be the relative path from the base directory of your local repository or an absolute path.

See WinSCP's scripting documentation for details on how to write this script.

hg-rsync makes two parameters available from within the script.

  1. The connection portion of the path configuration.

    • (your.login@remote.host:22 from the example.)

  2. The path portion of the path configuration.

    • (remote/path/to/sync from the example.)

Here is an example:

option batch on
option confirm off
option transfer automatic
option exclude "readme.txt"
open %1%
cd %2%
synchronize local www/images/upload www/images/upload
synchronize local www/files/upload www/files/upload
close
exit

This will tell WinSCP to do the following:

  1. Open a connection using the login, host, and port specified in the path.

  2. Change to the directory specified in the path.

  3. Synchronize your several local directories with the remote directories.
  4. Exit.

path

This is the remote path to the base directory you want to sync from. By default this will be the default path found under the [paths] portion of your hgrc. You can either specify a full ssh:// path or an alias for a path defined under [paths].

cmd

By default, hg-rsync will search for WinSCP in the default install directories. If you have WinSCP elsewhere, then specify where the the executible is with this option.

Usage

hg rsync [-s SCRIPT] [PATH]

To use hg-rsync, simply run the following command. This will requires that you at least set the script option and have a default path.

    hg rsync

Options

-s SCRIPT, --script SCRIPT

PATH

Hook

You can add a hook to keep your working directory in sync while you work. If you decide to use a hook, make sure you are configured to sync without having to specify a password.

Here is an example that will sync after you Pull changes.

[hooks]
postincoming.rsync = python:/path/to/hg-rsync.py:hook


CategoryExtensionsByOthers

RemoteSyncExtension (last edited 2011-09-25 13:54:27 by YannEMORIN)