Is it possible to synchronize local/remote repositories without any interaction (i.e. by script)?

Adrian Klaver adrian.klaver at aklaver.com
Sun Aug 12 15:36:16 UTC 2018


On 08/12/2018 07:00 AM, Chris Green wrote:
> I am a 'single user' developer (retired Software Engineer) and I use
> mercurial to keep track of software I write mostly for my own use.
> It's an excellent tool, much more intuitive than git for me anyway.
> 
> 
> I would like to be able to keep some repositories on remote systems
> in step with a 'master' repository on my home desktop machine.  This
> is all on Linux (Debian or derivatives) systems.  All the systems have
> ssh access to each other but in the main this requires a password or
> key/passphrase for authentication.
> 
> 
> Firstly, is there a straightforward sequence of commands that one can
> issue to 'synchronize' two repositories?  Since I am almost certainly
> the only user and I'm unlikely to edit the same file on two different
> systems (without committing changes in between) no file merges should
> be required.  I'm happy for a script to ask for input if it does
> detect that some sort of merge is required.

The way I did/do this:

1) Setup a private repo at Bitbucket(bitbucket.org), its free.

2) Use hg push and pull commands to move commits from local computer to 
Bitbucket and then to remote computer.


I would say doing an automated script on login will cause you more 
issues then it is worth. You will forget to commit after a session and 
then the script will choke. While it is possible to code for the common 
possible errors I find the feedback from running the commands manually 
important.


> 
> So, I've cloned a repository on a remote system somewhere:-
> 
>      hg clone ssh://my.home.system.com/repo1
> 
> I have two use cases:-
> 
>      1 - I've changed something on the home system and I want the
>      change to be copied to the remote system by a script called from
>      .bash_login (i.e. automatically at login).
> 
>      2 - After logging in on the remote system via ssh I change
>      something there and I want the change copied back to the home
>      system by the .bash_logout script (i.e. automatically at logout).
> 
> These need to be as far as possible silent scripts, as noted above I'm
> happy to have them talk to me if there's a conflict of some sort but
> otherwise I want quietness.  I can probably manage to make the ssh
> access password/key-less but how easy is it to automate the mercurial
> bits?
> 


-- 
Adrian Klaver
adrian.klaver at aklaver.com



More information about the Mercurial mailing list