有没有办法通过 SSH 将 Mercurial 存储库存档到远程目录?例如,如果可以执行以下操作,那就太好了:
hg archive ssh://[email protected] /cdn-cgi/l/email-protection/path/to/archive
然而,这似乎不起作用。它而是创建一个名为的目录ssh:
在当前目录中。
我制作了以下快速而肮脏的脚本,通过创建临时 ZIP 存档、通过 SSH 复制它并解压缩目标目录来模拟所需的行为。不过,我想知道是否有更好的方法。
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
Edit: clone
-and-push
这是理想的选择,但不幸的是远程服务器没有安装 Mercurial。
不,这是不可能的——我们总是假设远程主机上有一个正常运行的 Mercurial 安装。
我绝对同意你的观点,这个功能会很好,但我认为它必须在扩展中实现。 Mercurial 不是通用的 SCP/FTP/rsync 文件复制程序,因此不要期望在核心中看到此功能。
这提醒了我......也许你可以建立在FTP扩展 http://mercurial.selenic.com/wiki/FTPExtension让它做你想做的事。祝你好运! :-)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)