问题描述
有没有办法通过 SSH 将 Mercurial 存储库归档到远程目录?例如,如果可以执行以下操作就好了:
Is there any way to archive a Mercurial repository to a remote directory over SSH? For example, it would be nice if one could do the following:
hg archive ssh://[email protected]/path/to/archive
然而,这似乎不起作用.它会在当前目录中创建一个名为 ssh:
的目录.
However, that does not appear to work. It instead creates a directory called ssh:
in the current directory.
我制作了以下简单粗暴的脚本,通过创建临时 ZIP 存档、通过 SSH 复制并解压缩目标目录来模拟所需的行为.但是,我想知道是否有更好的方法.
I made the following quick-and-dirty script that emulates the desired behavior by creating a temporary ZIP archive, copying it over SSH, and unzipping the destination directory. However, I would like to know if there is a better way.
if [[ $# != 1 ]]; then
echo "Usage: $0 [user@]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
-and-push
是理想的,但不幸的是远程服务器没有安装 Mercurial.
Edit: clone
-and-push
would be ideal, but unfortunately the remote server does not have Mercurial installed.
推荐答案
不,这是不可能的——我们总是假设远程主机上有一个正常运行的 Mercurial 安装.
Nope, this is not possible -- we always assume that there is a functioning Mercurial installation on the remote host.
我完全同意你的看法,这个功能会很好,但我认为它必须在扩展中实现.Mercurial 不是通用的 SCP/FTP/rsync 文件复制程序,因此不要期望在核心中看到此功能.
I definitely agree with you that this functionality would be nice, but I think it would have to be made in an extension. Mercurial is not a general SCP/FTP/rsync file-copying program, so don't expect to see this functionality in the core.
这让我想起...也许你可以建立在 FTP 扩展之上你想要什么.祝你好运!:-)
This reminds me... perhaps you can built on the FTP extension to make it do what you want. Good luck! :-)
这篇关于hg 存档到远程目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!