代码之家  ›  专栏  ›  技术社区  ›  Mike Caron

如何在Windows上进行硬链接克隆

  •  5
  • Mike Caron  · 技术社区  · 14 年前

    我有一个Win7 x64盒子,运行Tortoise 1.0 x64版本。关于乌龟,我们发现它是1.0英寸,带有mercurial-1.5,python-2.6.4,pygtk-2.16.0,gtk-2.18.7“。我还安装了ActivePython 2.6和Mercurial 1.5 x64(通过Mercurial安装程序从 the 64-bit installer . 在我的Windows设备上没有一个带有硬链接的克隆。我的设备上的驱动器也是支持硬链接的NTFS。

    实际上,当我运行python解释器并通过win32file api执行硬链接创建时,它成功地创建了一个链接:

    me@pc C:\temp
    > python
    ActivePython 2.6.2.2 (ActiveState Software Inc.) based on
    Python 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from win32file import *
    >>> CreateHardLink('C:\\temp\\Mike2.txt','C:\\temp\\Mike.txt')
    >>> ^Z
    
    me@pc C:\temp
    > fsutil hardlink list Mike.txt
    \temp\Mike.txt
    \temp\Mike2.txt
    

    但是,如果我使用mercurial进行克隆,则不会得到相同的结果:

    me@pc C:\Users\mcaron
    > which hg
    C:\Program Files (x86)\Mercurial\\hg.EXE
    me@pc C:\temp
    > hg status demo
    mcaron@DEV-MCARON-W64 C:\temp
    > hg log demo
    changeset:   0:6db7092740d5
    tag:         tip
    user:        Michael Caron <mcaron@solidworks.com>
    date:        Wed Mar 24 16:08:38 2010 -0500
    summary:     first
    
    me@pc C:\temp
    > hg clone demo demo2
    updating to branch default
    5 files updated, 0 files merged, 0 files removed, 0 files unresolved
    me@pc C:\temp
    > fsutil hardlink list .\demo\mike.prtprp
    \temp\demo\mike.prtprp
    me@pc4 C:\temp
    > fsutil hardlink list .\demo\mike1.prtprp
    \temp\demo\mike1.prtprp
    me@pc C:\temp
    > fsutil hardlink list .\demo\mike1_2.prtprp
    \temp\demo\mike1_2.prtprp
    mme@pc C:\temp
    > fsutil hardlink list .\demo\mike2.prtprp
    \temp\demo\mike2.prtprp
    
    me@pc4 C:\temp
    > hg --version
    Mercurial Distributed SCM (version 1.5)
    
    Copyright (C) 2005-2010 Matt Mackall <mpm@selenic.com> and others
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    me@pc C:\temp
    > python -V
    Python 2.6.2
    

    是否有人在使用硬链接的Windows上进行克隆,或者不支持该克隆?我注意到TortoiseHg安装程序附带了一个python 2.6安装。还注意到它有自己的hg可执行文件(我也尝试过得到相同的结果)。TortoiseHg和Mercurial安装是否会造成问题?

    1 回复  |  直到 14 年前
        1
  •  9
  •   Ry4an Brase    14 年前

    是的,你得到了答案:硬链接在repo(.hg)中,而不是工作目录。因此,如果使用 -U 克隆不占用额外的磁盘空间。在服务器端,无工作目录克隆是一个很好的选择,有时在桌面上也很有用。如果你忘记了-u,你可以随时摆脱回购的工作目录 hg update -r null 它将更新为空修订版,这比添加任何文件都要早。