This project is not maintained anymore (2015-03-31). Let me know if you want to continue working on this.
Requires Mercurial ≥ 2.0 (older versions may work too, but tests have been run for 2.0)
The idea of this extension is to use Mercurial as a synchronization engine to keep files in sync across work stations.
This extension provides the autosync command which automatically and continuously commits working copy changes, fetches (pull, merge, commit) changes from another repository and pushes local changes back to the other repository. Think of configuration files or to-do lists as examples for things to synchronize. On a higher level the autosync command not only synchronizes repositories but working copies. A central repository (usually without a working copy) must be used as synchronization hub:
Running the autosync command in work and home ensures the working copies (!) of both repositories stay in sync (as long as they are no conflicting changes).
Errors and merge conflicts which cannot be resolved automatically are highlighted in the output. Additionally an alert tool can be specified to run on errors and conflicts. The alerter is supposed to notify errors to a human. In any case the command keeps running and retries after the next interval, hoping things get fixed externally.
When running in daemon mode, any output gets logged into the file autosync.log within the repository's .hg directory (use --daemon-log to set a different file).
This command denies to run in a virgin repository as this may unrelate repositories which were supposed to get synchronized. Before running autosync, pull or commit something first manually.
Download or clone hg-autosync to some place, then enable the extension in your hgrc file:
[extensions] autosync = /path/to/autosync.py
[autosync] merge = ... alert = ...
By default Mercurial's internal non-interactive merger internal:merge is used when fetching from another repository (i.e. option ui → merge and HGMERGE are ignored). Option autosync → merge can be used to set another merge tool (e.g. inernal:local to let local changes automatically win on conflicts).
The option autosync → alert may point to a program to call on problems to notify them to a human. The repository path and an error message are passed as arguments to the alerter program. Example alert tools can be found in the directory alerter.
Typically you run hg autosync -D in each repository clone you want to be synchronized.
Inspect hg help autosync to get more detailed information and available options.