hg归档到远程目录
有什么方法通过SSH将Mercurial存储库存档到远程目录?例如,如果可以执行以下操作将会很好:hg归档到远程目录
hg archive ssh://[email protected]/path/to/archive
但是,这似乎不起作用。它会在当前目录中创建一个名为ssh:
的目录。
我做了以下快速和肮脏的脚本,通过创建临时ZIP存档,通过SSH复制并解压缩目标目录来模拟所需的行为。但是,我想知道是否有更好的方法。
if [[ $# != 1 ]]; then
echo "Usage: $0 [[email protected]]hostname:remote_dir"
exit
fi
arg=$1
arg=${arg%/} # remove trailing slash
host=${arg%%:*}
remote_dir=${arg##*:}
# zip named to match lowest directory in $remote_dir
zip=${remote_dir##*/}.zip
# root of archive will match zip name
hg archive -t zip $zip
# make $remote_dir if it doesn't exist
ssh $host mkdir --parents $remote_dir
# copy zip over ssh into destination
scp $zip $host:$remote_dir
# unzip into containing directory (will prompt for overwrite)
ssh $host unzip $remote_dir/$zip -d $remote_dir/..
# clean up zips
ssh $host rm $remote_dir/$zip
rm $zip
编辑:clone
- 和 - push
将是理想的,但不幸的是远程服务器没有安装水银。
不可能,这是不可能的 - 我们总是假设远程主机上安装了Mercurial功能。
我绝对同意你,这个功能会很好,但我认为这将不得不在扩展。 Mercurial不是一个普通的SCP/FTP/rsync文件复制程序,所以不要期望在核心中看到这个功能。
这让我想起...也许你可以建立在FTP extension上,让它做你想做的事。祝你好运! :-)
感谢您的明确答案。从Mercurial开发人员直接听到是很好的。 – 2010-03-01 16:08:51
感谢您的评论:-) – 2010-03-03 23:37:33
你有没有考虑过简单地在远程存在一个克隆,并做hg push
存档?
这将是理想的,但不幸的是远程主机没有安装Mercurial。 – 2010-02-25 23:48:46
@Brett:是否可以在本地安装hg?我曾在几个地方做过这个。 – 2010-02-25 23:51:09
这会工作,但我仍然很好奇,如果有远程存档的方式,如果没有,为什么? – 2010-02-25 23:57:14
您可以使用ssh隧道在本地机器上安装远程目录,然后只需执行标准的hg clone
和hg push
操作(就HG而言),但是它们实际写入的文件系统是哪个在远程计算机上?
看起来大概有这样几个计算器问题:
我经常在类似的情况。我解决这个问题的方式是sshfs。
sshfs [email protected]:path/to/repo local/path/to/somewhere-else
hg archive local/path/to/somewhere-else
fusermount -r somewhere-else
唯一的缺点是sshfs的比NFS,桑巴或rsync的更慢。一般来说,我没有注意到,因为我只是很少需要在远程文件系统中执行任何操作。
@Brett丹尼尔:我要张贴保罗弥敦道公布答案。不只是一个*“hg push ssh://[email protected]/hg/”*为你工作? – SyntaxT3rr0r 2010-02-25 23:45:57