Home

Mercurial autosync extension

Requires Mercurial ≥ 2.0 (older versions may work too, but tests have been run for 2.0)

Automated duplex synchronization with another repository

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:

Example repo setup

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.

Flattr Mercurial AutoSync Extension

Installation

Download or clone hg-autosync to some place, then enable the extension in your hgrc file:

[extensions]
autosync = /path/to/autosync.py

Configuration

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

Usage

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.

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.