Hg archive for remote directory

Is there a way to archive a Mercurial repository to a remote directory via SSH? For example, it would be nice if you could do the following:

hg archive ssh:// user@example.com /path/to/archive 

However, this does not work. Instead, a directory called ssh: in the current directory.

I made the following quick and dirty script that emulates the desired behavior by creating a temporary ZIP archive, copying it through SSH and unpacking 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 

Edit : clone -and- push would be ideal, but unfortunately Mercurial is not installed on the remote server.

+4
source share
5 answers

No, this is not possible - we always assume that there is a working Mercurial installation on the remote host.

I definitely agree with you that this functionality would be nice, but I think it would have to be done in an extension. Mercurial is not a general program for copying SCP / FTP / rsync files, so do not expect to see this functionality in the kernel.

It reminds me ... maybe you can build on an FTP extension to get it to do what you want. Good luck! :-)

+7
source

Have you just considered having a clone on the remote control and doing hg push for archiving?

+1
source

Could you use the ssh tunnel to mount the remote directory on your local computer, and then just perform the standard hg clone and hg push operations "locally" (as far as HG knows), but where do they actually write to the file system that is located on the remote a computer?

There seem to be a few stackoverflow questions about this:

+1
source

I often find myself in a similar situation. The way I get around is sshfs .

  • sshfs me@somewhere-else :path/to/repo local/path/to/somewhere-else
  • hg archive local/path/to/somewhere-else
  • fusermount -r somewhere-else

The only downside is that sshfs is slower than nfs, samba or rsync. I usually don’t notice, since I rarely have to do anything on a remote file system.

+1
source

You can also just execute hg on the remote host:

 ssh user@example.com "cd /path/to/repo; hg archive -r 123 /path/to/archive" 
0
source

Source: https://habr.com/ru/post/1302433/


All Articles