How to push/pull over arbitrary pipe?

Jesse Glick jesse.glick at sun.com
Sat Nov 14 09:49:40 CST 2009


Consider two machines A and B, each with a similar repository. Assume that neither repo can access the other via standard channels like HTTP(S), SSH, etc., but that it is 
possible to set up a bidirectional bytestream between the two by other means. Is it possible to push from A to B (or pull into B from A) using standard Mercurial 
commands, i.e. without writing a new extension?

'hg serve --stdio' sounds promising so I tried the following but it did not work (last command just hung):

mkfifo /tmp/hgpipe1
mkfifo /tmp/hgpipe2
hg -R repo-a serve --stdio < /tmp/hgpipe1 > /tmp/hgpipe2 &
hg -R repo-b pull --ssh 'cat < /tmp/hgpipe2 > /tmp/hgpipe1' ssh://wherever/

Is there some alternative syntax that works for the other end?


I guess a different tactic would be

hg -R repo-a bundle `hg -R repo-b heads --template ' --base {node}'` /tmp/xfer.hg
hg -R repo-b unbundle /tmp/xfer.hg

though when I try it on a repo with multiple branches it does not quite work: --base does not reliably exclude even the named changeset:

$ hg glog --template '{node}\n'
@  e5fa3a6df5f0c4c940c4f4ab237eb6fbca091deb
|
| o    d9f586bbe8e8b75eed46b0abd5bcc8f348ce1e3c
| |\
| | o  2978fe74aa4508365fd6a970a935b8a0953591cf
| | |
| | o  8b698abb9f51ae602f4e497966197c4c13341751
| | |
| o |  9e526fb25bc2d2f4e7aeb72fd96b35b9902a0455
| | |
| o |  498d31677409706dbc0a2abb29674867d4b45fe6
| |\|
| o |  b117c3731d2aa491b4bda5f22ff744331f97a3af
| | |
| o |  6074b66facf0c9ffc15b858c2ab39eebd0d66c55
| |/
o /  783c8713fd16d257e78f463ff254ad8c9de69439
|/
o  039e779c048c219ca8161df39fc7bb0eb8d7ea21
$ hg --debug bundle --base d9f586bbe8e8b75eed46b0abd5bcc8f348ce1e3c --base 783c8713fd16d257e78f463ff254ad8c9de69439 /tmp/xfer.hg
2 changesets found
list of changesets:
d9f586bbe8e8b75eed46b0abd5bcc8f348ce1e3c  <=== why?!
e5fa3a6df5f0c4c940c4f4ab237eb6fbca091deb  <=== expected just this one

Fortunately the only harm I see from that bug is that extraneous changesets may be included. ('hg -R repo-a out repo-b' correctly displays just e5fa3a6df5f0.)



More information about the Mercurial-devel mailing list