Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push to two repositories that can't reach each other

The setup:

  • a laptop L
  • an office server hosting various repositories SOffice
  • a customer's database server SCustomer

I'm writing code on L for a customer, and regularly want to push it both to SOffice as well as SCustomer.

I know I could use a changegroup hook to push to a third repository from the second (as described in this answer), but this requires that the second can reach the third network-wise.

In my case, each is behind a firewall, and only my laptop typically accesses both through a VPN (or by being physically there). I could set up the VPN on SOffice to get to SCustomer, but I'd rather not.

Is there a way I can, say, set default to two repositories?

like image 432
Sören Kuklau Avatar asked Nov 24 '11 21:11

Sören Kuklau


3 Answers

You can't default to two repositories, but you can define more than one repository in your hgrc file :

[paths]
default= /path/to/first/repo
scustomer = /path/to/second/repo

You can then push to the scustomer repository explicitly :

hg push scustomer

If you want to automate the process of pushing to both repository at once, I'm not aware of a Mercurial method to do it, but it is really easy to create a shell script, alias or something else to run both commands one after the other.

You can even use a hook on the repository to automatically push to the other one, but you will have to discriminate between a "manual" push and the automatic push in the hook, and I'm supposing this will be really messy.

like image 165
krtek Avatar answered Nov 15 '22 11:11

krtek


Could you create a second clone of the repository with a hook that automatically pushes to both of the external repositories? Then push from your working clone to the second clone.

like image 44
Neil Avatar answered Nov 15 '22 10:11

Neil


There's a MultirepoExtension that adds commands for doing any operation on multiple repositories.

Or you could create an alias to push to both like:

[aliases]
pushboth = !$HG push http://first ; $HG push http://second

or you could create a pre-push hook that pushes to the other one. Something like:

[hooks]
pre-push = hg push http://second

But I like (and upvoted) krtek's answer the most. Just give each a path alias and run push twice with the short names instead of the URLs.

like image 22
Ry4an Brase Avatar answered Nov 15 '22 12:11

Ry4an Brase