有什么方法通过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
将是理想的,但不幸的是远程服务器没有安装水银。
@Brett丹尼尔:我要张贴保罗弥敦道公布答案。不只是一个*“hg push ssh://[email protected]/hg/”*为你工作? – SyntaxT3rr0r 2010-02-25 23:45:57