Differences between revisions 3 and 4
Revision 3 as of 2011-06-06 16:41:24
Size: 3217
Editor: RyanSeto
Comment: Fix order of wording.
Revision 4 as of 2011-09-25 13:54:27
Size: 3208
Editor: YannEMORIN
Comment: Make the page work with the all-extensions scrapping tool
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
Mercurial Extension: http://bitbucket.org/MrWerewolf/hg-rsync Repository: http://bitbucket.org/MrWerewolf/hg-rsync

Remote Sync

This extension is not distributed with Mercurial.

Author: Ryan Seto

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


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.


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

rsync = /path/to/hg-rsync

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

Here is an example:

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


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

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.


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].


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.


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


-s SCRIPT, --script SCRIPT

  • The path to the WinSCP sync script.


  • Remote path to sync from. If unspecified this will be the default path. This can be an alias or a full ssh:// path.


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.

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


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