代码之家  ›  专栏  ›  技术社区  ›  Brett Daniel

Hg存档到远程目录

  •  4
  • Brett Daniel  · 技术社区  · 15 年前

    有没有办法通过ssh将mercurial存储库归档到远程目录?例如,如果你能做到以下几点就好了:

    hg archive ssh://user@example.com/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
    

    编辑 : clone -和 push 很理想,但不幸的是,远程服务器没有安装mercurial。

    5 回复  |  直到 9 年前
        1
  •  7
  •   Martin Geisler    15 年前

    不,这是不可能的——我们总是假设在远程主机上有一个运行正常的mercurial安装。

    我完全同意你的观点,这项功能是很好的,但我认为它必须进行扩展。Mercurial不是一个通用的scp/ftp/rsync文件复制程序,因此不要期望在核心中看到这个功能。

    这提醒了我…也许你可以建立在 FTP extension 让它做你想做的。祝你好运!:-)

        2
  •  1
  •   Paul Nathan    15 年前

    你有没有想过在遥控器上放一个克隆人 hg push 归档?

        3
  •  1
  •   Community Mohan Dere    8 年前

    可以使用ssh隧道在本地计算机上挂载远程目录,然后执行标准操作吗? hg clone hg push 操作“本地”(据hg所知),但是它们实际上在哪里写入远程计算机上的文件系统?

    这样做似乎有几个stackoverflow问题:

        4
  •  1
  •   deft_code    15 年前

    我经常遇到类似的情况。我的生活方式是 sshfs .

    1. sshfs me@somewhere-else:path/to/repo local/path/to/somewhere-else
    2. hg archive local/path/to/somewhere-else
    3. fusermount -r somewhere-else

    唯一的缺点是sshfs比nfs、samba或rsync慢。通常我不会注意到,因为我很少需要在远程文件系统中做任何事情。

        5
  •  0
  •   DustWolf    9 年前

    您也可以简单地在远程主机上执行hg:

    ssh user@example.com "cd /path/to/repo; hg archive -r 123 /path/to/archive"
    
    推荐文章