汞归档到远程目录 [英] hg archive to Remote Directory
问题描述
是否可以通过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://user@example.com/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
-和-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! :-)
这篇关于汞归档到远程目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!