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

Cameron Simpson cs at cskk.id.au
Wed Aug 15 23:22:48 UTC 2018


Chris,

I'm a little late here, but I'm in a similar situation to you. Here's what I 
do.

1: I've got a personal repo at bitbucket:

  https://bitbucket.org/cameron_simpson/css/overview

which I push to with:

  hg push --new-branch -r tip ssh://hg@bitbucket.org/cameron_simpson/css

which is normally silent (well, noninteractive - it reports on how many 
changesets got pushed).

2: I live on my laptop, but I've got working repos on a couple of home 
machines.  Since the .hg/hgrc in the local repo has this:

  [paths]
  default = ssh://hg@bitbucket.org/cameron_simpson/css
  home = ssh://home/hg/css

I can just "hg push home" to update the home machine.

Now, you could stick any of these in an hg commit hook, and even kick them off 
in the background with output redirected from there (to not stall your commits 
and not produce annoying noise) because if you're offline or there's some other 
failure/conflict you can always address it later.

You do want to keep in your head the difference between a repo and a checkout.  
In my mind, the repo is the state (contained in the .hg subdir) and the 
checkout is your working set of files. The "hg push" above only updates the 
repo. The checked out files at the far end are _not_ updated.

For Bitbucket that is normal and irrelevant - it _only_ manages/provides a 
repo. For the home machine it means the work tree has all the new state in the 
repo but that the working files are not up to date.

Next time I stand in the home machine checkout I need to go "hg up" to bring 
the working files up to date. You could automate or not. You _do_ want to do it 
before doing new work as otherwise your next commit there will make a new 
branch.

Cheers,
Cameron Simpson <cs at cskk.id.au>



More information about the Mercurial mailing list